@@ -65,6 +65,7 @@ public static void Main ()
6565 GetUnderlyingTypeOnNonNullableKnownType . Test ( ) ;
6666 MakeGenericTypeWithUnknownValue ( new object [ 2 ] { 1 , 2 } ) ;
6767 MakeGenericTypeWithKnowAndUnknownArray ( ) ;
68+ RequiresOnNullableMakeGenericType . Test ( ) ;
6869 }
6970
7071 [ Kept ]
@@ -97,6 +98,68 @@ static void RequireAllFromMadeGenericNullableOfTypeWithMethodWithRuc ()
9798 typeof ( Nullable < > ) . MakeGenericType ( typeof ( TestStructWithRucMethod ) ) . RequiresAll ( ) ;
9899 }
99100
101+ public class RequiresOnNullableMakeGenericType
102+ {
103+ [ Kept ]
104+ static Type UnannotatedField ;
105+ [ Kept ]
106+ [ KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
107+ [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicMethods ) ]
108+ static Type FieldWithMethods ;
109+ [ Kept ]
110+ [ UnexpectedWarning ( "IL2090" , Tool . TrimmerAnalyzerAndNativeAot , "https://github.com/dotnet/runtime/issues/93800" ) ]
111+ static void Field ( )
112+ {
113+ typeof ( Nullable < > ) . MakeGenericType ( UnannotatedField ) . GetMethods ( ) ;
114+ typeof ( Nullable < > ) . MakeGenericType ( FieldWithMethods ) . GetMethods ( ) ;
115+ }
116+
117+ [ Kept ]
118+ [ UnexpectedWarning ( "IL2090" , Tool . TrimmerAnalyzerAndNativeAot , "https://github.com/dotnet/runtime/issues/93800" ) ]
119+ static void Parameter (
120+ Type unannotated ,
121+ [ KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
122+ [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicMethods ) ] Type annotated )
123+ {
124+ typeof ( Nullable < > ) . MakeGenericType ( unannotated ) . GetMethods ( ) ;
125+ typeof ( Nullable < > ) . MakeGenericType ( annotated ) . GetMethods ( ) ;
126+ }
127+
128+ [ Kept ]
129+ [ ExpectedWarning ( "IL2090" , "TUnannotated" ) ]
130+ static void TypeParameter <
131+ TUnannotated ,
132+ [ KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
133+ [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicMethods ) ] TAnnotated > ( )
134+ {
135+ typeof ( Nullable < > ) . MakeGenericType ( typeof ( TUnannotated ) ) . GetMethods ( ) ;
136+ typeof ( Nullable < > ) . MakeGenericType ( typeof ( TAnnotated ) ) . GetMethods ( ) ;
137+ }
138+
139+ [ Kept ]
140+ [ UnexpectedWarning ( "IL2090" , Tool . TrimmerAnalyzerAndNativeAot , "https://github.com/dotnet/runtime/issues/93800" ) ]
141+ static void ReturnValue ( )
142+ {
143+ typeof ( Nullable < > ) . MakeGenericType ( GetUnannotated ( ) ) . GetMethods ( ) ;
144+ typeof ( Nullable < > ) . MakeGenericType ( GetAnnotated ( ) ) . GetMethods ( ) ;
145+ }
146+ [ Kept ]
147+ static Type GetUnannotated ( ) => null ;
148+ [ Kept ]
149+ [ return : KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
150+ [ return : DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicMethods ) ]
151+ static Type GetAnnotated ( ) => null ;
152+
153+ [ Kept ]
154+ public static void Test ( )
155+ {
156+ Field ( ) ;
157+ Parameter ( null , null ) ;
158+ TypeParameter < object , object > ( ) ;
159+ ReturnValue ( ) ;
160+ }
161+ }
162+
100163 [ Kept ]
101164 static void TestRequireRucMethodThroughNullable ( )
102165 {
0 commit comments