2005-06-08 Martin Baulig <martin@ximian.com>
[mono.git] / mono / tests / custom-attr.cs
index 4fa114186a935cd011e73e70ef60994841d578b3..7e8d50dd41d7a743a52d2b898e48f0469755f2a0 100644 (file)
@@ -17,8 +17,25 @@ namespace Test {
                        ival = blah;
                }
        }
+
+       public class My3Attribute : Attribute {
+               char[] array_val;
+
+               public char[] Prop {
+                       get {
+                               return array_val;
+                       }
+                       set {
+                               array_val = value;
+                       }
+               }
+
+               public char[] Prop2;
+       }
+                       
        [My("testclass")]
        [My2("testclass", 22)]
+       [My3(Prop = new char [] { 'A', 'B', 'C', 'D' }, Prop2 = new char [] { 'A', 'D' })]
        public class Test {
                static public int Main() {
                        System.Reflection.MemberInfo info = typeof (Test);
@@ -26,11 +43,24 @@ namespace Test {
                        for (int i = 0; i < attributes.Length; i ++) {
                                System.Console.WriteLine(attributes[i]);
                        }
-                       if (attributes.Length != 2)
+                       if (attributes.Length != 3)
                                return 1;
-                       MyAttribute attr = (MyAttribute) attributes [0];
-                       if (attr.val != "testclass")
-                               return 2;
+                       for (int i = 0; i < attributes.Length; ++i) {
+                               if (attributes [i] is MyAttribute) {
+                                       if (((MyAttribute)attributes [i]).val != "testclass")
+                                               return 2;
+                               }
+                               if (attributes [i] is My3Attribute) {
+                                       if (new String (((My3Attribute)attributes [i]).Prop) != "ABCD") {
+                                               Console.WriteLine (new String (((My3Attribute)attributes [i]).Prop));
+                                               return 3;
+                                       }
+                                       if (new String (((My3Attribute)attributes [i]).Prop2) != "AD") {
+                                               Console.WriteLine (new String (((My3Attribute)attributes [i]).Prop2));
+                                               return 4;
+                                       }
+                               }
+                       }
                        return 0;
                }
        }