Table of Contents

Class TypeSpecification

Namespace
AsmResolver.DotNet
Assembly
AsmResolver.DotNet.dll

Represents a type that allows for assigning metadata tokens to type signatures stored in the blob stream.

public class TypeSpecification : MetadataMember, ITypeDefOrRef, ITypeDescriptor, IMemberDescriptor, IFullNameProvider, IMemberRefParent, INameProvider, IModuleProvider, IImportable, IHasCustomAttribute, IMetadataMember
Inheritance
TypeSpecification
Implements
Derived
Inherited Members
Extension Methods

Constructors

TypeSpecification(TypeSignature?)

Creates a new type specification.

public TypeSpecification(TypeSignature? signature)

Parameters

signature TypeSignature

The type signature to assign a metadata token.

TypeSpecification(MetadataToken)

Initializes an empty type specification.

protected TypeSpecification(MetadataToken token)

Parameters

token MetadataToken

The token of the type specification.

Fields

CustomAttributesInternal

The internal custom attribute list.

protected IList<CustomAttribute>? CustomAttributesInternal

Field Value

IList<CustomAttribute>

Remarks

This value may not be initialized. Use CustomAttributes instead.

Properties

ContextModule

Gets the module that defines the member definition or reference.

public ModuleDefinition? ContextModule { get; }

Property Value

ModuleDefinition

Remarks

For member references, this does not obtain the module definition that the member is defined in. Rather, it obtains the module definition that references this reference.

CustomAttributes

Gets a collection of custom attributes assigned to this member.

public IList<CustomAttribute> CustomAttributes { get; }

Property Value

IList<CustomAttribute>

DeclaringType

When this type is nested, gets the enclosing type.

public ITypeDefOrRef? DeclaringType { get; }

Property Value

ITypeDefOrRef

FullName

Gets the full name of the object.

public string FullName { get; }

Property Value

string

HasCustomAttributes

Gets a value indicating whether the member is assigned custom attributes.

public virtual bool HasCustomAttributes { get; }

Property Value

bool

IsValueType

public bool IsValueType { get; }

Property Value

bool

Name

Gets or sets the name of the referenced type.

public Utf8String Name { get; }

Property Value

Utf8String

Namespace

Gets or sets the namespace the type is residing in.

public Utf8String? Namespace { get; }

Property Value

Utf8String

Scope

Gets the resolution scope that defines the type.

public IResolutionScope? Scope { get; }

Property Value

IResolutionScope

Signature

Gets or sets the type signature that this type specification is referencing.

public TypeSignature? Signature { get; set; }

Property Value

TypeSignature

Methods

GetCustomAttributes()

Obtains the list of custom attributes assigned to the member.

protected virtual IList<CustomAttribute> GetCustomAttributes()

Returns

IList<CustomAttribute>

The attributes

Remarks

This method is called upon initialization of the CustomAttributes property.

GetSignature()

Obtains the signature the type specification is referencing.

protected virtual TypeSignature? GetSignature()

Returns

TypeSignature

The signature.

Remarks

This method is called upon initialization of the Signature property.

ImportWith(ReferenceImporter)

Imports the type specification using the provided reference importer object.

public ITypeDefOrRef ImportWith(ReferenceImporter importer)

Parameters

importer ReferenceImporter

The reference importer to use.

Returns

ITypeDefOrRef

The imported type.

IsImportedInModule(ModuleDefinition)

Determines whether the descriptor of the member is fully imported in the provided module.

public bool IsImportedInModule(ModuleDefinition module)

Parameters

module ModuleDefinition

The module that is supposed to import the member.

Returns

bool

true if the descriptor of the member is fully imported by the module, false otherwise.

Remarks

This method verifies all references in the descriptor of the member only. It does not verify any additional data or contents (such as a method body) associated to the member.

Resolve(RuntimeContext?, out TypeDefinition?)

Attempts to resolve the type reference to its definition, assuming the provided module as resolution context.

public ResolutionStatus Resolve(RuntimeContext? context, out TypeDefinition? definition)

Parameters

context RuntimeContext

The context to assume when resolving the type.

definition TypeDefinition

The resolved type definition, or null if the type could not be resolved.

Returns

ResolutionStatus

A value describing the success or failure status of the type resolution.

ToString()

public override string ToString()

Returns

string

ToTypeSignature()

Gets the underlying type signature.

public TypeSignature ToTypeSignature()

Returns

TypeSignature

The type signature.

ToTypeSignature(bool)

Transforms the type descriptor to an instance of a TypeSignature, which can be used in blob signatures.

public TypeSignature ToTypeSignature(bool isValueType)

Parameters

isValueType bool

true if the type is a value type, false otherwise.

Returns

TypeSignature

The constructed type signature instance.

Remarks

This function can be used to avoid type resolution on type references.

TryGetIsValueType(RuntimeContext?)

Determines whether the type is considered a value type or reference type by the runtime.

public bool? TryGetIsValueType(RuntimeContext? context)

Parameters

context RuntimeContext

The runtime context that is assumed.

Returns

bool?

true when the type is considered a value type, false when it is a reference type, null when unknown.