public GetILProcessor ( ) : Mono.Cecil.Cil.ILProcessor | ||
return | Mono.Cecil.Cil.ILProcessor |
MethodDefinition methodDefinition = GetTypeDefinition().Methods.Single(x => x.Name == methodName); MethodBody methodBody = methodDefinition.Body; ILProcessor processor = methodBody.GetILProcessor();
MethodBody methodBody = methodDefinition.Body; ILProcessor processor = methodBody.GetILProcessor(); Instruction instruction = processor.Create(OpCodes.Ret); processor.InsertBefore(methodBody.Instructions.Last(), instruction);This code example retrieves the IL processor for a method body, creates a new instruction to return from the method, and inserts it before the last instruction in the method body. Package library: Mono.Cecil.