public static MethodDefinition TryResolve(this ModuleDefinition scope, MethodReference methodRef)
        {
            var matchingTypeRef = methodRef.DeclaringType.Clone();

            matchingTypeRef.Scope = scope;
            var matchingMethodRef = methodRef.Clone();

            matchingMethodRef.DeclaringType = matchingTypeRef;
            return(scope.MetadataResolver.TryResolve(matchingMethodRef));
        }
Beispiel #2
0
        public static MethodReference MakeGeneric(this MethodReference method, TypeReference declaringType)
        {
            if (!declaringType.IsGenericInstance || method.DeclaringType.IsGenericInstance)
            {
                return(method);
            }

            var genericDeclType = new GenericInstanceType(method.DeclaringType);

            foreach (var argument in ((GenericInstanceType)declaringType).GenericArguments)
            {
                genericDeclType.GenericArguments.Add(argument);
            }

            var result = method.Clone();

            result.DeclaringType = genericDeclType;
            return(result);
        }