so, i'm trying to add an instance method to a class. i tried this, but
it fails on write, because it can't find System.Object.
var asm = AssemblyDefinition.ReadAssembly(p);
foreach (TypeDefinition def in asm.MainModule.Types) {
Debug.Log(def.Name);
if (def.Name == "Sample") {
var t = new TypeReference("System", "Object", null,
null, false);
var m = new MethodDefinition("Start",
MethodAttributes.Public, t);
def.Methods.Add(m);
Debug.Log("added start");
}
}
asm.Write(p);
so, how would i get this to work?
also, how would i get the method to return void instead of an object?
--
--
mono-cecil