[Mono-bugs] [Bug 75060][Maj] New - incorrect code is generated for DllImport with ExactSpelling=true

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu May 26 23:50:35 EDT 2005


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 vladimir at pobox.com.

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

--- shadow/75060	2005-05-26 23:50:35.000000000 -0400
+++ shadow/75060.tmp.17544	2005-05-26 23:50:35.000000000 -0400
@@ -0,0 +1,45 @@
+Bug#: 75060
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: C#
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: vladimir at pobox.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: incorrect code is generated for DllImport with ExactSpelling=true
+
+With 1.1.7 and svn, if a p/invoke method is compiled such as:
+
+  [DllImport("foo", ExactSpelling=true)]
+  public static extern void foo (string s);
+
+that method gets output as:
+
+    .method public static  hidebysig  pinvokeimpl ("foo" unicode winapi )
+
+which is wrong -- the charset should be ansi, and there should be a
+nomangle flag there.
+
+What's happening is that the "charset" field of MethodBuilder is being used
+by mcs to pass along some extra flags for PInvokeAttributes as defined in
+the spec.  However, the CharSet enum values are "1 2 3 4" for
+none/ansi/unicode/auto, and the binary spec values are 0x0 0x2 0x4 0x6. 
+The flag for ExactSpelling is 0x1.  So.... mcs passes along 0x2 (Ansi, the
+default) | 0x1 -> 3, which is the enum value for Unicode.  And we all lose.
+
+The attached patches (one for mcs, one for mono) removes the
+passing-of-magic-stuff via charset, and instead extends the same private
+API mechanism used by BestFitMapping and ThrowOnUnmappableChar to
+ExactSpelling and SetLastError.
+
+I'd like to add a test for this, but none of the tests seem to DllImport
+anything -- can't test it without actually executing a DllImport'd function
+or without examining ildasm/monodis output.


More information about the mono-bugs mailing list