something like this? one of the extensions I mentioned I can give away btw.

        public static TypeReference GetTypeWithGenericResolve(this
ParameterDefinition definition)
        {
            TypeReference ret = definition.ParameterType;
            if (definition.ParameterType.IsGenericParameter)
            {
                var f = (MethodReference) definition.Method;
                if (f.DeclaringType is GenericInstanceType)
                {
                    var position =
                        ((GenericInstanceType)
f.DeclaringType).ElementType.GenericParameters.GetIndexByName(
                            definition.ParameterType.Name);
                    if (position != -1)
                        ret = ((GenericInstanceType)
f.DeclaringType).GenericArguments[position];
                }
                if (f.HasGenericParameters)
                {
                    var position = f.GenericParameters.GetIndexByName(
definition.ParameterType.Name);
                    if (position != -1)
                        ret = f.GenericParameters[position];
                }
            }
            return ret;
        }


On Tue, Nov 30, 2010 at 1:20 PM, Jb Evain <[email protected]> wrote:

> On Tue, Nov 30, 2010 at 7:16 PM, Greg Young <[email protected]>
> wrote:
> > Ah beautiful that's what I was hoping you would say :) Already have code
> > doing that elsewhere, just got confused based on the output in strings as
> I
> > expected it to get replaced with the caller context name.
> > Will go write it now in fact :)
>
> Cool. As a side note, you will need to differentiate the type of the
> generic parameter, as they can be declared by either a method or a
> type. So you have to deal with that when retrieving the argument from
> the generic context.
>
> You also have to deal with typespecs, for instance arrays (T[]), or
> byrefs types (T&).
>
> Jb
>
> --
> --
> mono-cecil




-- 
Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer de
votre attention

-- 
--
mono-cecil

Reply via email to