Class FieldSpec

Namespace
AsmLocator
Assembly
AsmLocator.dll

Describes constraints used to match a field definition.

public sealed record FieldSpec : IEquatable<FieldSpec>
Inheritance
FieldSpec
Implements
Inherited Members

Constructors

FieldSpec()

public FieldSpec()

Properties

Attribute

The custom attribute type full-name matcher.

public StringMatcher? Attribute { get; init; }

Property Value

StringMatcher

FieldType

The field type full-name matcher.

public StringMatcher? FieldType { get; init; }

Property Value

StringMatcher

IsInitOnly

Whether the field must be init-only (readonly).

public bool? IsInitOnly { get; init; }

Property Value

bool?

IsLiteral

Whether the field must be a literal constant.

public bool? IsLiteral { 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?

IsStatic

Whether the candidate must be static.

public bool? IsStatic { get; init; }

Property Value

bool?

Name

The member name matcher. When null, the name is not used as a constraint.

public StringMatcher? Name { get; init; }

Property Value

StringMatcher

Where

An optional custom predicate applied after the built-in constraints.

public Func<FieldDefinition, bool>? Where { get; init; }

Property Value

Func<FieldDefinition, bool>

Methods

ByName(StringMatcher)

Creates a specification constrained by member name.

public static FieldSpec ByName(StringMatcher name)

Parameters

name StringMatcher

The name matcher for the target member.

Returns

FieldSpec

A new specification with the described constraints.

Equals(FieldSpec?)

public bool Equals(FieldSpec? other)

Parameters

other FieldSpec

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

Matches(FieldDefinition)

Returns whether the supplied candidate satisfies all constraints configured in this specification.

public bool Matches(FieldDefinition field)

Parameters

field FieldDefinition

The candidate AsmResolver field definition.

Returns

bool

true if every configured constraint is satisfied; otherwise false.

Of(StringMatcher, StringMatcher?)

When only a name is supplied, matches by name; when a type is supplied, also matches the field type.

public static FieldSpec Of(StringMatcher name, StringMatcher? fieldType = null)

Parameters

name StringMatcher

The name matcher for the target member.

fieldType StringMatcher

An optional matcher for the field type full name.

Returns

FieldSpec

A new specification with the described constraints.

ToString()

Returns a readable representation of this object.

public override string ToString()

Returns

string

A readable description.

Operators

operator ==(FieldSpec?, FieldSpec?)

public static bool operator ==(FieldSpec? left, FieldSpec? right)

Parameters

left FieldSpec
right FieldSpec

Returns

bool

implicit operator FieldSpec(string)

Converts a string into a FieldSpec that matches the field name.

public static implicit operator FieldSpec(string name)

Parameters

name string

The name matcher for the target member.

Returns

FieldSpec

The specification created from the supplied string.

operator !=(FieldSpec?, FieldSpec?)

public static bool operator !=(FieldSpec? left, FieldSpec? right)

Parameters

left FieldSpec
right FieldSpec

Returns

bool