2005-09-21 Lluis Sanchez Gual <lluis@novell.com>
[mono.git] / mcs / tests / test-157.cs
index 6f33e0dcfd37e3a77d9bdc50fbb155c2b20a5ed6..32943211e3578051d5040b6eea80386edee6ed90 100644 (file)
@@ -1,12 +1,8 @@
-// cs-20.cs : Cannot find attribute type My (maybe you forgot to set the usage using the AttributeUsage attribute ?).
-// Line : 18
-
 using System;
 using System.Reflection;
 
 namespace Test {
        
-               //[AttributeUsage (AttributeTargets.All)]
        public class MyAttribute: Attribute {
                public string val;
                public MyAttribute (string stuff) {
@@ -14,21 +10,39 @@ namespace Test {
                        val = stuff;
                }
        }
+
+        public interface ITest {
+                string TestProperty {
+                        [My ("testifaceproperty")] get;
+                }
+        }
        
        [My("testclass")]
-
        public class Test {
-               static public int Main() {
+               static public int Main () {
                        System.Reflection.MemberInfo info = typeof (Test);
                        object[] attributes = info.GetCustomAttributes (false);
                        for (int i = 0; i < attributes.Length; i ++) {
                                System.Console.WriteLine(attributes[i]);
                        }
-                       if (attributes.Length != 2)
+                       if (attributes.Length != 1)
                                return 1;
                        MyAttribute attr = (MyAttribute) attributes [0];
                        if (attr.val != "testclass")
                                return 2;
+
+                        info = typeof (ITest).GetMethod ("get_TestProperty");
+                       attributes = info.GetCustomAttributes (false);
+                       for (int i = 0; i < attributes.Length; i ++) {
+                               System.Console.WriteLine(attributes[i]);
+                       }
+                       if (attributes.Length != 1)
+                               return 3;
+
+                        attr = (MyAttribute) attributes [0];
+                       if (attr.val != "testifaceproperty")
+                               return 4;
+                        
                        return 0;
                }
        }