2002-10-23 Tim Coleman (tim@timcoleman.com)
[mono.git] / mcs / tests / test-101.cs
1 using System;
2 using System.Reflection;
3
4 namespace Test {
5         
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         
14         public class My2Attribute: MyAttribute {
15                 public int ival;
16                 public My2Attribute (string stuff, int blah) : base (stuff) {
17                         System.Console.WriteLine ("ctor with int val"+stuff);
18                         ival = blah;
19                 }
20         }
21         
22         [My("testclass")]
23         [My2("testclass", 22)]
24         public class Test {
25                 static public int Main() {
26                         System.Reflection.MemberInfo info = typeof (Test);
27                         object[] attributes = info.GetCustomAttributes (false);
28                         for (int i = 0; i < attributes.Length; i ++) {
29                                 System.Console.WriteLine(attributes[i]);
30                         }
31                         if (attributes.Length != 2)
32                                 return 1;
33                         MyAttribute attr = (MyAttribute) attributes [0];
34                         if (attr.val != "testclass")
35                                 return 2;
36                         return 0;
37                 }
38         }
39 }