cleol
[mcs.git] / tests / test-128.cs
blob5c9e275014ac80d44cbb1a99ad9043925c9cce15
1 using System;
2 using System.Reflection;
4 public class SimpleAttribute : Attribute {
6 string n;
8 public SimpleAttribute (string name)
10 n = name;
14 [AttributeUsage (AttributeTargets.All)]
15 public class MineAttribute : Attribute {
16 public MineAttribute (params Type [] t)
18 types = t;
20 public Type[] types;
23 [Mine(typeof(int), typeof (string), typeof(object[]))]
24 public class Foo {
25 public static int MM ()
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;
33 if (ma.types [1] != typeof (string)){
34 Console.WriteLine ("failed");
35 return 2;
37 if (ma.types [2] != typeof (object [])){
38 Console.WriteLine ("failed");
39 return 3;
41 Console.WriteLine ("OK");
42 return 0;
46 public class Blah {
48 int i;
50 public int Value {
52 [Simple ("Foo!")]
53 get {
54 return i;
57 [Simple ("Bar !")]
58 set {
59 i = value;
63 [Simple ((string) null)]
64 int Another ()
66 return 1;
69 public static int Main ()
72 // We need a better test which does reflection to check if the
73 // attributes have actually been applied etc.
76 return Foo.MM ();