// Creates a new method but keeps declaring type as is
        public static IMethodDefOrRef create(IMethodDefOrRef method, IList <TypeSig> genericArgs, IList <TypeSig> genericMethodArgs)
        {
            if (method == null)
            {
                return(method);
            }
            if ((genericArgs == null || genericArgs.Count == 0) && (genericMethodArgs == null || genericMethodArgs.Count == 0))
            {
                return(method);
            }

            var sig = method.MethodSig;

            if (sig == null)
            {
                return(method);
            }

            var newSig = new GenericArgsSubstitutor(genericArgs, genericMethodArgs).create(sig);

            if (newSig == sig)
            {
                return(method);
            }

            return(new MemberRefUser(method.DeclaringType.Module, method.Name, newSig, method.DeclaringType));
        }
示例#2
0
        public static TypeSig GetGenericArgument(GenericInstSig typeOwner, MethodSpec methodOwner, TypeSig type)
        {
            var typeArgs      = typeOwner == null ? null : typeOwner.GenericArguments;
            var genMethodArgs = methodOwner == null || methodOwner.GenericInstMethodSig == null ?
                                null : methodOwner.GenericInstMethodSig.GenericArguments;

            return(GenericArgsSubstitutor.Create(type, typeArgs, genMethodArgs));
        }
		// Creates a new method but keeps declaring type as is
		public static IMethodDefOrRef Create(IMethodDefOrRef method, IList<TypeSig> genericArgs, IList<TypeSig> genericMethodArgs) {
			if (method == null)
				return method;
			if ((genericArgs == null || genericArgs.Count == 0) && (genericMethodArgs == null || genericMethodArgs.Count == 0))
				return method;

			var sig = method.MethodSig;
			if (sig == null)
				return method;

			var newSig = new GenericArgsSubstitutor(genericArgs, genericMethodArgs).Create(sig);
			if (newSig == sig)
				return method;

			return new MemberRefUser(method.DeclaringType.Module, method.Name, newSig, method.DeclaringType);
		}