TypeReference Class
A type used by the code: in a signature, an attribute, or an instruction. The type may be defined outside the architecture.
public sealed class TypeReferenceProperties
| Name | Description |
|---|---|
| ArrayRank | Gets the rank of an array, or 0. |
| AssemblyName | Gets the simple name of the assembly the type is referenced from, or null when it is unknown. Type forwarders are not followed: a type of the framework is often referenced from System.Runtime. |
| DeclaringType | Gets the containing type of a nested type. |
| Definition | Gets the definition of a named type when one of the assemblies of the architecture defines it, or null. |
| ElementType | Gets the element type of an array, a pointer or a reference. |
| FullName | Gets the full name of a named type as written in metadata (System.Collections.Generic.List`1, MyApp.Outer+Inner), without its generic arguments. For other kinds, it is the same as TypeReference.ToString. |
| GenericArguments | Gets the generic arguments of a generic instantiation (List<Order>), or an empty list. |
| GenericTypeDefinition | Gets the generic type definition of a generic instantiation (List<T> for List<Order>), or null. |
| IsGenericInstance | Gets a value indicating whether the type is a generic instantiation (List<Order>). |
| Kind | Gets the shape of the type. |
| MetadataName | Gets the name of the type as written in metadata, with the generic arity (List`1). |
| Name | Gets the name of the type, without the namespace, the containing type and the generic arity (List). |
| Namespace | Gets the namespace of the type, or of its outermost containing type for a nested type. It is empty for a type that is not named. |
| SignatureTypes | Gets the types of the signature of a function pointer (the return type first), or an empty list. |
ArrayRank
TypeReference.csAssemblyName
TypeReference.csDeclaringType
TypeReference.csGets the containing type of a nested type.
public TypeReference? DeclaringType { get; }Property value
Definition
TypeReference.csGets the definition of a named type when one of the assemblies of the architecture defines it, or null.
public TypeElement? Definition { get; }Property value
ElementType
TypeReference.csGets the element type of an array, a pointer or a reference.
public TypeReference? ElementType { get; }Property value
FullName
TypeReference.csGets the full name of a named type as written in metadata (System.Collections.Generic.List`1, MyApp.Outer+Inner), without its generic arguments. For other kinds, it is the same as TypeReference.ToString.
public string FullName { get; }Property value
GenericArguments
TypeReference.csGets the generic arguments of a generic instantiation (List<Order>), or an empty list.
public IReadOnlyList<TypeReference> GenericArguments { get; }Property value
GenericTypeDefinition
TypeReference.csGets the generic type definition of a generic instantiation (List<T> for List<Order>), or null.
public TypeReference? GenericTypeDefinition { get; }Property value
IsGenericInstance
TypeReference.csKind
TypeReference.csMetadataName
TypeReference.csName
TypeReference.csNamespace
TypeReference.csSignatureTypes
TypeReference.csGets the types of the signature of a function pointer (the return type first), or an empty list.
public IReadOnlyList<TypeReference> SignatureTypes { get; }Property value
Methods
| Name | Description |
|---|---|
| Is(Type) | Determines whether the type is the named type type, or a generic instantiation of it. |
| Is<T>() | Determines whether the type is the named type T, or a generic instantiation of it. |
| IsInNamespace(string) | Determines whether the type is in the namespace namespace, not in one of its child namespaces. |
| IsInNamespaceOrChildren(string) | Determines whether the type is in the namespace namespace or in one of its child namespaces: MyApp.Domain matches MyApp.Domain and MyApp.Domain.Events, not MyApp.DomainEvents. |
| ToString() | Returns the type as written in C#: System.Collections.Generic.List<MyApp.Order>, System.Collections.Generic.List<>. |
IsInNamespace(string)
TypeReference.csDetermines whether the type is in the namespace namespace, not in one of its child namespaces.
Parameters
namespacestring- The namespace (
MyApp.Domain).
Returns
bool true when TypeReference.Namespace is namespace.
See also
IsInNamespaceOrChildren(string)
TypeReference.csDetermines whether the type is in the namespace namespace or in one of its child namespaces: MyApp.Domain matches MyApp.Domain and MyApp.Domain.Events, not MyApp.DomainEvents.
Parameters
namespacestring- The namespace (
MyApp.Domain).
Returns
bool true when TypeReference.Namespace is namespace or starts with namespace followed by a dot.