On Fri, Nov 19, 2010 at 5:35 PM, Greg Young <[email protected]> wrote:
> ok I get that but how can I match up the parameter names?

Names don't matter, they don't cross assemblies boundaries. For
instance, in foo.exe:

List<int> list = new List<int>();
list.Add(42);

When you analyze foo.exe, you see method references to
List`1<System.Int32>::Add(!0)

Also, don't confuse the collection .GenericParameters which contains
the declaration of the parameters, and .GenericArguments which
contains the actual arguments of the generic instantiation. In the
case:

List`1<System.Int32>::Add(!0)

The parameter type of the parameter of Add is a GenericParameter that
you can find declared in the ((GenericInstanceType)
method.DeclaringType).ElementType.GenericParameters collection. Then
you can map its argument by position in the ((GenericInstanceType)
method.DeclaringType).GenericArguments collection.

> I have a ParameterType of T
> I figured I would be able to match up T in the GenericArguments of the
> declaring type but they are just indexed (no names).
> How would I match up a Generic Argument?
> On Fri, Nov 19, 2010 at 11:31 AM, Jb Evain <[email protected]> wrote:
>>
>> Hi,
>>
>> You have to take different things into account:
>>
>> *) Where the GenericParameter is defined, on a type or on a method,
>> that's necessary if you want to map a GenericParameter to its
>> corresponding argument.
>> * The position of the GenericParameter, that gives you the position
>> of the corresponding argument.
>>
>>
>> On Fri, Nov 19, 2010 at 5:25 PM, Greg Young <[email protected]>
>> wrote:
>> > I have a method reference:
>> > {System.Void TestProject.IFoo`1<System.Int32>::Foo(T)}
>> > I can't seem to figure out how to tie the T to System.Int32 I can get
>> > the
>> > generic arguments off the declaring type but I have a name (T) and they
>> > don't seem to have this info on them? eg:
>> > ((GenericInstanceType) m1.DeclaringType).GenericArguments
>> > In the parameter type I see a position which seems like it may be an
>> > index
>> > back into the generic arguments. Is this correct?
>> > Greg
>> >
>> > --
>> > Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer
>> > de
>> > votre attention
>> >
>> > --
>> > --
>> > mono-cecil
>>
>> --
>> --
>> mono-cecil
>
>
> --
> Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer de
> votre attention
>
> --
> --
> mono-cecil

-- 
--
mono-cecil

Reply via email to