Hm, this seems a bit fragile to me. The name of generic parameters doesn't cross assemblies boundaries. Meaning that if in assembly.dll, you reference List<T>, assembly.dll has no idea that the GenericParameter of List`1 is named T. The convention is that it will be named !0.
It's not an issue if you always resolve references to definitions, but am not sure that's what you're doing. On Thu, Dec 2, 2010 at 9:00 PM, Greg Young <[email protected]> wrote: > ah sure sorry I missed that. > public static class CollectionGenericParameterExtensions > { > public static int GetIndexByName(this Collection<GenericParameter> > collection, string name) > { > for (int i = 0; i < collection.Count; i++) > { > if (collection[i].FullName == name) return i; > } > return -1; > } > } > On Thu, Dec 2, 2010 at 2:55 PM, Jb Evain <[email protected]> wrote: >> >> On Thu, Dec 2, 2010 at 8:53 PM, Greg Young <[email protected]> >> wrote: >> > >> > ((GenericInstanceType)f.DeclaringType).ElementType.GenericParameters.GetIndexByName( >> >> Could you post GetIndexByName too? >> >> -- >> -- >> mono-cecil > > > -- > Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer de > votre attention > > -- > -- > mono-cecil -- -- mono-cecil
