* ILParser.jay: de-bacwardificate values passed to add method,
[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         public class My2Attribute: MyAttribute {
14                 public int ival;
15                 public My2Attribute (string stuff, int blah) : base (stuff) {
16                         System.Console.WriteLine ("ctor with int val"+stuff);
17                         ival = blah;
18                 }
19         }
20         [My("testclass")]
21         [My2("testclass", 22)]
22         public class Test {
23                 static public int Main() {
24                         System.Reflection.MemberInfo info = typeof (Test);
25                         object[] attributes = info.GetCustomAttributes (false);
26                         for (int i = 0; i < attributes.Length; i ++) {
27                                 System.Console.WriteLine(attributes[i]);
28                         }
29                         if (attributes.Length != 2)
30                                 return 1;
31                         MyAttribute attr = (MyAttribute) attributes [0];
32                         if (attr.val != "testclass")
33                                 return 2;
34                         return 0;
35                 }
36         }
37 }