Skip to content

IInformationalInstruction Interface

A Mono.Cecil Instruction wrapper which contains extra information about the instruction for analysis.

C#
public interface IInformationalInstruction

Incoming branches to this instruction.

C#
HashSet<IInformationalInstruction> IncomingBranches { get; }

The immediate previous instruction in the list or an incoming branch if control flow stops at the immediate previous instruction.

C#
IInformationalInstruction? PreviousChronological { get; }

In a case where there are multiple incoming branches, this will point to the first evaluated incoming branch.
If you care about finding a previous incoming invalid stack size somewhere, this will work fine.

In a case where an incoming invalid stack size exists on a branch other than what is found via backtracking with this, it’s not a problem because the error in that case is stack size mismatch which is evaluated during the CIL instruction crawling phase. And in such a case we do NOT evaluate further errors after that point because the whole stack after that point is invalid and any stack size related error would be misleading.

The immediate instruction before this instruction.

C#
IInformationalInstruction? Previous { get; }

The previous instruction may be unreachable, in which case any of its informational data not evaluated. If you want to get the “real” previous instruction, use PreviousChronological.

The immediate instruction after this instruction.

C#
[SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "I don't care about Visual Basic.")]
IInformationalInstruction? Next { get; }

The Mono.Cecil Instruction wrapped by this IInformationalInstruction.

C#
Instruction Instruction { get; }

The calculated stack size at the end of this instruction.

C#
int StackSize { get; }

The stack size before we got to this instruction.

C#
int IncomingStackSize { get; }

The total change to the stack size done by this instruction. Calculated by summing up StackPop and StackPush.

C#
int StackDelta { get; }

The pop behavior of this instruction.

C#
int StackPop { get; }

The push behavior of this instruction.

C#
int StackPush { get; }

The minimum relative distance from the first instruction in the method body, taking branching into account.

C#
int RelativeDistance { get; }

Exception handlers are exceptional, which is why this distance has to be relative.

If this instruction can be reached through following the control flow of the instructions. Instructions after conditional branches are always evaluated and considered reachable.

C#
bool IsReachable { get; }

If this instruction was evaluated after it was created. This is the same as IsReachable when unreachable instructions aren’t evaluated such as when using CreateInformationalSnapshotJIT(MethodBody)

C#
bool IsEvaluated { get; }

A list of error annotations on this instruction.

C#
List<IInformationalInstruction.IAnnotation> ErrorAnnotations { get; }

Whether or not this instruction has any error annotations.

C#
bool HasErrorAnnotations { get; }

Exception handler information related to this instruction.

C#
ReadOnlyCollection<IInformationalInstruction.IHandlerInfo> HandlerInfos { get; }

Collects all incoming instructions, excluding this IInformationalInstruction.

C#
HashSet<IInformationalInstruction> CollectIncoming()

HashSet<IInformationalInstruction>
All incoming instructions.

Returns a string presentation of this IInformationalInstruction.

C#
string ToString()

string

Returns a string presentation of this IInformationalInstruction, including error annotations.

C#
string ToStringWithAnnotations()

string