/// <summary> /// Inserts instructions before a target in a method. /// </summary> /// <param name="md">The method.</param> /// <param name="target">The instruction target.</param> /// <param name="instructions">The instructions.</param> public static void InsertBefore(this MethodDefinition md, Instruction target, params Instruction[] instructions) { var ilp = md.Body.GetILProcessor(); ilp.InsertAfter(target, target.Copy()); target.OpCode = OpCodes.Nop; for (int i = instructions.Length - 1; i >= 0; i--) ilp.InsertAfter(target, instructions[i]); if (!shortToLongMethods.Contains(md)) shortToLongMethods.Add(md); }