+ 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;
+ }
+ }
+ }
+
+ //
+ // Test that requesting a specific custom attributes does not
+ // create all the others
+ //
+
+ typeof (Y).IsDefined (typeof (ZAttribute), true);
+ typeof (Y).IsDefined (typeof (XAttribute), true);
+
+ typeof (Y).GetCustomAttributes (typeof (ZAttribute), true);
+
+ try {
+ typeof (Y).GetCustomAttributes (true);
+ return 4;
+ }
+ catch {
+ }
+