Class MethodSpec
- Namespace
- AsmLocator
- Assembly
- AsmLocator.dll
Describes constraints used to match a method definition, including its signature and optional body contents.
public sealed record MethodSpec : IEquatable<MethodSpec>
- Inheritance
-
MethodSpec
- Implements
- Inherited Members
Constructors
MethodSpec()
public MethodSpec()
Properties
Attribute
The custom attribute type full-name matcher.
public StringMatcher? Attribute { get; init; }
Property Value
BodyContains
Each instruction specification must match at least one instruction in the body; list order is ignored.
public IReadOnlyList<InstructionSpec>? BodyContains { get; init; }
Property Value
GenericParameterCount
The required number of generic parameters.
public int? GenericParameterCount { get; init; }
Property Value
- int?
HasBody
Whether the method must contain a CIL method body.
public bool? HasBody { get; init; }
Property Value
- bool?
IsAbstract
Whether the method must be abstract.
public bool? IsAbstract { get; init; }
Property Value
- bool?
IsConstructor
Whether the method must be a constructor.
public bool? IsConstructor { get; init; }
Property Value
- bool?
IsPrivate
Whether the candidate must be private.
public bool? IsPrivate { get; init; }
Property Value
- bool?
IsPublic
Whether the candidate must be public.
public bool? IsPublic { get; init; }
Property Value
- bool?
IsSpecialName
Whether the method must be marked specialname. Property and event accessors
(get_X, set_X, add_X, remove_X), operator overloads (op_Implicit)
and constructors carry this flag. Use false to exclude them.
public bool? IsSpecialName { get; init; }
Property Value
- bool?
IsStatic
Whether the candidate must be static.
public bool? IsStatic { get; init; }
Property Value
- bool?
IsVirtual
Whether the method must be virtual.
public bool? IsVirtual { get; init; }
Property Value
- bool?
Locals
Each local specification must match at least one local variable in the method body.
public IReadOnlyList<LocalSpec>? Locals { get; init; }
Property Value
Name
The member name matcher. When null, the name is not used as a constraint.
public StringMatcher? Name { get; init; }
Property Value
ParameterCount
The required number of parameters.
public int? ParameterCount { get; init; }
Property Value
- int?
Parameters
When null, the parameter count and types are unconstrained. When set, the count and order must match exactly.
public IReadOnlyList<ParameterSpec>? Parameters { get; init; }
Property Value
ReturnType
The return type full-name matcher.
public StringMatcher? ReturnType { get; init; }
Property Value
Where
An optional custom predicate applied after the built-in constraints.
public Func<MethodDefinition, bool>? Where { get; init; }
Property Value
Methods
ByName(StringMatcher)
Creates a method specification constrained only by name, without constraining its parameters.
public static MethodSpec ByName(StringMatcher name)
Parameters
nameStringMatcherThe name matcher for the target member.
Returns
- MethodSpec
A new specification with the described constraints.
Constructor(params string[])
Creates a specification for an instance constructor with the supplied parameter types.
public static MethodSpec Constructor(params string[] parameterTypes)
Parameters
parameterTypesstring[]The ordered parameter type full names.
Returns
- MethodSpec
A new specification with the described constraints.
Equals(MethodSpec?)
public bool Equals(MethodSpec? other)
Parameters
otherMethodSpec
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
Matches(MethodDefinition)
Returns whether the supplied candidate satisfies all constraints configured in this specification.
public bool Matches(MethodDefinition method)
Parameters
methodMethodDefinitionThe candidate AsmResolver method definition.
Returns
NoParameters(StringMatcher)
Creates a method specification that requires no parameters.
public static MethodSpec NoParameters(StringMatcher name)
Parameters
nameStringMatcherThe name matcher for the target member.
Returns
- MethodSpec
A new specification with the described constraints.
Of(StringMatcher)
Creates a method specification constrained only by the supplied name.
public static MethodSpec Of(StringMatcher name)
Parameters
nameStringMatcherThe name matcher for the target member.
Returns
- MethodSpec
A new specification with the described constraints.
Of(StringMatcher, params string[])
The resulting specification requires the exact parameter count and order. A * type matcher accepts any parameter type.
public static MethodSpec Of(StringMatcher name, params string[] parameterTypes)
Parameters
nameStringMatcherThe name matcher for the target member.
parameterTypesstring[]The ordered parameter type full names.
Returns
- MethodSpec
A new specification with the described constraints.
StaticConstructor()
Creates a specification for a parameterless static constructor.
public static MethodSpec StaticConstructor()
Returns
- MethodSpec
A new specification with the described constraints.
ToString()
Returns a readable representation of this object.
public override string ToString()
Returns
- string
A readable description.
WithParameters(StringMatcher, params ParameterSpec[])
Creates a method specification using detailed, ordered parameter specifications.
public static MethodSpec WithParameters(StringMatcher name, params ParameterSpec[] parameters)
Parameters
nameStringMatcherThe name matcher for the target member.
parametersParameterSpec[]The ordered parameter specifications.
Returns
- MethodSpec
A new specification with the described constraints.
Operators
operator ==(MethodSpec?, MethodSpec?)
public static bool operator ==(MethodSpec? left, MethodSpec? right)
Parameters
leftMethodSpecrightMethodSpec
Returns
implicit operator MethodSpec(string)
Converts a method name string into a MethodSpec.
public static implicit operator MethodSpec(string name)
Parameters
namestringThe name matcher for the target member.
Returns
- MethodSpec
The specification created from the supplied string.
operator !=(MethodSpec?, MethodSpec?)
public static bool operator !=(MethodSpec? left, MethodSpec? right)
Parameters
leftMethodSpecrightMethodSpec