[Mono-bugs] [Bug 28562][Nor] Changed - type info lost with enum arguments to a custom attr that takes an object

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 22 Sep 2004 09:12:01 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by martin@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=28562

--- shadow/28562	2004-09-22 08:31:23.000000000 -0400
+++ shadow/28562.tmp.11594	2004-09-22 09:12:01.000000000 -0400
@@ -162,6 +162,54 @@
 to fix it.  If it ever comes back to me, I'll WONTFIX it.
 
 ------- Additional Comments From marek.safar@seznam.cz  2004-09-21 13:16 -------
 Created an attachment (id=11071)
 Test fix
 
+
+------- Additional Comments From martin@ximian.com  2004-09-22 09:12 -------
+Isn't the following the correct test case ?
+
+====
+using System;
+
+[My((long)1)]
+[My(TypeCode.Empty)]
+[My(typeof(System.Enum))]
+class T {
+        static int Main() {
+                object[] a = Attribute.GetCustomAttributes (typeof
+(T), false);
+                if (a.Length != 3)
+                        return 1;
+                foreach (object o in a) {
+                        My attr = (My)o;
+                        if (attr.obj.GetType () == typeof (long)) {
+                                long val = (long) attr.obj;
+                                if (val != 1)
+                                        return 2;
+                        } else if (attr.obj.GetType () == typeof
+(TypeCode)) {
+                                TypeCode val = (TypeCode) attr.obj;
+                                if (val != TypeCode.Empty)
+                                        return 3;
+                        } else if (attr.obj.GetType ().IsSubclassOf
+(typeof (Type))) {
+                                Type val = (Type) attr.obj;
+                                if (val != typeof (System.Enum))
+                                        return 4;
+                        } else
+                                return 5;
+
+                }
+                return 0;
+        }
+}
+
+[AttributeUsage(AttributeTargets.All,AllowMultiple=true)]
+class My : Attribute {
+        public object obj;
+        public My (object o) {
+                obj = o;
+        }
+}
+====