Skip to content

Commit dd5962b

Browse files
github-actions[bot]sbomerjeffschwMSFT
authored
Fix analyzer tracking of nullable enums (#110331)
Co-authored-by: Sven Boemer <[email protected]> Co-authored-by: Jeff Schwartz <[email protected]>
1 parent f09d2e8 commit dd5962b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/SingleValueExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static class SingleValueExtensions
2121
new GenericParameterValue ((ITypeParameterSymbol) underlyingType)),
2222
// typeof(Nullable<>)
2323
TypeKind.Error => new SystemTypeValue (new TypeProxy (type)),
24-
TypeKind.Class or TypeKind.Struct or TypeKind.Interface =>
24+
TypeKind.Class or TypeKind.Enum or TypeKind.Interface or TypeKind.Struct =>
2525
new NullableSystemTypeValue (new TypeProxy (type), new SystemTypeValue (new TypeProxy (underlyingType))),
2626
_ => UnknownValue.Instance
2727
};

src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/RunClassConstructor.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static void Main ()
2222
TestIfElseUsingRuntimeTypeHandle (1);
2323
TestIfElseUsingType (1);
2424
TestNullableValueType ();
25+
TestNullableEnum ();
2526
}
2627

2728
[Kept]
@@ -132,6 +133,16 @@ static void TestNullableValueType ()
132133
RuntimeHelpers.RunClassConstructor (typeof (int?).TypeHandle);
133134
}
134135

136+
[Kept]
137+
[KeptMember ( "value__")]
138+
enum MyEnum {}
139+
140+
[Kept]
141+
static void TestNullableEnum ()
142+
{
143+
RuntimeHelpers.RunClassConstructor (typeof (Nullable<MyEnum>).TypeHandle);
144+
}
145+
135146
[Kept]
136147
[KeptMember (".cctor()")]
137148
class OnlyUsedViaReflection

0 commit comments

Comments
 (0)