2 using System.Reflection;
4 // this for test_0_missing_attr_on_assembly
5 [assembly: MissingAttribute]
7 public sealed class MyAttribute : Attribute
9 public Type Type { get; set; }
10 public MyAttribute (Type t) {
12 // throw new Exception ();
15 public override string ToString () {
20 public sealed class My2Attribute : Attribute
22 public object Obj { get; set; }
23 public My2Attribute (object t) {
25 // throw new Exception ();
28 public override string ToString () {
33 public sealed class My3Attribute : Attribute
35 public My3Attribute (object[] arr) {
39 public class MyException : Exception {}
40 public sealed class ExceptionOnCtor : Attribute
42 public ExceptionOnCtor () {
43 throw new MyException ();
51 public static int test_0_missing_attr_on_assembly () {
53 Assembly.GetExecutingAssembly().GetCustomAttributes (false);
55 } catch (TypeLoadException exn) {
60 [My3 (new object[] { DisappearingEnum.V0 })]
61 public static int test_0_missing_enum_arg_alt3 () {
63 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
65 } catch (TypeLoadException) {
70 [My2 (new DisappearingEnum[] { DisappearingEnum.V0 })]
71 public static int test_0_missing_enum_arg_alt2 () {
73 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
75 } catch (TypeLoadException) {
80 [My2 (new object[] { DisappearingEnum.V0 })]
81 public static int test_0_missing_enum_arg_alt () {
83 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
85 } catch (TypeLoadException) {
90 [My2 (DisappearingEnum.V0)]
91 public static int test_0_missing_enum_arg () {
93 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
95 } catch (TypeLoadException) {
100 [My3 (new object[] { typeof (DisappearingType)})]
101 public static int test_0_array_of_missing_type_alt2 () {
103 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
105 } catch (TypeLoadException) {
109 [My2 (new Type[] { typeof (DisappearingType)})]
110 public static int test_0_array_of_missing_type () {
112 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
114 } catch (TypeLoadException) {
121 [My2 (typeof (DisappearingType))]
122 public static int test_0_missing_type_arg_alt () {
124 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
126 } catch (TypeLoadException) {
131 [My (typeof (DisappearingType))]
132 public static int test_0_missing_type_arg () {
134 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
136 } catch (TypeLoadException) {
143 public static int test_0_missing_ctor () {
145 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
147 } catch (MissingMethodException) {
152 [BadAttr (Field = 1)]
153 public static int test_0_missing_field () {
155 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
157 } catch (CustomAttributeFormatException) {
162 [BadAttr (Property = 1)]
163 public static int test_0_missing_property () {
165 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
167 } catch (CustomAttributeFormatException) {
172 /* FIXME Verify the type of the cattr with the one on the field/property
173 [BadAttr (Field2 = 1)]
174 public static int test_0_bad_field () {
176 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
178 } catch (CustomAttributeFormatException) {
183 [BadAttr (Property2 = 1)]
184 public static int test_0_bad_property () {
186 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
188 } catch (CustomAttributeFormatException) {
194 [BadAttr (Property3 = 1)]
195 public static int test_0_bad_property_no_setter () {
197 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
199 } catch (CustomAttributeFormatException) {
205 public static int test_0_cattr_ctor_throws () {
207 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
209 } catch (MyException) {
215 static int Main (String[] args) {
216 return TestDriver.RunTests (typeof (Tests), args);