TypeElement Class
A type defined in an assembly of the architecture.
public sealed class TypeElementProperties
| Name | Description |
|---|---|
| Accessibility | Gets the declared accessibility of the type. |
| Architecture | Gets the architecture that contains the type. |
| Assembly | Gets the assembly that defines the type. |
| Attributes | Gets the attributes applied to the type. |
| BaseType | Gets the base type, or null for an interface and for Object. |
| Constructors | Gets the instance and static constructors. |
| DeclaringType | Gets the containing type of a nested type, or null. |
| Dependencies | Gets the types the type uses, in its declaration, the declarations of its members, and the code of its methods, lambdas, local functions, iterators and async methods. A type used several times by a member in the same way gives one dependency. The type itself and the types generated by the compiler are not included. |
| Events | Gets the events. |
| Fields | Gets the fields, except the ones generated by the compiler (backing fields of auto-properties). |
| FullName | Gets the full name of the type as written in metadata (MyApp.Repository`1, MyApp.Outer+Inner), which is also the value of Type.FullName. |
| GenericParameters | Gets the names of the generic parameters of the type, including the ones of its containing types. |
| Interfaces | Gets the interfaces the type declares. Use TypeElement.Implements to include the interfaces of the base types. |
| IsAbstract | Gets a value indicating whether the type is an abstract class. Interfaces and static classes are not abstract classes. |
| IsClass | Gets a value indicating whether the type is a class, including a record class. |
| IsDelegate | Gets a value indicating whether the type is a delegate. |
| IsEnum | Gets a value indicating whether the type is an enum. |
| IsGeneric | Gets a value indicating whether the type has generic parameters, including the ones of its containing types. |
| IsImmutable | Gets a value indicating whether the instances of the type cannot be modified: its instance fields are readonly or constant, and its instance properties have no setter, or an init setter. The types of the fields are not checked. |
| IsInterface | Gets a value indicating whether the type is an interface. |
| IsNested | Gets a value indicating whether the type is nested in another type. |
| IsPublic | Gets a value indicating whether the type is declared public. A public type nested in a non-public type is public. |
| IsRecord | Gets a value indicating whether the type is a record class or a record struct. |
| IsSealed | Gets a value indicating whether no type can inherit from the type: a sealed class, a struct, an enum or a delegate. Static classes are not sealed. |
| IsStatic | Gets a value indicating whether the type is a static class. |
| IsStruct | Gets a value indicating whether the type is a struct, including a record struct. |
| Kind | Gets the kind of the type. |
| Location | Gets the first statement of the type when the PDB is available, or null. |
| Members | Gets all the members: constructors, methods, properties, fields and events. |
| MetadataName | Gets the name of the type as written in metadata, with the generic arity (Repository`1). |
| Methods | Gets the methods, except the constructors, the accessors of the properties and events, and the methods generated by the compiler (lambdas, local functions). |
| Name | Gets the name of the type, without the namespace, the containing type and the generic arity (Repository for Repository<T>). |
| Namespace | Gets the namespace of the type, or of its outermost containing type for a nested type. |
| NestedTypes | Gets the nested types, except the ones generated by the compiler. |
| Properties | Gets the properties and indexers. |
Accessibility
TypeElement.csGets the declared accessibility of the type.
public ElementAccessibility Accessibility { get; }Property value
Architecture
TypeElement.csGets the architecture that contains the type.
public ArchitectureModel Architecture { get; }Property value
Assembly
TypeElement.csAttributes
TypeElement.csGets the attributes applied to the type.
public IReadOnlyList<AttributeElement> Attributes { get; }Property value
BaseType
TypeElement.csGets the base type, or null for an interface and for Object.
public TypeReference? BaseType { get; }Property value
Constructors
TypeElement.csGets the instance and static constructors.
public IReadOnlyList<MethodElement> Constructors { get; }Property value
DeclaringType
TypeElement.csGets the containing type of a nested type, or null.
public TypeElement? DeclaringType { get; }Property value
Dependencies
TypeElement.csGets the types the type uses, in its declaration, the declarations of its members, and the code of its methods, lambdas, local functions, iterators and async methods. A type used several times by a member in the same way gives one dependency. The type itself and the types generated by the compiler are not included.
public IReadOnlyList<Dependency> Dependencies { get; }Property value
Events
TypeElement.csFields
TypeElement.csGets the fields, except the ones generated by the compiler (backing fields of auto-properties).
public IReadOnlyList<FieldElement> Fields { get; }Property value
FullName
TypeElement.csGets the full name of the type as written in metadata (MyApp.Repository`1, MyApp.Outer+Inner), which is also the value of Type.FullName.
public string FullName { get; }Property value
GenericParameters
TypeElement.csGets the names of the generic parameters of the type, including the ones of its containing types.
public IReadOnlyList<string> GenericParameters { get; }Property value
Interfaces
TypeElement.csGets the interfaces the type declares. Use TypeElement.Implements to include the interfaces of the base types.
public IReadOnlyList<TypeReference> Interfaces { get; }Property value
IsAbstract
TypeElement.csIsClass
TypeElement.csIsDelegate
TypeElement.csIsEnum
TypeElement.csIsGeneric
TypeElement.csIsImmutable
TypeElement.csIsInterface
TypeElement.csIsNested
TypeElement.csIsPublic
TypeElement.csIsRecord
TypeElement.csIsSealed
TypeElement.csIsStatic
TypeElement.csIsStruct
TypeElement.csKind
TypeElement.csLocation
TypeElement.csGets the first statement of the type when the PDB is available, or null.
public SourceLocation? Location { get; }Property value
Members
TypeElement.csGets all the members: constructors, methods, properties, fields and events.
public IReadOnlyList<MemberElement> Members { get; }Property value
MetadataName
TypeElement.csMethods
TypeElement.csGets the methods, except the constructors, the accessors of the properties and events, and the methods generated by the compiler (lambdas, local functions).
public IReadOnlyList<MethodElement> Methods { get; }Property value
Name
TypeElement.csNamespace
TypeElement.csNestedTypes
TypeElement.csGets the nested types, except the ones generated by the compiler.
public IReadOnlyList<TypeElement> NestedTypes { get; }Property value
Properties
TypeElement.csGets the properties and indexers.
public IReadOnlyList<PropertyElement> Properties { get; }Property value
Methods
| Name | Description |
|---|---|
| HasAttribute(Type) | Determines whether the type has an attribute of the given type. |
| HasAttribute<T>() | Determines whether the type has an attribute of type T. |
| Implements(string) | Determines whether the type, one of its base types, or one of their interfaces implements the interface whose metadata name is fullName. |
| Implements(Type) | Determines whether the type, one of its base types, or one of their interfaces implements interfaceType. |
| Implements<T>() | Determines whether the type, one of its base types, or one of their interfaces implements T. |
| InheritsFrom(string) | Determines whether the type inherits, directly or not, from the type whose metadata name is fullName. |
| InheritsFrom(Type) | Determines whether the type inherits, directly or not, from baseType. The base types are resolved in the referenced assemblies. |
| InheritsFrom<T>() | Determines whether the type inherits, directly or not, from T. The base types are resolved in the referenced assemblies. |
| Is(Type) | Determines whether the type is type, or its generic type definition. |
| IsAssignableTo(string) | Determines whether the type is the type whose metadata name is fullName, inherits from it, or implements it. |
| IsAssignableTo(Type) | Determines whether the type is type, inherits from it, or implements it. |
| IsAssignableTo<T>() | Determines whether the type is T, inherits from it, or implements 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#: MyApp.Repository<T>, MyApp.Outer.Inner. |
Implements overloads
Implements(string)
TypeElement.csDetermines whether the type, one of its base types, or one of their interfaces implements the interface whose metadata name is fullName.
Implements(Type)
TypeElement.csDetermines whether the type, one of its base types, or one of their interfaces implements interfaceType.
Implements<T>()
TypeElement.csInheritsFrom overloads
InheritsFrom(string)
TypeElement.csDetermines whether the type inherits, directly or not, from the type whose metadata name is fullName.
InheritsFrom(Type)
TypeElement.csDetermines whether the type inherits, directly or not, from baseType. The base types are resolved in the referenced assemblies.
InheritsFrom<T>()
TypeElement.csIs(Type)
TypeElement.csIsAssignableTo overloads
IsAssignableTo(string)
TypeElement.csDetermines whether the type is the type whose metadata name is fullName, inherits from it, or implements it.
IsAssignableTo(Type)
TypeElement.csIsAssignableTo<T>()
TypeElement.csIsInNamespace(string)
TypeElement.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 TypeElement.Namespace is namespace.
See also
IsInNamespaceOrChildren(string)
TypeElement.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 TypeElement.Namespace is namespace or starts with namespace followed by a dot.