Table of Contents

Class TypeRef

Namespace
Microsoft.VisualStudio.Composition.Reflection
Assembly
Microsoft.VisualStudio.Composition.dll
public class TypeRef : IEquatable<TypeRef>, IEquatable<Type>
Inheritance
TypeRef
Implements
Inherited Members
Extension Methods

Properties

AssemblyId

public StrongAssemblyIdentity AssemblyId { get; }

Property Value

StrongAssemblyIdentity

AssemblyName

public AssemblyName AssemblyName { get; }

Property Value

AssemblyName

BaseTypes

Gets the full list of base types and interfaces for this instance.

public ImmutableArray<TypeRef> BaseTypes { get; }

Property Value

ImmutableArray<TypeRef>

Remarks

This list will only be populated if this instance was created with shallow set to false. The collection is ordered bottom-up for types with the implemented interfaces appended at the end.

ElementTypeRef

public TypeRef ElementTypeRef { get; }

Property Value

TypeRef

FullName

Gets the full name of the type represented by this instance. When representing a generic type, this is the full name of the generic type definition.

public string FullName { get; }

Property Value

string

GenericTypeArguments

public ImmutableArray<TypeRef> GenericTypeArguments { get; }

Property Value

ImmutableArray<TypeRef>

GenericTypeParameterCount

public int GenericTypeParameterCount { get; }

Property Value

int

IsArray

public bool IsArray { get; }

Property Value

bool

IsGenericType

public bool IsGenericType { get; }

Property Value

bool

IsGenericTypeDefinition

public bool IsGenericTypeDefinition { get; }

Property Value

bool

IsShallow

Gets a value indicating whether or not this TypeRef is shallow. Shallow TypeRefs do not have a defined list of base types.

public bool IsShallow { get; }

Property Value

bool

IsValueType

public bool IsValueType { get; }

Property Value

bool

MetadataToken

public int MetadataToken { get; }

Property Value

int

TypeFlags

public TypeRefFlags TypeFlags { get; }

Property Value

TypeRefFlags

Methods

Equals(TypeRef?)

public bool Equals(TypeRef? other)

Parameters

other TypeRef

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

Equals(Type?)

public bool Equals(Type? other)

Parameters

other Type

Returns

bool

Get(Resolver, StrongAssemblyIdentity, int, string, TypeRefFlags, int, ImmutableArray<TypeRef>, bool, ImmutableArray<TypeRef>, TypeRef?)

public static TypeRef Get(Resolver resolver, StrongAssemblyIdentity assemblyId, int metadataToken, string fullName, TypeRefFlags typeFlags, int genericTypeParameterCount, ImmutableArray<TypeRef> genericTypeArguments, bool shallow, ImmutableArray<TypeRef> baseTypes, TypeRef? elementTypeRef)

Parameters

resolver Resolver
assemblyId StrongAssemblyIdentity
metadataToken int
fullName string
typeFlags TypeRefFlags
genericTypeParameterCount int
genericTypeArguments ImmutableArray<TypeRef>
shallow bool
baseTypes ImmutableArray<TypeRef>
elementTypeRef TypeRef

Returns

TypeRef

Get(Resolver, AssemblyName, int, string, TypeRefFlags, int, ImmutableArray<TypeRef>, bool, ImmutableArray<TypeRef>, TypeRef?)

public static TypeRef Get(Resolver resolver, AssemblyName assemblyName, int metadataToken, string fullName, TypeRefFlags typeFlags, int genericTypeParameterCount, ImmutableArray<TypeRef> genericTypeArguments, bool shallow, ImmutableArray<TypeRef> baseTypes, TypeRef? elementTypeRef)

Parameters

resolver Resolver
assemblyName AssemblyName
metadataToken int
fullName string
typeFlags TypeRefFlags
genericTypeParameterCount int
genericTypeArguments ImmutableArray<TypeRef>
shallow bool
baseTypes ImmutableArray<TypeRef>
elementTypeRef TypeRef

Returns

TypeRef

Get(Type?, Resolver)

Gets a TypeRef that represents a given Type instance.

public static TypeRef? Get(Type? type, Resolver resolver)

Parameters

type Type

The Type to represent. May be null to get a null result.

resolver Resolver

The resolver to use to reconstitute type or derivatives later.

Returns

TypeRef

An instance of TypeRef if type is not null; otherwise null.

GetHashCode()

public override int GetHashCode()

Returns

int

IsAssignableFrom(TypeRef)

Checks if the type represented by the given TypeRef can be assigned to the type represented by this instance.

public bool IsAssignableFrom(TypeRef other)

Parameters

other TypeRef

TypeRef to compare to.

Returns

bool

true if the given TypeRef can be assigned to this instance, false otherwise.

Remarks

The assignability check is done by traversing all the base types and interfaces of the given TypeRef to check if any of them are equal to this instance. Should that fail, the CLR is asked to check for assignability which will trigger an assembly load.

MakeGenericTypeRef(ImmutableArray<TypeRef>)

public TypeRef MakeGenericTypeRef(ImmutableArray<TypeRef> genericTypeArguments)

Parameters

genericTypeArguments ImmutableArray<TypeRef>

Returns

TypeRef