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
IMemberRefParentThe declaring member.
memberName
stringThe name of the member to reference.
signature
MemberSignatureThe 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
IResolutionScopeThe scope the type is defined in.
ns
stringThe namespace of the type.
name
stringThe 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
ITypeDefOrRefThe enclosing type.
nestedTypeName
stringThe 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
ITypeDescriptorThe type.
ns
stringThe namespace.
name
stringThe 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
ExportedTypeThe type.
ns
Utf8StringThe namespace.
name
Utf8StringThe 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
ITypeDefOrRefThe type.
ns
Utf8StringThe namespace.
name
Utf8StringThe 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
ITypeDescriptorThe 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
ITypeDescriptorThe element type.
dimensionCount
intThe 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
ITypeDescriptorThe 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
ITypeDescriptorThe 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
ITypeDescriptorThe element type.
isValueType
booltrue
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
ITypeDescriptorThe element type.
modifierType
ITypeDefOrRefThe modifier type to add.
isRequired
boolIndicates 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
ITypeDescriptorThe 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
ITypeDescriptorThe 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
ITypeDescriptorThe element type.
Returns
- SzArrayTypeSignature
The constructed array type signature.