[Mono-dev] [PATCH] Encoding of the generic type definition.

Rodrigo Kumpera kumpera at gmail.com
Mon Oct 1 11:29:40 EDT 2007


The patch that changed the generic type definition to be the same instance
of the fully open instantiation introduced a small issue in the encoding of
types. This issue is quite subtle and gmcs produces it only on rare

If you use, for example:  ILGenerator::Emit (OpCodes.Callvirt, MethodInfo),
where the method belongs directly to the TypeBuilder, it will generate the
wrong code. This was demonstrated by gtest-203, it generates  "callvirt
instance void class C`2::bar<!2,!3>()" instead of "callvirt   instance void
class C`2<!X,!Y>::bar<!2,!3>()" (notice that C`2 is instantiated here).

The major issue fixing this is regarding how the generic type definition
should be encoded in metadata tables. First, all uses should be replaced by
an explicit instantiation, a typespec token, and  the type itself must be
encoded using a typedef or typeref. To archive that I had to do some big
changes in reflection.c, shifting the typespec tokens from assembly->typedef
cache to assembly->typespec.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071001/319acbaa/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: generics_encode.diff
Type: text/x-patch
Size: 6001 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071001/319acbaa/attachment.bin 

More information about the Mono-devel-list mailing list