I am trying to copy a very simple method from one type to another Type
So far I have this
private MethodDefinition CopyMethod(MethodDefinition
templateMethod, TypeDefinition targetType)
{
var newMethod = new
MethodDefinition(templateMethod.Name,
templateMethod.Attributes, templateMethod.ReturnType);
foreach (var parameterDefinition in templateMethod.Parameters)
{
newMethod.Parameters.Add(parameterDefinition);
}
foreach (var instruction in templateMethod.Body.Instructions)
{
newMethod.Body.Instructions.Add(instruction);
}
targetType.Methods.Add(newMethod);
return newMethod;
}
But I am getting a "Invalid Typeref token." when I try to execute the code.
Any pointers?
--
--
mono-cecil