2007-03-28 Chris Toshok <toshok@ximian.com>
[mono-project.git] / mono / tests / cattr-object.cs
blob51db9c5ae58a1c7bc78ba174ac949a83eb27f18c
1 using System;
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;
31 return 0;
35 [AttributeUsage(AttributeTargets.All,AllowMultiple=true)]
36 class My : Attribute {
37 public object obj;
38 public My (object o) {
39 obj = o;