Class LocatorExtensions

Namespace
AsmLocator
Assembly
AsmLocator.dll

Provides lookup operations directly on AsmResolver objects without creating an AssemblyLocator. For example: typeDef.FindMethod(MethodSpec.ByName("Execute")).

public static class LocatorExtensions
Inheritance
LocatorExtensions
Inherited Members

Methods

FindEvent(TypeDefinition, EventSpec)

Returns the first event declared on this type that satisfies the specification, or null.

public static EventDefinition? FindEvent(this TypeDefinition type, EventSpec spec)

Parameters

type TypeDefinition

The AsmResolver type definition on which the extension method operates.

spec EventSpec

The specification that candidate objects must satisfy.

Returns

EventDefinition

The first match, or null when nothing matches.

FindEvents(TypeDefinition, EventSpec)

Enumerates events declared directly on this type that satisfy the supplied event specification.

public static IEnumerable<EventDefinition> FindEvents(this TypeDefinition type, EventSpec spec)

Parameters

type TypeDefinition

The AsmResolver type definition on which the extension method operates.

spec EventSpec

The specification that candidate objects must satisfy.

Returns

IEnumerable<EventDefinition>

A lazily evaluated sequence of the matching items; empty when nothing matches.

FindField(TypeDefinition, FieldSpec)

Returns the first field declared on this type that satisfies the specification, or null.

public static FieldDefinition? FindField(this TypeDefinition type, FieldSpec spec)

Parameters

type TypeDefinition

The AsmResolver type definition on which the extension method operates.

spec FieldSpec

The specification that candidate objects must satisfy.

Returns

FieldDefinition

The first match, or null when nothing matches.

FindFields(TypeDefinition, FieldSpec)

Enumerates fields declared directly on this type that satisfy the supplied field specification.

public static IEnumerable<FieldDefinition> FindFields(this TypeDefinition type, FieldSpec spec)

Parameters

type TypeDefinition

The AsmResolver type definition on which the extension method operates.

spec FieldSpec

The specification that candidate objects must satisfy.

Returns

IEnumerable<FieldDefinition>

A lazily evaluated sequence of the matching items; empty when nothing matches.

FindInstructions(CilMethodBody, InstructionSpec)

Enumerates matching instructions in this method body and includes each instruction's current index.

public static IEnumerable<InstructionMatch> FindInstructions(this CilMethodBody body, InstructionSpec spec)

Parameters

body CilMethodBody

The CIL method body containing the local variables or instructions to search.

spec InstructionSpec

The specification that candidate objects must satisfy.

Returns

IEnumerable<InstructionMatch>

A lazily evaluated sequence of the matching items; empty when nothing matches.

FindLocals(CilMethodBody, LocalSpec)

Enumerates local variables in this method body that satisfy the supplied local specification.

public static IEnumerable<CilLocalVariable> FindLocals(this CilMethodBody body, LocalSpec spec)

Parameters

body CilMethodBody

The CIL method body containing the local variables or instructions to search.

spec LocalSpec

The specification that candidate objects must satisfy.

Returns

IEnumerable<CilLocalVariable>

A lazily evaluated sequence of the matching items; empty when nothing matches.

FindMethod(TypeDefinition, MethodSpec)

Returns the first method declared on this type that satisfies the specification, or null.

public static MethodDefinition? FindMethod(this TypeDefinition type, MethodSpec spec)

Parameters

type TypeDefinition

The AsmResolver type definition on which the extension method operates.

spec MethodSpec

The specification that candidate objects must satisfy.

Returns

MethodDefinition

The first match, or null when nothing matches.

FindMethods(TypeDefinition, MethodSpec)

Enumerates methods declared directly on this type that satisfy the supplied method specification.

public static IEnumerable<MethodDefinition> FindMethods(this TypeDefinition type, MethodSpec spec)

Parameters

type TypeDefinition

The AsmResolver type definition on which the extension method operates.

spec MethodSpec

The specification that candidate objects must satisfy.

Returns

IEnumerable<MethodDefinition>

A lazily evaluated sequence of the matching items; empty when nothing matches.

FindNestedTypes(TypeDefinition, TypeSpec, bool)

Finds nested types declared directly by this type, optionally including all descendants.

public static IEnumerable<TypeDefinition> FindNestedTypes(this TypeDefinition type, TypeSpec spec, bool recursive = false)

Parameters

type TypeDefinition

The declaring type to search.

spec TypeSpec

The specification that candidate nested types must satisfy.

recursive bool

When true, also searches nested types at every depth.

Returns

IEnumerable<TypeDefinition>

Matching nested type definitions.

FindParameter(MethodDefinition, ParameterSpec)

Returns the first matching parameter, or null when no parameter matches.

public static Parameter? FindParameter(this MethodDefinition method, ParameterSpec spec)

Parameters

method MethodDefinition

The AsmResolver method definition whose parameters are searched.

spec ParameterSpec

The specification that candidate objects must satisfy.

Returns

Parameter

The first match, or null when nothing matches.

FindParameters(MethodDefinition, ParameterSpec)

Enumerates parameters of this method that satisfy the supplied parameter specification.

public static IEnumerable<Parameter> FindParameters(this MethodDefinition method, ParameterSpec spec)

Parameters

method MethodDefinition

The AsmResolver method definition whose parameters are searched.

spec ParameterSpec

The specification that candidate objects must satisfy.

Returns

IEnumerable<Parameter>

A lazily evaluated sequence of the matching items; empty when nothing matches.

FindPattern(CilMethodBody, IReadOnlyList<InstructionSpec>)

Enumerates contiguous instruction sequences that exactly match the supplied ordered pattern.

public static IEnumerable<InstructionSequence> FindPattern(this CilMethodBody body, IReadOnlyList<InstructionSpec> pattern)

Parameters

body CilMethodBody

The CIL method body containing the local variables or instructions to search.

pattern IReadOnlyList<InstructionSpec>

The ordered instruction specifications that form the pattern.

Returns

IEnumerable<InstructionSequence>

A lazily evaluated sequence of the matching items; empty when nothing matches.

FindProperties(TypeDefinition, PropertySpec)

Enumerates properties declared directly on this type that satisfy the supplied property specification.

public static IEnumerable<PropertyDefinition> FindProperties(this TypeDefinition type, PropertySpec spec)

Parameters

type TypeDefinition

The AsmResolver type definition on which the extension method operates.

spec PropertySpec

The specification that candidate objects must satisfy.

Returns

IEnumerable<PropertyDefinition>

A lazily evaluated sequence of the matching items; empty when nothing matches.

FindProperty(TypeDefinition, PropertySpec)

Returns the first property declared on this type that satisfies the specification, or null.

public static PropertyDefinition? FindProperty(this TypeDefinition type, PropertySpec spec)

Parameters

type TypeDefinition

The AsmResolver type definition on which the extension method operates.

spec PropertySpec

The specification that candidate objects must satisfy.

Returns

PropertyDefinition

The first match, or null when nothing matches.

GetAccessor(EventDefinition, EventAccessor)

Returns the requested accessor method for this property or event, or null when that accessor is not defined.

public static MethodDefinition? GetAccessor(this EventDefinition ev, EventAccessor accessor)

Parameters

ev EventDefinition

The event definition whose accessor is requested.

accessor EventAccessor

The property or event accessor to retrieve.

Returns

MethodDefinition

The accessor method, or null when it is not defined.

GetAccessor(PropertyDefinition, PropertyAccessor)

Returns the requested accessor method for this property or event, or null when that accessor is not defined.

public static MethodDefinition? GetAccessor(this PropertyDefinition property, PropertyAccessor accessor)

Parameters

property PropertyDefinition

The property definition whose accessor is requested.

accessor PropertyAccessor

The property or event accessor to retrieve.

Returns

MethodDefinition

The accessor method, or null when it is not defined.