2 using System
.Reflection
;
4 public class CtorInfoTest
12 public static void Main(string[] args
)
15 // uses static initialization
16 int[] iarray
= // int array, int constants
27 object[] oarray
= // int array, int constants
46 // mcs used to throw with 7 or more elements in the array initializer
47 ConstructorInfo
[] ciarray
= // ref array, null constants
58 string[] scarray
= // string array, string constants
69 string[] snarray
= // string array, null constants
80 decimal[] darray
= // decimal constants
92 IConvertible
[] lcarray
= // boxed integer constants
105 System
.Enum
[] eatarray
= // boxed enum constants
107 AttributeTargets
.Assembly
,
108 AttributeTargets
.Module
,
109 AttributeTargets
.Class
,
110 AttributeTargets
.Struct
,
111 AttributeTargets
.Enum
,
112 AttributeTargets
.Constructor
,
113 AttributeTargets
.Method
,
114 AttributeTargets
.Property
,
115 AttributeTargets
.Field
,
116 AttributeTargets
.Event
,
117 AttributeTargets
.Interface
,
118 AttributeTargets
.Parameter
,
119 AttributeTargets
.Delegate
,
120 AttributeTargets
.ReturnValue
,
121 AttributeTargets
.All
,
124 E
[] atarray
= // enum constants
131 string[] smarray
= // string array, mixture
137 for (int i
= 0; i
< iarray
.Length
; ++i
)
138 Assert (i
, iarray
[i
]);
140 for (int i
= 0; i
< ciarray
.Length
; ++i
)
141 Assert (null, ciarray
[i
]);
143 Assert ("a", scarray
[0]);
145 for (int i
= 0; i
< snarray
.Length
; ++i
)
146 Assert (null, snarray
[i
]);
148 for (decimal i
= 0; i
< darray
.Length
; ++i
)
149 Assert (i
, darray
[(int)i
]);
151 for (int i
= 0; i
< lcarray
.Length
; ++i
)
152 Assert (i
, lcarray
[i
]);
154 Assert (E
.A
, atarray
[0]);
155 Assert (E
.B
, atarray
[1]);
157 Assert (AttributeTargets
.Assembly
, eatarray
[0]);
158 Assert (AttributeTargets
.Class
, eatarray
[2]);
160 Assert (null, smarray
[0]);
161 Assert ("a", smarray
[1]);
165 static void Assert (object expected
, object value)
167 if (expected
== null && value == null)
170 if (!expected
.Equals (value))
171 Console
.WriteLine ("ERROR {0} != {1}", expected
, value);