[Mono-bugs] [Bug 64435][Nor] New - mcs creates custom attribute blobs that differ from .NET/csc

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 29 Aug 2004 02:19: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 mathpup@mylinuxisp.com.

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

--- shadow/64435	2004-08-29 02:19:01.000000000 -0400
+++ shadow/64435.tmp.3904	2004-08-29 02:19:01.000000000 -0400
@@ -0,0 +1,102 @@
+Bug#: 64435
+Product: Mono: Compilers
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mathpup@mylinuxisp.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mcs creates custom attribute blobs that differ from .NET/csc
+
+Description of Problem: 
+ 
+When a custom attribute contains a field (or property) whose type is 
+object[], mcs emits a slightly different blob from csc on .NET (both Rotor 
+and 2.0 Beta). (An object[] would be used when the field should contain an 
+array of boxed valuetypes.) The exact format for this case is not 
+documented in the ECMA spec, which is probably why the output of mcs 
+differs slightly. The documentation that does exist is mostly in Partition 
+II, 22.3, with some metadata information about ELEMENT_TYPE_* in the table 
+of 22.1.15. 
+ 
+If the custom attribute class is declared 
+ 
+[AttributeUsage(AttributeTargets.Class)] 
+public class NewAttribute:Attribute 
+{ 
+ public object[] ArrayOfBoxed; 
+} 
+ 
+and the attribute is specified as 
+ 
+[NewAttribute(ArrayOfBoxed=new object[] {4, 'A', "String"})] 
+ 
+csc emits the blob 
+01 00 01 00 53 1D *51* 0C 41 72 72 61 79 4F 66 42   // ....S.Q.ArrayOfB 
+6F 78 65 64 03 00 00 00 08 04 00 00 00 03 41 00   // oxed..........A. 
+0E 06 53 74 72 69 6E 67                         ) // ..String 
+ 
+mcs emits the blob 
+01 00 01 00 53 1D *1C* 0C 41 72 72 61 79 4F 66 42   // ....S...ArrayOfB 
+6F 78 65 64 03 00 00 00 08 04 00 00 00 03 41 00   // oxed..........A. 
+0E 06 53 74 72 69 6E 67                         ) // ..String 
+ 
+I've placed ** around the byte that differs. Deciphering the blob, 
+ 
+01 00 -- uint16 indicates a custom attribute 
+01 00 -- uint16 1 named argument 
+53    -- the argument is a field 
+1D    -- the argument is an SZARRAY 
+51 with csc, 1C with mcs 
+ 
+mcs actually uses the value from the table that many of the ELEMENT_TYPEs 
+appear in, where ELEMENT_TYPE_OBJECT = 0x1C. However, csc uses the 
+undocumented "tagged object" flag of 0x51. 
+ 
+ 
+Steps to reproduce the problem: 
+1. csc test-field-with-array-of-boxed.cs 
+2. monodis test-field-with-array-of-boxed.exe 
+ 
+ 
+Actual Results: 
+ 
+See above 
+ 
+ 
+Expected Results: 
+ 
+See above 
+ 
+How often does this happen?  
+ 
+Always 
+ 
+Additional Information: 
+ 
+Test program: 
+ 
+using System; 
+ 
+ 
+[AttributeUsage(AttributeTargets.Class)] 
+public class NewAttribute:Attribute 
+{ 
+ public object[] ArrayOfBoxed; 
+} 
+ 
+[NewAttribute(ArrayOfBoxed=new object[] {4, 'A', "String"})] 
+public class Testing 
+{ 
+    public static void Main() 
+    { 
+ } 
+}