You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding a new class with generic constraints and passing it down to the parent class the update seems to apply successfully but the generated type is invalid.
Reproduction Steps
Run the following program with dotnet watch or from Visual Studio and uncomment L10 when the application is running.
using System.Reflection.Metadata;[assembly:MetadataUpdateHandler(typeof(MetadataUpdateHandler))]
Console.WriteLine("Ready..");await Task.Delay(-1);publicinterface ICat;internalabstractclass Holder<T>;//internal sealed class CatHolder<T> : Holder<T> where T : ICat; //Uncomment this line when the application is running.internalstaticclassMetadataUpdateHandler{privatestaticvoidUpdateApplication(Type[]?_){try{
Console.WriteLine("Update..");
GC.KeepAlive(typeof(MetadataUpdateHandler).Assembly.GetTypes());}catch(Exceptionex){
Console.WriteLine(ex);}}}
Expected behavior
The update is applied successfully with the correct generic constraints.
Actual behavior
The following exception is printed to the console.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
GenericArguments[0], 'T', on 'Holder`1[T]' violates the constraint of type parameter 'T'.
at System.Reflection.RuntimeModule.GetDefinedTypes()
at System.Reflection.RuntimeModule.GetTypes()
at MetadataUpdateHandler.UpdateApplication(Type[] _)
System.TypeLoadException: GenericArguments[0], 'T', on 'Holder`1[T]' violates the constraint of type parameter 'T'.
Regression?
No, fails on .NET 6 and .NET 8.
Known Workarounds
No response
Configuration
9.0.100-preview.2.24157.14
Microsoft Visual Studio Community 2022 (64-bit) - Preview Version 17.10.0 Preview 2.0
Other information
No response
The text was updated successfully, but these errors were encountered:
Description
When adding a new class with generic constraints and passing it down to the parent class the update seems to apply successfully but the generated type is invalid.
Reproduction Steps
Run the following program with
dotnet watch
or from Visual Studio and uncomment L10 when the application is running.Expected behavior
The update is applied successfully with the correct generic constraints.
Actual behavior
The following exception is printed to the console.
Regression?
No, fails on .NET 6 and .NET 8.
Known Workarounds
No response
Configuration
9.0.100-preview.2.24157.14
Microsoft Visual Studio Community 2022 (64-bit) - Preview Version 17.10.0 Preview 2.0
Other information
No response
The text was updated successfully, but these errors were encountered: