[Mono-list] mcs bug and Reflection.Emit shortcoming

Jeroen Frijters mono@jeroen.nu
Thu, 13 Jun 2002 15:27:02 +0200


I just wrote some test code on Microsoft's implementation, and their
implementation for Reflection.Emit doesn't use MethodInfo.ReflectedType,
so if you change the behaviour of Mono's Reflection.Emit, you won't be
compatible.

I fear that this, along with the (bigger) issue of lack of module
support pretty much mean that mcs won't run on Microsoft's
implementation. Are there any other issues you're aware of?

Regards,
Jeroen

> -----Original Message-----
> From: mono-list-admin@ximian.com 
> [mailto:mono-list-admin@ximian.com] On Behalf Of Paolo Molaro
> Sent: Thursday, June 13, 2002 12:32
> To: mono-list@ximian.com
> Subject: Re: [Mono-list] mcs bug and Reflection.Emit shortcoming
> 
> 
> On 06/13/02 Jeroen Frijters wrote:
> > And then disassemble usedll.exe, you'll see that ToString calls
> > [mscorlib]System.Object::ToString() instead of
> > [testdll]testdll::ToString() (as csc does). This will cause version
> > problems, if a new version of the dll overrides ToString, 
> it will not be
> > called.
> > 
> > The problem is that, AFAIK, Reflection.Emit doesn't have 
> the ability to
> > create a MethodInfo for an inherited method, but I hope I'm wrong.
> 
> Interesting bug. I added support in the runtime to execute code like
> that (that reference methods in an inherited class instead of in the
> declaring class), but I didn't understand why one would 
> produce such code
> and how until your sample test. I even asked about the issue on the
> DOTNET list but no one replied. Thanks!
> 
> The Reflection API provides support for such cases in this way: if you
> call FindMembers() for the ToString() method starting from the testdll
> type (the base type for type test), you'll get a MethodInfo that has:
> 
> 	DeclaringType: System.Object
> 	ReflectedType: testdll
> 
> So the info is there in the first place. My guess is that mcs sets the
> DeclaredOnly binding flag and loops until it finds the method, so
> ReflectedType is always equal to the DeclaringType. After mcs is fixed
> I'll change our Reflection.Emit code to take into account the
> ReflectedType when emitting the memberref token.
> 
> lupus
> 
> -- 
> -----------------------------------------------------------------
> lupus@debian.org                                     debian/rules
> lupus@ximian.com                             Monkeys do it better
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>