* Mono.Posix.dll.sources: Rename Mono.Posix to Mono.Unix.
[mono.git] / mono / tests / cattr-object.cs
1 using System;
2
3 [My((long)1)]
4 [My(TypeCode.Empty)]
5 [My(typeof(System.Enum))]
6 class T {
7         static int Main() {
8                 object[] a = Attribute.GetCustomAttributes (typeof (T), false);
9                 if (a.Length != 3)
10                         return 1;
11                 foreach (object o in a) {
12                         My attr = (My)o;
13                         if (attr.obj.GetType () == typeof(long)) {
14                                 long val = (long)attr.obj;
15                                 Console.WriteLine ("got value: {0}", val);
16                                 if (val != 1)
17                                         return 2;
18                         } else if (attr.obj.GetType () == typeof(TypeCode)) {
19                                 int val = (int)attr.obj;
20                                 if (val != (int)TypeCode.Empty)
21                                         return 3;
22                         } else {
23                                 Type t = attr.obj as Type;
24                                 if (t == null)
25                                         return 4;
26                                 if (t != typeof (System.Enum))
27                                         return 5;
28                         }
29                         
30                 }
31                 return 0;
32         }
33 }
34
35 [AttributeUsage(AttributeTargets.All,AllowMultiple=true)]
36 class My : Attribute {
37         public object obj;
38         public My (object o) {
39                 obj = o;
40         }
41 }