The first thing which needs to be done is getting Type.GetMethods() right wrt. generic instances.
Suppose you have a generic type definition like this:
Now, you want to instantiate Test to Test<int> - and you want to do this in the same assembly. This means that the underlying generic type is actually a TypeBuilder.
We need to consider two things here:
klass->methods, but need to access the tb->methods array on the TypeBuilder instead. We still need to inflate the methods and we should just do this once.
MethodBuilder.
I'm using a small trick to do this: the actual instantiation of a
generic type is done in
mono_reflection_bind_generic_parameters() which is called
from Type.BindGenericParameters(). If the underlying
generic type is a TypeBuilder, we populate
iklass->methods from tb->methods and
tb->ctors.