@@ -50,6 +50,57 @@ public void FieldTest(string fieldName, NullabilityState readState, NullabilityS
50
50
Assert . Null ( nullability . ElementType ) ;
51
51
}
52
52
53
+ public class FI_FieldArray
54
+ {
55
+ public int [ ] intArray ;
56
+ public object ? [ ] objectArray ;
57
+ public string ? [ ] stringArray ;
58
+ }
59
+
60
+ public class FI_GenericClassField < T >
61
+ {
62
+ public object ? [ ] objectArray ;
63
+ public T ? genparamField ;
64
+ public T ? [ ] gparrayField ;
65
+ }
66
+
67
+ public static IEnumerable < object [ ] > FieldArrayTestData ( )
68
+ {
69
+ yield return new object [ ] { "objectArray" , NullabilityState . NotNull , NullabilityState . NotNull , typeof ( object [ ] ) } ;
70
+ yield return new object [ ] { "stringArray" , NullabilityState . NotNull , NullabilityState . NotNull , typeof ( string [ ] ) } ;
71
+ }
72
+
73
+ [ Theory ]
74
+ [ MemberData ( nameof ( FieldArrayTestData ) ) ]
75
+ public void FieldArrayTest ( string fieldName , NullabilityState readState , NullabilityState writeState , Type type )
76
+ {
77
+ FieldInfo field = typeof ( FI_FieldArray ) . GetField ( fieldName , flags ) ;
78
+ NullabilityInfo nullability = nullabilityContext . Create ( field ) ;
79
+ Assert . Equal ( readState , nullability . ReadState ) ;
80
+ Assert . Equal ( writeState , nullability . WriteState ) ;
81
+ Assert . Equal ( type , nullability . Type ) ;
82
+ Assert . Empty ( nullability . GenericTypeArguments ) ;
83
+ }
84
+
85
+ public static IEnumerable < object [ ] > GenericArrayFieldTypeTestData ( )
86
+ {
87
+ yield return new object [ ] { "objectArray" , NullabilityState . NotNull , NullabilityState . NotNull , typeof ( object [ ] ) } ;
88
+ yield return new object [ ] { "genparamField" , NullabilityState . NotNull , NullabilityState . NotNull , typeof ( int ) } ;
89
+ yield return new object [ ] { "gparrayField" , NullabilityState . NotNull , NullabilityState . NotNull , typeof ( int [ ] ) } ;
90
+ }
91
+
92
+ [ Theory ]
93
+ [ MemberData ( nameof ( GenericArrayFieldTypeTestData ) ) ]
94
+ public void GenericArrayFieldTypeTest ( string fieldName , NullabilityState readState , NullabilityState writeState , Type type )
95
+ {
96
+ FieldInfo field = typeof ( FI_GenericClassField < int > ) . GetField ( fieldName , flags ) ! ;
97
+ NullabilityInfo nullability = nullabilityContext . Create ( field ) ;
98
+ Assert . Equal ( readState , nullability . ReadState ) ;
99
+ Assert . Equal ( writeState , nullability . WriteState ) ;
100
+ Assert . Equal ( type , nullability . Type ) ;
101
+ Assert . Empty ( nullability . GenericTypeArguments ) ;
102
+ }
103
+
53
104
public static IEnumerable < object [ ] > EventTestData ( )
54
105
{
55
106
yield return new object [ ] { "EventNullable" , NullabilityState . Nullable , NullabilityState . Nullable , typeof ( EventHandler ) } ;
0 commit comments