[Mono-bugs] [Bug 41520][Nor] Changed - Fail to compiler constructors in attributes.

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Thu, 1 May 2003 14:29:55 -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 lupus@ximian.com.

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

--- shadow/41520	Thu May  1 13:29:33 2003
+++ shadow/41520.tmp.32144	Thu May  1 14:29:55 2003
@@ -127,6 +127,46 @@
 (Mono.CSharp.EmitContext,object,object,Mono.CSharp.Attributes)
 in <0x00840> 00 Mono.CSharp.TypeContainer:Emit ()
 in <0x004d8> 00 Mono.CSharp.RootContext:EmitCode ()
 in <0x0084b> 00 Mono.CSharp.Driver:MainDriver (string[])
 in <0x00011> 00 Mono.CSharp.Driver:Main (string[])
 
+
+------- Additional Comments From lupus@ximian.com  2003-05-01 14:29 -------
+The null reference is fixed in cvs.
+The issue with RemotingCorba looks like a mcs bug,
+it will crash with the MS runtime, too. The issue is related to
+the CorbaRaises attribute as used in CosNaming.cs:
+CorbaRaises takes a params Type[] argument in the constructor
+and the attribute is used without the new Type[] {...} syntax.
+This makes mcs pass an incorrect array of arguments to the custom
+attribute ctor.
+Basically, it doesn't construct an array, but passes in the arguments
+to the custom attr ctor.
+I added an assert to reflection to check for it, here is the test case
+that triggers it:
+using System;
+using System.Reflection;
+
+[AttributeUsage (AttributeTargets.All)]
+public class MineAttribute : Attribute {
+        public MineAttribute (params Type [] t)
+        {
+                types = t;
+        }
+        public Type[] types;
+}
+
+[Mine(typeof(int), typeof (string), typeof(object[]))]
+public class Foo {
+        public static int Main ()
+        {
+                object[] attrs = typeof (Foo).GetCustomAttributes
+(typeof(MineAttribute), true);
+                MineAttribute ma = (MineAttribute) attrs [0];
+                if (ma.types [0] != typeof (int))
+                        Console.WriteLine ("failed");
+                return 0;
+        }
+}
+
+