InstructionExtensions Class
Definition
Section titled “Definition”Extension methods for Instruction.
public static class InstructionExtensionsInheritance object
Methods
Section titled “Methods”Get(Instruction, out Instruction)
Section titled “Get(Instruction, out Instruction)”Stores an instruction instance into an ‘out’ parameter variable while returning the same instruction instance for convenient use in methods that take instruction instances, e.g.
weaver.InsertBeforeCurrent( w.Create(OpCodes.Ldc_I4_0).Get(out var ldcI40), w.Create(OpCodes.Ret).Get(out var ret));public static Instruction Get(this Instruction source, out Instruction instruction)Parameters
Section titled “Parameters”source Instruction
The instruction instance to get.
instruction Instruction
The got instruction instance.
Returns
Section titled “Returns”Instruction
The same instruction instance.
MarkLabel(Instruction, ILLabel)
Section titled “MarkLabel(Instruction, ILLabel)”Marks an instruction as a target of an MonoMod.Cil.ILLabel while returning the same instruction instance for convenient use in methods that take instruction instances, e.g.
ILLabel label = weaver.DeclareLabel();// ...weaver.InsertBeforeCurrent( w.Create(OpCodes.Ret).MarkLabel(label));public static Instruction MarkLabel(this Instruction instruction, ILLabel label)Parameters
Section titled “Parameters”instruction Instruction
The instruction to mark a label with.
label MonoMod.Cil.ILLabel
The label to be marked.
Returns
Section titled “Returns”Instruction
The same instruction instance.
Clone(Instruction)
Section titled “Clone(Instruction)”Creates and returns a clone of the provided instruction instance. Useful for reusing the same instruction in a method as inserting duplicate instruction instances into a method is problematic, such as breaking the target method compilation in certain cases.
public static Instruction Clone(this Instruction instruction)Parameters
Section titled “Parameters”instruction Instruction
The instruction to clone.
Returns
Section titled “Returns”Instruction
The clone.
ToStringSafe(Instruction)
Section titled “ToStringSafe(Instruction)”Returns a string representation of an Instruction without fear of InvalidCastException.
public static string ToStringSafe(this Instruction instruction)Parameters
Section titled “Parameters”instruction Instruction
Instruction to turn into a string representation.
Returns
Section titled “Returns”string
String representation of an Instruction.