I'm writing an IL static analysis tool, and I'm having a hard time understanding the rules governing how generic type parameters are referenced:

take this IL (from the IList<T> interface):

.property instance !T Item(
    int32 index
)
{
    .get instance !0 System.Collections.Generic.IList`1::get_Item(int32)
    .set instance void System.Collections.Generic.IList`1::set_Item(int32, !0)
}

Why is the !0 there instead of !T? I presume they're equivalent as far as the VM goes, it just seems odd to use positional references at all when you're guaranteed to have the names.

Update: an additional case, from KeyedCollection.ctor:

IL_0037:  newobj instance void class System.Collections.Generic.Dictionary`2<!TKey,!TItem>::'.ctor'(class System.Collections.Generic.IEqualityComparer`1<!0>)
IL_003c:  stfld class System.Collections.Generic.Dictionary`2<!0,!1> class System.Collections.ObjectModel.KeyedCollection`2<!0,!1>::dictionary
Edit
Report