diff --git a/src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/SingleValueExtensions.cs b/src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/SingleValueExtensions.cs index 5362f267afa531..7730958dd87e62 100644 --- a/src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/SingleValueExtensions.cs +++ b/src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/SingleValueExtensions.cs @@ -21,7 +21,7 @@ public static class SingleValueExtensions new GenericParameterValue ((ITypeParameterSymbol) underlyingType)), // typeof(Nullable<>) TypeKind.Error => new SystemTypeValue (new TypeProxy (type)), - TypeKind.Class or TypeKind.Struct or TypeKind.Interface => + TypeKind.Class or TypeKind.Enum or TypeKind.Interface or TypeKind.Struct => new NullableSystemTypeValue (new TypeProxy (type), new SystemTypeValue (new TypeProxy (underlyingType))), _ => UnknownValue.Instance }; diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/RunClassConstructor.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/RunClassConstructor.cs index 20812c86edf305..8c38ac7742f35f 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/RunClassConstructor.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/RunClassConstructor.cs @@ -22,6 +22,7 @@ public static void Main () TestIfElseUsingRuntimeTypeHandle (1); TestIfElseUsingType (1); TestNullableValueType (); + TestNullableEnum (); } [Kept] @@ -132,6 +133,16 @@ static void TestNullableValueType () RuntimeHelpers.RunClassConstructor (typeof (int?).TypeHandle); } + [Kept] + [KeptMember ( "value__")] + enum MyEnum {} + + [Kept] + static void TestNullableEnum () + { + RuntimeHelpers.RunClassConstructor (typeof (Nullable).TypeHandle); + } + [Kept] [KeptMember (".cctor()")] class OnlyUsedViaReflection