2004-05-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / tests / test-102.cs
index f72af0f8778c47266ee826d9c0722556b6726c9a..1c82586d3530ec41798fb2201b931603eb123335 100644 (file)
@@ -17,9 +17,19 @@ namespace N1 {
                }
        }
 
-       interface A {
-               [Mine ("hello")]
-               void Hello ();
+        [AttributeUsage (AttributeTargets.ReturnValue)]
+       public class ReturnAttribute : Attribute {
+
+               public string name;
+               
+               public ReturnAttribute (string s)
+               {
+                       name = s;
+               }
+       }
+
+       public interface TestInterface {
+               void Hello ([Mine ("param")] int i);
        }       
 
        public class Foo {      
@@ -27,7 +37,7 @@ namespace N1 {
                int i;
                
                [Mine ("Foo")]
-               [return: Mine ("Bar")]  
+               [return: Return ("Bar")]        
                public static int Main ()
                {
                        Type t = typeof (Foo);
@@ -42,12 +52,12 @@ namespace N1 {
                                                Console.WriteLine ("Got more than one return attribute");
                                                return 1;
                                        }
-                                       if (!(ret_attrs [0] is MineAttribute)){
+                                       if (!(ret_attrs [0] is ReturnAttribute)){
                                                Console.WriteLine ("Dit not get a MineAttribute");
                                                return 2;
                                        }
 
-                                       MineAttribute ma = (MineAttribute) ret_attrs [0];
+                                       ReturnAttribute ma = (ReturnAttribute) ret_attrs [0];
                                        if (ma.name != "Bar"){
                                                Console.WriteLine ("The return attribute is not Bar");
                                                return 2;
@@ -55,6 +65,19 @@ namespace N1 {
                                }
                        }
 
+                        Type ifType = typeof (TestInterface);
+                        
+                        MethodInfo method = ifType.GetMethod ("Hello", 
+                                                              BindingFlags.Public | BindingFlags.Instance);
+                        
+                        ParameterInfo[] parameters = method.GetParameters();
+                        ParameterInfo param = parameters [0];
+                        
+                        object[] testAttrs = param.GetCustomAttributes (true);
+                        
+                        if (testAttrs.Length != 1)
+                                return 1;
+                        
                        return 0;
                }
        }