2 using System.Reflection;
4 public sealed class MyAttribute : Attribute
6 public Type Type { get; set; }
7 public MyAttribute (Type t) {
9 // throw new Exception ();
12 public override string ToString () {
17 public sealed class My2Attribute : Attribute
19 public object Obj { get; set; }
20 public My2Attribute (object t) {
22 // throw new Exception ();
25 public override string ToString () {
30 public sealed class My3Attribute : Attribute
32 public My3Attribute (object[] arr) {
36 public class MyException : Exception {}
37 public sealed class ExceptionOnCtor : Attribute
39 public ExceptionOnCtor () {
40 throw new MyException ();
48 [My3 (new object[] { DisappearingEnum.V0 })]
49 public static int test_0_missing_enum_arg_alt3 () {
51 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
53 } catch (TypeLoadException) {
58 [My2 (new DisappearingEnum[] { DisappearingEnum.V0 })]
59 public static int test_0_missing_enum_arg_alt2 () {
61 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
63 } catch (TypeLoadException) {
68 [My2 (new object[] { DisappearingEnum.V0 })]
69 public static int test_0_missing_enum_arg_alt () {
71 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
73 } catch (TypeLoadException) {
78 [My2 (DisappearingEnum.V0)]
79 public static int test_0_missing_enum_arg () {
81 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
83 } catch (TypeLoadException) {
88 [My3 (new object[] { typeof (DisappearingType)})]
89 public static int test_0_array_of_missing_type_alt2 () {
91 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
93 } catch (TypeLoadException) {
97 [My2 (new Type[] { typeof (DisappearingType)})]
98 public static int test_0_array_of_missing_type () {
100 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
102 } catch (TypeLoadException) {
109 [My2 (typeof (DisappearingType))]
110 public static int test_0_missing_type_arg_alt () {
112 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
114 } catch (TypeLoadException) {
119 [My (typeof (DisappearingType))]
120 public static int test_0_missing_type_arg () {
122 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
124 } catch (TypeLoadException) {
131 public static int test_0_missing_ctor () {
133 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
135 } catch (MissingMethodException) {
140 [BadAttr (Field = 1)]
141 public static int test_0_missing_field () {
143 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
145 } catch (CustomAttributeFormatException) {
150 [BadAttr (Property = 1)]
151 public static int test_0_missing_property () {
153 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
155 } catch (CustomAttributeFormatException) {
160 /* FIXME Verify the type of the cattr with the one on the field/property
161 [BadAttr (Field2 = 1)]
162 public static int test_0_bad_field () {
164 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
166 } catch (CustomAttributeFormatException) {
171 [BadAttr (Property2 = 1)]
172 public static int test_0_bad_property () {
174 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
176 } catch (CustomAttributeFormatException) {
182 [BadAttr (Property3 = 1)]
183 public static int test_0_bad_property_no_setter () {
185 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
187 } catch (CustomAttributeFormatException) {
193 public static int test_0_cattr_ctor_throws () {
195 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
197 } catch (MyException) {
203 static int Main (String[] args) {
204 return TestDriver.RunTests (typeof (Tests), args);