Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / cattr-object.cs
1 using System;
2 using System.Collections.Generic;
3
4 [My((long)1)]
5 [My(TypeCode.Empty)]
6 [My(typeof(System.Enum))]
7 [My(new Type[] { typeof(IEnumerable<string>), typeof(IList<string>) })]
8 class T {
9         static int Main() {
10                 object[] a = Attribute.GetCustomAttributes (typeof (T), false);
11                 if (a.Length != 4)
12                         return 1;
13                 foreach (object o in a) {
14                         My attr = (My)o;
15                         if (attr.obj.GetType () == typeof(long)) {
16                                 long val = (long)attr.obj;
17                                 if (val != 1)
18                                         return 2;
19                         } else if (attr.obj.GetType () == typeof(TypeCode)) {
20                                 int val = (int)attr.obj;
21                                 if (val != (int)TypeCode.Empty)
22                                         return 3;
23                         } else if (attr.obj.GetType () == typeof(Type[])) {
24                                 Type[] arr = (Type[])attr.obj;
25
26                                 if (arr [0] != typeof (IEnumerable<string>))
27                                         return 6;
28                                 if (arr [1] != typeof (IList<string>))
29                                         return 7;
30                         } else {
31                                 Type t = attr.obj as Type;
32                                 if (t == null)
33                                         return 4;
34                                 if (t != typeof (System.Enum))
35                                         return 5;
36                         }
37                         
38                 }
39                 return 0;
40         }
41 }
42
43 [AttributeUsage(AttributeTargets.All,AllowMultiple=true)]
44 class My : Attribute {
45         public object obj;
46         public My (object o) {
47                 obj = o;
48         }
49 }