Thanks for the bug report.  We've sent this along to the .NET team that
owns Reflection.Emit and they've confirmed these are bugs and are
entering them for tracking.

John

This posting is provided "AS IS" with no warranties, and confers no
rights.


-----Original Message-----
From: Jeroen Frijters [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, June 25, 2002 10:28 PM
To: [EMAIL PROTECTED]
Subject: Reflection.Emit bugs


Hello,

While building my JVM for .NET (http://radio.weblogs.com/0109845/) I ran
into the following CLR bug. When ModuleBuilder.GetType(string) is used
to construct an array type from an unfinished type (as suggested in
ms-help://MS.NETFrameworkSDK/cpref/html/frlrfSystemReflectionEmitTypeBui
lderClassTopic.htm), it returns a different Type instance for each
invocation. Also, GetElementType() doesn't seem to work on these types.

Here is the source:
>>>>>>>>
using System;
using System.Reflection;
using System.Reflection.Emit;

class Bug
{
        public static void Main()
        {
                AssemblyName name = new AssemblyName();
                name.Name = "MyDynamicAssembly";
                AssemblyBuilder assemblyBuilder =
AppDomain.CurrentDomain.DefineDynamicAssembly(name,
AssemblyBuilderAccess.Run);
                ModuleBuilder moduleBuilder =
assemblyBuilder.DefineDynamicModule("MyDynamicModule");

                TypeBuilder lazyType =
moduleBuilder.DefineType("LazyType");

                Type t1 = moduleBuilder.GetType("LazyType[]");
                Type t2 = moduleBuilder.GetType("LazyType[]");
                Console.WriteLine(t1 == t2);
                Console.WriteLine(t1.Equals(t2));

                Type t3 = moduleBuilder.GetType("LazyType[][]");
                Console.WriteLine(t1);
                Console.WriteLine(t3.GetElementType());
                Console.WriteLine(t3.GetElementType() == t1);

                t1 = Type.GetType("System.Object[]");
                t3 = Type.GetType("System.Object[][]");
                Console.WriteLine(t1);
                Console.WriteLine(t3.GetElementType());
                Console.WriteLine(t3.GetElementType() == t1);
        }
}
<<<<<<<<<

Expected output:
True
True
LazyType[]
LazyType[]
True
System.Object[]
System.Object[]
True

Actual output (both on Rotor and the CLR):
False
False
LazyType[]
LazyType[][]
False
System.Object[]
System.Object[]
True

If someone from Microsoft could please confirm, and also forward this to
the CLR team, that would be great.

Regards,
Jeroen

Reply via email to