Class PropertySpec

Namespace
AsmLocator
Assembly
AsmLocator.dll

Describes constraints used to match a property definition.

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

Constructors

PropertySpec()

public PropertySpec()

Properties

Attribute

The custom attribute type full-name matcher.

public StringMatcher? Attribute { get; init; }

Property Value

StringMatcher

HasGetter

Whether the property must have a getter.

public bool? HasGetter { get; init; }

Property Value

bool?

HasSetter

Whether the property must have a setter.

public bool? HasSetter { get; init; }

Property Value

bool?

IsStatic

Whether the property accessors are static; the getter is preferred when present, otherwise the setter is inspected.

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

PropertyType

The property type full-name matcher.

public StringMatcher? PropertyType { get; init; }

Property Value

StringMatcher

Where

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

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

Property Value

Func<PropertyDefinition, bool>

Methods

ByName(StringMatcher)

Creates a specification constrained by member name.

public static PropertySpec ByName(StringMatcher name)

Parameters

name StringMatcher

The name matcher for the target member.

Returns

PropertySpec

A new specification with the described constraints.

Equals(PropertySpec?)

public bool Equals(PropertySpec? other)

Parameters

other PropertySpec

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

Matches(PropertyDefinition)

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

public bool Matches(PropertyDefinition property)

Parameters

property PropertyDefinition

The candidate AsmResolver property 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 property type is supplied, also matches its type.

public static PropertySpec Of(StringMatcher name, StringMatcher? propertyType = null)

Parameters

name StringMatcher

The name matcher for the target member.

propertyType StringMatcher

An optional matcher for the property type full name.

Returns

PropertySpec

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 ==(PropertySpec?, PropertySpec?)

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

Parameters

left PropertySpec
right PropertySpec

Returns

bool

implicit operator PropertySpec(string)

Converts a string into a PropertySpec that matches the property name.

public static implicit operator PropertySpec(string name)

Parameters

name string

The name matcher for the target member.

Returns

PropertySpec

The specification created from the supplied string.

operator !=(PropertySpec?, PropertySpec?)

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

Parameters

left PropertySpec
right PropertySpec

Returns

bool