[Mono-devel-list] [GENERICS] implementing static TypeBuilder.GetMethod (Field, Constructor)

Kamil Skalski nazgul at nemerle.org
Fri Jun 3 05:19:00 EDT 2005


Dnia piątek, 3 czerwca 2005 06:57, Martin Baulig napisał:
> On Mon, 2005-05-30 at 14:20 +0200, Michal Moskal wrote:
> > There is a static method in the 2.0 .NET reflection API:
> >
> >   MethodInfo TypeBuilder.GetMethod (System.Type t, MethodInfo m)
> >
> > there is no documentation on msdn, so I'll skip the link.
>
> Hello,
>
> is this method only in TypeBuilder or also in Type ?  I think if it's
> only in TypeBuilder it's not really that useful at all.

This is general purpose static method, but unfortunately it seems to be just a 
hack for MS.NET SRE limitation (not allowing to reflect members from 
TypeBuilder instances):
http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?FeedbackId=7f85f92e-4154-4cb2-8f53-8be324bd6e11

>
> > What it does is take instanciated generic type and a method taken from
> > the non instanciated generic type m. It then returns the same method
> > in t.
>
> We have some unmanaged API in Mono for that, shouldn't be hard exposing
> it through that function.
>
> However, you should also be able to implement this entirely in managed
> code, I'll have a look at this next week and send you some sample code.
>

I just noticed MetadataToken property in MemberInfo
http://msdn2.microsoft.com/library/9x594wbd(en-us,vs.80).aspx
On mono it returns 

MetadataToken is not supported for type 'System.Reflection.MonoGenericCMethod'
in <0x00000> <unknown method>
in (wrapper managed-to-native) System.Reflection.MemberInfo:get_MetadataToken 

but my intuition is that this could be a good way to test if two MemberInfos 
are pointing to the "similar" memeber and do the search effectively.

So another question is if MetadataToken is / will be possible to implement in 
mono and if it will return the same values for the same members, but 
originating in instanciated / non-instanciated versions of types.

Due to MS.NET limitations we will need to implement the TypeBuilder.GetX 
equivalents  - I will check later if MetadataToken is usable in their 
implementation.

-- 
Kamil Skalski
http://nazgul.omega.pl



More information about the Mono-devel-list mailing list