Hi! When you do operations on a method body, Cecil will maintain the dual linked list of instructions. See:
When you do a Replace, we're inserting the new instruction and removing the target instruction: https://github.com/jbevain/cecil/blob/master/Mono.Cecil.Cil/ILProcessor.cs#L258 When removed from the instructions, the dual linked list is fixed: https://github.com/jbevain/cecil/blob/master/Mono.Cecil.Cil/MethodBody.cs#L227 As a result, you can't access the Next instruction of an instruction which has been removed. You can however simply implement it as follows: var newInstruction = Instruction.Create(...); il.Replace(targetInstruction, newInstruction); il.InsertAfter(newInstruction, ...); il.InsertAfter(newInstruction.Next, ...); Jb -- -- -- mono-cecil --- You received this message because you are subscribed to the Google Groups "mono-cecil" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
