Class TypeSpec

Namespace
AsmLocator
Assembly
AsmLocator.dll

Describes constraints used to match a type definition.

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

Constructors

TypeSpec()

public TypeSpec()

Properties

Attribute

The full name matcher for a custom attribute type.

public StringMatcher? Attribute { get; init; }

Property Value

StringMatcher

BaseType

The base type full-name matcher.

public StringMatcher? BaseType { get; init; }

Property Value

StringMatcher

DeclaringType

The specification of the declaring type for nested-type matching.

public TypeSpec? DeclaringType { get; init; }

Property Value

TypeSpec

FullName

Nested type full names use the plus sign separator, for example Example.Outer+Inner.

public StringMatcher? FullName { get; init; }

Property Value

StringMatcher

GenericParameterCount

The required number of generic parameters.

public int? GenericParameterCount { get; init; }

Property Value

int?

Interfaces

The candidate type must implement every interface listed here.

public IReadOnlyList<StringMatcher>? Interfaces { get; init; }

Property Value

IReadOnlyList<StringMatcher>

IsAbstract

Whether the type must be abstract.

public bool? IsAbstract { get; init; }

Property Value

bool?

IsEnum

Whether the candidate must be an enum.

public bool? IsEnum { get; init; }

Property Value

bool?

IsInterface

Whether the candidate must be an interface.

public bool? IsInterface { get; init; }

Property Value

bool?

IsNested

Whether the candidate must be a nested type.

public bool? IsNested { get; init; }

Property Value

bool?

IsSealed

Whether the candidate must be sealed.

public bool? IsSealed { get; init; }

Property Value

bool?

IsValueType

Whether the candidate must be a value type.

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

Namespace

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

public StringMatcher? Namespace { get; init; }

Property Value

StringMatcher

Where

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

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

Property Value

Func<TypeDefinition, bool>

Methods

ByFullName(StringMatcher)

Creates a type specification constrained by full name.

public static TypeSpec ByFullName(StringMatcher fullName)

Parameters

fullName StringMatcher

The type full-name matcher.

Returns

TypeSpec

A new specification with the described constraints.

ByName(StringMatcher)

Creates a specification constrained by member name.

public static TypeSpec ByName(StringMatcher name)

Parameters

name StringMatcher

The type name matcher.

Returns

TypeSpec

A new specification with the described constraints.

Equals(TypeSpec?)

public bool Equals(TypeSpec? other)

Parameters

other TypeSpec

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

Matches(TypeDefinition)

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

public bool Matches(TypeDefinition type)

Parameters

type TypeDefinition

The candidate AsmResolver type definition.

Returns

bool

true if every configured constraint is satisfied; otherwise false.

NestedIn(TypeSpec, StringMatcher)

Creates a specification for a nested type with the supplied declaring type and nested type name.

public static TypeSpec NestedIn(TypeSpec outer, StringMatcher name)

Parameters

outer TypeSpec

The specification of the declaring type.

name StringMatcher

The type name matcher.

Returns

TypeSpec

A new specification with the described constraints.

Of(StringMatcher, StringMatcher)

Creates a type specification constrained by namespace and type name.

public static TypeSpec Of(StringMatcher @namespace, StringMatcher name)

Parameters

namespace StringMatcher

The namespace matcher.

name StringMatcher

The type name matcher.

Returns

TypeSpec

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

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

Parameters

left TypeSpec
right TypeSpec

Returns

bool

implicit operator TypeSpec(string)

Converts a full type name string into a TypeSpec.

public static implicit operator TypeSpec(string fullName)

Parameters

fullName string

The type full-name matcher.

Returns

TypeSpec

The specification created from the supplied string.

operator !=(TypeSpec?, TypeSpec?)

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

Parameters

left TypeSpec
right TypeSpec

Returns

bool