[WCF] mark JsonReader tests that proves referencesource bugs as [Ignore]d.
[mono-project.git] / mono / tests / custom-attr-errors.cs
blob83f3ff71c297047f73fa0fa50fc1ee9d8e9bced4
1 using System;
2 using System.Reflection;
4 public sealed class MyAttribute : Attribute
6 public Type Type { get; set; }
7 public MyAttribute (Type t) {
8 Type = t;
9 // throw new Exception ();
12 public override string ToString () {
13 return "my " + Type;
17 public sealed class My2Attribute : Attribute
19 public object Obj { get; set; }
20 public My2Attribute (object t) {
21 Obj = t;
22 // throw new Exception ();
25 public override string ToString () {
26 return "my2 " + Obj;
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 ();
44 public class Bar {}
46 class Tests {
48 [My3 (new object[] { DisappearingEnum.V0 })]
49 public static int test_0_missing_enum_arg_alt3 () {
50 try {
51 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
52 return 1;
53 } catch (TypeLoadException) {
54 return 0;
58 [My2 (new DisappearingEnum[] { DisappearingEnum.V0 })]
59 public static int test_0_missing_enum_arg_alt2 () {
60 try {
61 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
62 return 1;
63 } catch (TypeLoadException) {
64 return 0;
68 [My2 (new object[] { DisappearingEnum.V0 })]
69 public static int test_0_missing_enum_arg_alt () {
70 try {
71 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
72 return 1;
73 } catch (TypeLoadException) {
74 return 0;
78 [My2 (DisappearingEnum.V0)]
79 public static int test_0_missing_enum_arg () {
80 try {
81 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
82 return 1;
83 } catch (TypeLoadException) {
84 return 0;
88 [My3 (new object[] { typeof (DisappearingType)})]
89 public static int test_0_array_of_missing_type_alt2 () {
90 try {
91 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
92 return 1;
93 } catch (TypeLoadException) {
94 return 0;
97 [My2 (new Type[] { typeof (DisappearingType)})]
98 public static int test_0_array_of_missing_type () {
99 try {
100 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
101 return 1;
102 } catch (TypeLoadException) {
103 return 0;
109 [My2 (typeof (DisappearingType))]
110 public static int test_0_missing_type_arg_alt () {
111 try {
112 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
113 return 1;
114 } catch (TypeLoadException) {
115 return 0;
119 [My (typeof (DisappearingType))]
120 public static int test_0_missing_type_arg () {
121 try {
122 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
123 return 1;
124 } catch (TypeLoadException) {
125 return 0;
130 [MissingCtor (1)]
131 public static int test_0_missing_ctor () {
132 try {
133 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
134 return 1;
135 } catch (MissingMethodException) {
136 return 0;
140 [BadAttr (Field = 1)]
141 public static int test_0_missing_field () {
142 try {
143 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
144 return 1;
145 } catch (CustomAttributeFormatException) {
146 return 0;
150 [BadAttr (Property = 1)]
151 public static int test_0_missing_property () {
152 try {
153 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
154 return 1;
155 } catch (CustomAttributeFormatException) {
156 return 0;
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 () {
163 try {
164 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
165 return 1;
166 } catch (CustomAttributeFormatException) {
167 return 0;
171 [BadAttr (Property2 = 1)]
172 public static int test_0_bad_property () {
173 try {
174 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
175 return 1;
176 } catch (CustomAttributeFormatException) {
177 return 0;
182 [BadAttr (Property3 = 1)]
183 public static int test_0_bad_property_no_setter () {
184 try {
185 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
186 return 1;
187 } catch (CustomAttributeFormatException) {
188 return 0;
192 [ExceptionOnCtor]
193 public static int test_0_cattr_ctor_throws () {
194 try {
195 MethodBase.GetCurrentMethod ().GetCustomAttributes (false);
196 return 1;
197 } catch (MyException) {
198 return 0;
203 static int Main (String[] args) {
204 return TestDriver.RunTests (typeof (Tests), args);