February 15, 2006 7:32 pm (permalink)

Making GMCS work on Windows

Today, I did some cleanup of the generics-related reflection APIs to get them in sync with the MS runtime again. The nice side-effect of this is that GMCS is now almost working on Windows except one little issue:

Unfortunately, MethodBuilder doesn't have an API to change the MethodAttributes.

When creating a generic method, we're using the two-argument overload of TypeBuilder.DefineMethod() and then use MethodBuilder.SetSignature() later to specify the parameter and return types. This is neccessary because the parameter and return types may contain type parameters and we only get the type parameters by calling MethodBuilder.DefineGenericParameters() after creating the MethodBuilder.

However, in order to compute the final MethodAttributes, we need to figure out whether we're overriding a base method or implementing an interface method (to set NewSlot if neccessary). But to figure out whether we're implementing an interface method, we need the parameter and return types ...

I already filed a bug report about that, so maybe it'll get fixed in a future version of the .NET Framework.

Posted by martin at February 15, 2006 7:32 pm.