### Description In .NET 8 there is a bug regarding the handling of generic types, which produces a `TypeLoadException` ### Reproduction Steps ON .NET 8 Compile & run the following C# console application code code: ```csharp public interface IGeneric<T> { } public class DualGeneric<T1, T2> where T1 : T2 { } public class Record : DualGeneric<Record, IRecord>, IRecord { } public interface IRecord : IGeneric<Record> { } public interface IRecord<T> : IGeneric<Record<T>> { } public class Record<T> : DualGeneric<Record<T>, IRecord<T>>, IRecord<T> { } internal class Program { private static void Main(string[] args) { var record = new Record<int>(); Console.WriteLine("Works"); } } ``` ### Expected behavior Program prints Works message. ### Actual behavior Actual result: `System.TypeLoadException: 'GenericArguments[0], 'Record`1[T]', on 'DualGeneric`2[T1,T2]' violates the constraint of type parameter 'T1'.'` ### Regression? Code runs perfectly fine, when it's targeting .NET 7 ### Known Workarounds Run the code on .NET 7 ### Configuration * .NET 8 * Windows 10 22H2 * X64 * Shouldn't be specific to configuration ### Other information _No response_
Activity
webmaster442 commentedon Feb 1, 2024
Additional note: When removing the
where T1 : T2constraint from theDualGenerictype, the code works.MichalStrehovsky commentedon Feb 1, 2024
Maybe same as #97667? Cc @davidwrighton
davidwrighton commentedon Feb 2, 2024
@MichalStrehovsky @webmaster442 yes, this looks like a duplicate. The fix is currently in code review.
lambdageek commentedon Feb 6, 2024
Duplicate of #97667