Tue Feb 19 20:23:11 CET 2002 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / tests / custom-attr.cs
1
2 using System;
3 using System.Reflection;
4
5 namespace Test {
6         public class MyAttribute: Attribute {
7                 public string val;
8                 public MyAttribute (string stuff) {
9                         System.Console.WriteLine (stuff);
10                         val = stuff;
11                 }
12         }
13         [My("testclass")]
14         public class Test {
15                 static public int Main() {
16                         System.Reflection.MemberInfo info = typeof (Test);
17                         object[] attributes = info.GetCustomAttributes (false);
18                         for (int i = 0; i < attributes.Length; i ++) {
19                                 System.Console.WriteLine(attributes[i]);
20                         }
21                         if (attributes.Length != 1)
22                                 return 1;
23                         MyAttribute attr = (MyAttribute) attributes [0];
24                         if (attr.val != "testclass")
25                                 return 2;
26                         return 0;
27                 }
28         }
29 }