Hi Joe.
On Thu, Nov 25, 2010 at 7:51 PM, joer <[email protected]> wrote:
> there are many posts regarding generics and generic methods, it would
> really be helpful if there would be an article somewhere on the whole
> story.
Clearly. Still looking for hands here.
> I still do not know what the difference between
> GenericParameter and GernericArguments are and who needs what and when
> under which situations??
The difference between a generic parameter and a generic argument is
the same difference between a parameter and an argument.
Think of the type:
class List`1<T>
If you get the TypeDefinition for it, it will have one
GenericParameter in .GenericParameters : T. That's the only place
where GenericParameters are populated: in definitions.
Everywhere else, generic types have to be instantiated.
Now, if you have:
class Foo`1<U> {
List`1<U> list;
}
Then the type of the list field, List`1<U> will be a
GenericInstanceType, instantiated with one argument, U. U being the
GenericParameter declared on Foo`1.
What I suggest you do, is that you compile using C# what it is you
want to emit with Cecil, and you analyze what Cecil reads from this
assembly. This way you'll know exactly what to emit.
Jb
--
--
mono-cecil