public MemberResolver(TypeReference target, ModuleDefinition targetModule = null) { if (target == null) throw new ArgumentNullException("target"); Target = target; Module = targetModule ?? Target.Module; Source = Target.Resolve(); TargetWithArguments = Target as GenericInstanceType; _map = new GenericParametersMap(Source, TargetWithArguments); }
public MethodDefinition ResolveMethodDefinition(MethodDefinition sourceMethod, string name, MethodAttributes methodAttributes) { if (sourceMethod == null) throw new ArgumentNullException("sourceMethod"); bool createdMap = false; if (sourceMethod.HasGenericParameters) { createdMap = true; _map = new GenericParametersMap(sourceMethod) { Next = _map }; } var returnType = ResolveConstituentType(sourceMethod.ReturnType); var targetMethod = new MethodDefinition( name, methodAttributes, returnType); targetMethod.SemanticsAttributes = sourceMethod.SemanticsAttributes; ResolveGenericParameters(sourceMethod, targetMethod); ResolveParameters(sourceMethod, targetMethod); if (createdMap) { _map = _map.Next; } return targetMethod; }