[Mono-dev] Mono.Cecil: Full names of generic types

Matej Urbas matej.urbas at gmail.com
Sat Jul 22 07:38:51 EDT 2006


Hi

I'm working on code completion (generics support) in MonoDevelop and I'm 
making extensive use of Mono.Cecil.

I have a few questions about the way Mono.Cecil decorates full names of 
generic types:

1. All generic types have such a string appended to their full name: 
"`#" - where # represents the number of generic parameters. Is this a 
standard way of decorating generic names? If it is, can you point me to 
a document that specifies this? (I need it mostly because I'm 
interested, but I also expect to be using it when extracting undecorated 
names for code completion in monodevelop.)

2. Question about methods that have generic types as parameters: Here is 
an example of such a method:

static T System.Array.FindLast <T> (T[] array, System.Predicate<T> match)

Now, the problem: Parameters are specified in MethodDefinition with a 
collection of ParameterDefinition classes which have TypeReference as 
their type. If we look at the 'match' parameter in the upper method, 
Cecil will store this info in its m_paramType:

Full name of type: System.Predicate`1<T>
GenericParameters: empty!

You see, the GenericParameters collection of the 'match' parameter is 
empty and its full name has the generic parameters already appended 
(i.e.: <T>). Now, in monodevelop I have to extract generic parameters of 
such parameters but it seems like there is no other way but to parse 
them from the 'full name' string... In fact, one can tell that a method 
parameter is generic only if one searches for a &gt; or &lt; character 
in its name... I would really like to see those parameters specified in 
a collection rather than appended to the string. What can I do about it?

3. Oh, and to what extent is Mono.Cecil compatible with 
System.Reflection? E.g.: are the Mono.Cecil.GenericParamAttributes and 
System.Reflection.GenericParameterAttributes cast safe? - I mean, can 
they be cast from one-another and still preserve the expected information?


Hope I'm not annoying.

Thanks in ahead
---
Matej



More information about the Mono-devel-list mailing list