MethodDecorator.Fody.MethodDecorator.ReplaceRetInstructions C# (CSharp) Method

ReplaceRetInstructions() private static method

private static ReplaceRetInstructions ( Mono.Cecil.Cil.ILProcessor processor, Instruction methodEpilogueFirstInstruction ) : void
processor Mono.Cecil.Cil.ILProcessor
methodEpilogueFirstInstruction Mono.Cecil.Cil.Instruction
return void
        private static void ReplaceRetInstructions(ILProcessor processor, Instruction methodEpilogueFirstInstruction)
        {
            // We cannot call ret inside a try/catch block. Replace all ret instructions with
            // an unconditional branch to the start of the OnExit epilogue
            var retInstructions = (from i in processor.Body.Instructions
                                   where i.OpCode == OpCodes.Ret
                                   select i).ToList();

            foreach (var instruction in retInstructions) {
                instruction.OpCode = OpCodes.Br_S;
                instruction.Operand = methodEpilogueFirstInstruction;
            }
        }