* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / tests / test-128.cs
1 using System;
2 using System.Reflection;
3
4 public class SimpleAttribute : Attribute {
5
6         string n;
7         
8         public SimpleAttribute (string name)
9         {
10                 n = name;
11         }
12 }
13
14 [AttributeUsage (AttributeTargets.All)]
15 public class MineAttribute : Attribute {
16         public MineAttribute (params Type [] t)
17         {
18                 types = t;
19         }
20         public Type[] types;
21 }
22
23 [Mine(typeof(int), typeof (string), typeof(object[]))]
24 public class Foo {
25         public static int MM ()
26         {
27                 object[] attrs = typeof (Foo).GetCustomAttributes (typeof(MineAttribute), true);
28                 MineAttribute ma = (MineAttribute) attrs [0];
29                 if (ma.types [0] != typeof (int)){
30                         Console.WriteLine ("failed");
31                         return 1;
32                 }
33                 if (ma.types [1] != typeof (string)){
34                         Console.WriteLine ("failed");
35                         return 2;
36                 }
37                 if (ma.types [2] != typeof (object [])){
38                         Console.WriteLine ("failed");
39                         return 3;
40                 }
41                 Console.WriteLine ("OK");
42                 return 0;
43         }
44 }
45
46 public class Blah {
47
48         int i;
49
50         public int Value {
51
52                 [Simple ("Foo!")]
53                 get {
54                         return i;
55                 }
56
57                 [Simple ("Bar !")]
58                 set {
59                         i = value;
60                 }
61         }
62
63         [Simple ((string) null)]
64         int Another ()
65         {
66                 return 1;
67         }
68         
69         public static int Main ()
70         {
71                 //
72                 // We need a better test which does reflection to check if the
73                 // attributes have actually been applied etc.
74                 //
75
76                 return Foo.MM ();
77         }
78
79 }