[Mono-bugs] [Bug 31422][Nor] New - issue with compund typebuilder lookup and comparison

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
28 Sep 2002 10:53:18 -0000


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=31422

--- shadow/31422	Sat Sep 28 06:53:18 2002
+++ shadow/31422.tmp.17734	Sat Sep 28 06:53:18 2002
@@ -0,0 +1,77 @@
+Bug#: 31422
+Product: Mono/MCS
+Version: unspecified
+OS: other
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: lupus@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: issue with compund typebuilder lookup and comparison
+
+The following sample does compile when running mcs on the mono runtime, but
+not when running on the ms runtime. It does compile if you build it in the
+two steps (dll+main). csc compiles it fine in either mode.
+
+// compile with
+// mcs /define:DLL /define:MAIN nested-enum-array.cs
+// or in a separate dll:
+// mcs /define:DLL /target:library /out:nea.dll nested-enum-array.cs
+// mcs /define:MAIN /r:nea.dll nested-enum-array.cs
+#if DLL
+class T {
+        public enum A {
+                ZERO
+        }
+}
+#endif
+#if MAIN
+class X {
+        static void Main () {
+                T.A[] a = new T.A [5];
+        }
+}
+#endif
+
+The issue is that when mcs queries reflection for an array of typebuilders,
+like T.A[] in this case, Reflecion in the ms runtime always returns
+different handlers for the same query, while the mono runtime returns the
+same handle. Since mcs uses a simple comparison to check for type equality,
+it fails when running on windows.
+Here is a test to demostrate the behaviour of reflection:
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+class CGen {
+        public static int Main() {
+                AssemblyBuilder abuilder;
+                ModuleBuilder mbuilder;
+                TypeBuilder tbuilder;
+                AssemblyName an;
+                String name = "tcgen.exe";
+                TypeAttributes attrs = TypeAttributes.Public |
+TypeAttributes.Class;
+                an = new AssemblyName ();
+                an.Name = name;
+                abuilder = AppDomain.CurrentDomain.DefineDynamicAssembly
+(an, AssemblyBu                mbuilder = abuilder.DefineDynamicModule
+(name, name);
+                tbuilder = mbuilder.DefineType ("Test.CodeGen", attrs);
+                Type at1 = mbuilder.GetType ("Test.CodeGen[]");
+                Type at2 = mbuilder.GetType ("Test.CodeGen[]");
+                if (at1 == at2) {
+                        Console.WriteLine ("{0} == {1}", at1, at2);
+                } else {
+                        Console.WriteLine ("{0} != {1}", at1, at2);
+                }
+                return 0;
+        }
+}