ResolveMethodWithArg reuses the string version

This commit is contained in:
vis2k 2019-01-02 13:18:52 +01:00
parent fb124269f9
commit a33c20c823

View File

@ -58,26 +58,6 @@ public static MethodReference ResolveMethodInParents(TypeReference tr, AssemblyD
return ResolveMethodInParents(tr.Resolve().BaseType, scriptDef, name);
}
public static MethodReference ResolveMethodWithArg(TypeReference tr, AssemblyDefinition scriptDef, string name, TypeReference argType)
{
foreach (MethodDefinition methodRef in tr.Resolve().Methods)
{
if (methodRef.Name == name)
{
if (methodRef.Parameters.Count == 1)
{
if (methodRef.Parameters[0].ParameterType.FullName == argType.FullName)
{
return scriptDef.MainModule.ImportReference(methodRef);
}
}
}
}
Log.Error("ResolveMethodWithArg failed " + tr.Name + "::" + name + " " + argType);
Weaver.fail = true;
return null;
}
// System.Byte[] arguments need a version with a string
public static MethodReference ResolveMethodWithArg(TypeReference tr, AssemblyDefinition scriptDef, string name, string argTypeFullName)
{
@ -98,5 +78,11 @@ public static MethodReference ResolveMethodWithArg(TypeReference tr, AssemblyDef
Weaver.fail = true;
return null;
}
// reuse ResolveMethodWithArg string version
public static MethodReference ResolveMethodWithArg(TypeReference tr, AssemblyDefinition scriptDef, string name, TypeReference argType)
{
return ResolveMethodWithArg(tr, scriptDef, name, argType.FullName);
}
}
}