Merge pull request #495 from nicolas-raoul/fix-for-issue2907-with-no-formatting-changes
[mono.git] / mcs / tests / test-157.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 interface ITest {
15                 string TestProperty {
16                         [My ("testifaceproperty")] get;
17                 }
18         }
19         
20         [My("testclass")]
21         public class Test {
22                 public static int Main () {
23                         System.Reflection.MemberInfo info = typeof (Test);
24                         object[] attributes = info.GetCustomAttributes (false);
25                         for (int i = 0; i < attributes.Length; i ++) {
26                                 System.Console.WriteLine(attributes[i]);
27                         }
28                         if (attributes.Length != 1)
29                                 return 1;
30                         MyAttribute attr = (MyAttribute) attributes [0];
31                         if (attr.val != "testclass")
32                                 return 2;
33
34                         info = typeof (ITest).GetMethod ("get_TestProperty");
35                         attributes = info.GetCustomAttributes (false);
36                         for (int i = 0; i < attributes.Length; i ++) {
37                                 System.Console.WriteLine(attributes[i]);
38                         }
39                         if (attributes.Length != 1)
40                                 return 3;
41
42                         attr = (MyAttribute) attributes [0];
43                         if (attr.val != "testifaceproperty")
44                                 return 4;
45                         
46                         return 0;
47                 }
48         }
49 }