stubs added
[mono.git] / mcs / tests / test-102.cs
1 using System;
2 using System.Reflection;
3
4 [assembly: AssemblyTitle ("Foo")]
5 [assembly: AssemblyVersion ("1.0.2")]
6
7 namespace N1 {
8                 
9         [AttributeUsage (AttributeTargets.All)]
10         public class MineAttribute : Attribute {
11
12                 public string name;
13                 
14                 public MineAttribute (string s)
15                 {
16                         name = s;
17                 }
18         }
19
20         interface A {
21                 [Mine ("hello")]
22                 void Hello ();
23         }       
24
25         public class Foo {      
26                 
27                 int i;
28                 
29                 [Mine ("Foo")]
30                 [return: Mine ("Bar")]  
31                 public static int Main ()
32                 {
33                         Type t = typeof (Foo);
34                         foreach (MemberInfo m in t.GetMembers ()){
35                                 if (m.Name == "Main"){
36                                         MethodInfo mb = (MethodInfo) m;
37
38                                         ICustomAttributeProvider p = mb.ReturnTypeCustomAttributes;
39                                         object [] ret_attrs = p.GetCustomAttributes (false);
40
41                                         if (ret_attrs.Length != 1){
42                                                 Console.WriteLine ("Got more than one return attribute");
43                                                 return 1;
44                                         }
45                                         if (!(ret_attrs [0] is MineAttribute)){
46                                                 Console.WriteLine ("Dit not get a MineAttribute");
47                                                 return 2;
48                                         }
49
50                                         MineAttribute ma = (MineAttribute) ret_attrs [0];
51                                         if (ma.name != "Bar"){
52                                                 Console.WriteLine ("The return attribute is not Bar");
53                                                 return 2;
54                                         }
55                                 }
56                         }
57
58                         return 0;
59                 }
60         }
61 }