Table of Contents

Class TypeDescriptorExtensions

Namespace
AsmResolver.DotNet
Assembly
AsmResolver.DotNet.dll

Provides convenience extension methods to instances of ITypeDescriptor.

public static class TypeDescriptorExtensions
Inheritance
TypeDescriptorExtensions
Inherited Members

Methods

CreateMemberReference(IMemberRefParent, string?, MemberSignature?)

Constructs a reference to a member declared within the provided parent member.

public static MemberReference CreateMemberReference(this IMemberRefParent parent, string? memberName, MemberSignature? signature)

Parameters

parent IMemberRefParent

The declaring member.

memberName string

The name of the member to reference.

signature MemberSignature

The signature of the member to reference.

Returns

MemberReference

The constructed reference.

CreateTypeReference(IResolutionScope, string?, string)

Constructs a reference to a type within the provided resolution scope.

public static TypeReference CreateTypeReference(this IResolutionScope scope, string? ns, string name)

Parameters

scope IResolutionScope

The scope the type is defined in.

ns string

The namespace of the type.

name string

The name of the type.

Returns

TypeReference

The constructed reference.

CreateTypeReference(ITypeDefOrRef, string)

Constructs a reference to a nested type.

public static TypeReference CreateTypeReference(this ITypeDefOrRef declaringType, string nestedTypeName)

Parameters

declaringType ITypeDefOrRef

The enclosing type.

nestedTypeName string

The name of the nested type.

Returns

TypeReference

The constructed reference.

Exceptions

ArgumentOutOfRangeException

Occurs when declaringType cannot be used as a declaring type of a type reference.

IsTypeOf(ITypeDescriptor, string?, string?)

Determines whether a type matches a namespace and name pair.

public static bool IsTypeOf(this ITypeDescriptor type, string? ns, string? name)

Parameters

type ITypeDescriptor

The type.

ns string

The namespace.

name string

The name.

Returns

bool

true if the name and the namespace of the type matches the provided values, false otherwise.

IsTypeOfUtf8(ExportedType, Utf8String?, Utf8String?)

Determines whether a type matches a namespace and name pair.

public static bool IsTypeOfUtf8(this ExportedType type, Utf8String? ns, Utf8String? name)

Parameters

type ExportedType

The type.

ns Utf8String

The namespace.

name Utf8String

The name.

Returns

bool

true if the name and the namespace of the type matches the provided values, false otherwise.

IsTypeOfUtf8(ITypeDefOrRef, Utf8String?, Utf8String?)

Determines whether a type matches a namespace and name pair.

public static bool IsTypeOfUtf8(this ITypeDefOrRef type, Utf8String? ns, Utf8String? name)

Parameters

type ITypeDefOrRef

The type.

ns Utf8String

The namespace.

name Utf8String

The name.

Returns

bool

true if the name and the namespace of the type matches the provided values, false otherwise.

MakeArrayType(ITypeDescriptor, params ArrayDimension[])

Constructs a new single-dimension, zero based array signature with the provided type descriptor as element type.

public static ArrayTypeSignature MakeArrayType(this ITypeDescriptor type, params ArrayDimension[] dimensions)

Parameters

type ITypeDescriptor

The element type.

dimensions ArrayDimension[]

The dimensions of the array.

Returns

ArrayTypeSignature

The constructed array type signature.

MakeArrayType(ITypeDescriptor, int)

Constructs a new single-dimension, zero based array signature with the provided type descriptor as element type.

public static ArrayTypeSignature MakeArrayType(this ITypeDescriptor type, int dimensionCount)

Parameters

type ITypeDescriptor

The element type.

dimensionCount int

The number of dimensions in the array.

Returns

ArrayTypeSignature

The constructed array type signature.

MakeByReferenceType(ITypeDescriptor)

Constructs a new by-reference type signature with the provided type descriptor as element type. as element type.

public static ByReferenceTypeSignature MakeByReferenceType(this ITypeDescriptor type)

Parameters

type ITypeDescriptor

The element type.

Returns

ByReferenceTypeSignature

The constructed by-reference type signature.

MakeGenericInstanceType(ITypeDescriptor, params TypeSignature[])

Constructs a new pointer type signature with the provided type descriptor as element type. as element type.

public static GenericInstanceTypeSignature MakeGenericInstanceType(this ITypeDescriptor type, params TypeSignature[] typeArguments)

Parameters

type ITypeDescriptor

The element type.

typeArguments TypeSignature[]

The arguments to instantiate the type with.

Returns

GenericInstanceTypeSignature

The constructed by-reference type signature.

MakeGenericInstanceType(ITypeDescriptor, bool, params TypeSignature[])

Constructs a new pointer type signature with the provided type descriptor as element type. as element type.

public static GenericInstanceTypeSignature MakeGenericInstanceType(this ITypeDescriptor type, bool isValueType, params TypeSignature[] typeArguments)

Parameters

type ITypeDescriptor

The element type.

isValueType bool

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

typeArguments TypeSignature[]

The arguments to instantiate the type with.

Returns

GenericInstanceTypeSignature

The constructed by-reference type signature.

Remarks

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

MakeModifierType(ITypeDescriptor, ITypeDefOrRef, bool)

Constructs a new pointer type signature with the provided type descriptor as element type. as element type.

public static CustomModifierTypeSignature MakeModifierType(this ITypeDescriptor type, ITypeDefOrRef modifierType, bool isRequired)

Parameters

type ITypeDescriptor

The element type.

modifierType ITypeDefOrRef

The modifier type to add.

isRequired bool

Indicates whether the modifier is required or optional.

Returns

CustomModifierTypeSignature

The constructed by-reference type signature.

MakePinnedType(ITypeDescriptor)

Constructs a new pinned type signature with the provided type descriptor as element type. as element type.

public static PinnedTypeSignature MakePinnedType(this ITypeDescriptor type)

Parameters

type ITypeDescriptor

The element type.

Returns

PinnedTypeSignature

The constructed by-reference type signature.

MakePointerType(ITypeDescriptor)

Constructs a new pointer type signature with the provided type descriptor as element type. as element type.

public static PointerTypeSignature MakePointerType(this ITypeDescriptor type)

Parameters

type ITypeDescriptor

The element type.

Returns

PointerTypeSignature

The constructed by-reference type signature.

MakeSzArrayType(ITypeDescriptor)

Constructs a new single-dimension, zero based array signature with the provided type descriptor as element type.

public static SzArrayTypeSignature MakeSzArrayType(this ITypeDescriptor type)

Parameters

type ITypeDescriptor

The element type.

Returns

SzArrayTypeSignature

The constructed array type signature.