[Mono-bugs] [Bug 74482][Wis] New - mono uses method param type instead of type in the Constant MD table to interpret the constant value

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 7 Apr 2005 05:39:43 -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 radical@gmail.com.

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

--- shadow/74482	2005-04-07 05:39:43.000000000 -0400
+++ shadow/74482.tmp.6793	2005-04-07 05:39:43.000000000 -0400
@@ -0,0 +1,82 @@
+Bug#: 74482
+Product: Mono: Runtime
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: JIT
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: radical@gmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mono uses method param type instead of type in the Constant MD table to interpret the constant value
+
+Attachments:
+i1.il -> testcase
+i1.dll -> compiled on .net
+ref.cs -> a simple program which reflects on an assembly and lists the
+default values for its parameters
+
+Result of running the compiled .dll on .net:
+
+$ ./ref.exe i1.DLL 
+#### Type = abc
+*****Method : GetHashCode
+*****Method : Equals
+*****Method : ToString
+*****Method : foo
+# : ParameterInfo.ParameterType = System.Int32
+o.Type = System.String, o.Value = "hello"
+
+# : ParameterInfo.ParameterType = System.Object
+o.Type = System.Int32, o.Value = "-1"
+
+# : ParameterInfo.ParameterType = System.Int32
+NULL
+
+*****Method : GetType
+
+------------------
+Mono gives:
+
+radical@linux:~> mono ./ref.exe i1.DLL 
+#### Type = abc
+*****Method : foo
+
+** (./ref.exe:5006): WARNING **: type 0x1c should not be in constant table
+# : ParameterInfo.ParameterType = System.Int32
+o.Type = System.Int32, o.Value = "6619240"
+
+# : ParameterInfo.ParameterType = System.Int32
+o.Type = System.Int32, o.Value = "0"
+
+------------------
+
+Basically, if a method is declared like:
+
+void foo ([opt] int32 a, [opt] object b, [opt] int32 c)
+{
+//With default val specified as
+     .param [1] = bytearray (
+        68 00 65 00 6c 00 6c 00 6f 00 )                  // h.e.l.l.o.
+
+        .param [2] = int32(-1)
+        .param [3] = nullref
+
+}
+
+Reflecting on a method parameter's default value, 
+.Net returns type of the actual Constant
+Mono returns type of the method param!
+
+The attached patch fixes that. It should basically use the type defined in
+the Constant MD Table.
+
+Note: Assigning a nullref to a int32 type method param is ok with ilasm AND
+PEVerify.. but obviously trying to use such a method with vbc/mbas will be
+a problem as an int32 can't be NULL!