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

Michal Moskal michal.moskal at gmail.com
Mon May 30 08:20:10 EDT 2005


Hello,

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.

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.

It is crucial in our compiler -- because we first work on generic
types like List[T], access some members of it x.Length, where we still
do not know the exact type of x (we only know it is a List) and
finally we know that it is List[int], but we have already resolved
get_Length() and have method info for it from List[T].

We now need method info from List[int]. We cannot just do
typeof(List[int]).GetMethod("get_Length"), because it can be
overloaded.

This is needed for type inference.

There are also similar GetField and GetConstructor static methods.

Now the question -- how do I implement this method in mono?

Exactly I would like to know how to compare MethodInfo from List[T]
type and method from List[int], so I can say there are equal. Is
comparing RuntimeMethodHandle going to work?

And how do I compare Fields? (the way for methods will I guess work
also for ctors).

-- 
   Michal Moskal,
   http://nemerle.org/~malekith/



More information about the Mono-devel-list mailing list