Open sandboxFocusImprove this doc

Namespace Metalama.Framework.Code

This namespace represents the structure of the source code.

Simplified class diagram

classDiagram
      IDeclaration <|-- IMemberOrNamedType
      IMemberOrNamedType <|-- IMember
      IMemberOrNamedType <|-- INamedType
      IMember <|-- IFieldOrProperty
      IMember <|-- IFieldOrPropertyOrIndexer
      IFieldOrPropertyOrIndexer <|-- IFieldOrProperty
      IFieldOrProperty <|-- IField
      IFieldOrProperty <|-- IProperty
      IPropertyOrIndexer <|-- IProperty
      IFieldOrPropertyOrIndexer <|-- IPropertyOrIndexer
      IPropertyOrIndexer <|-- IIndexer
      IMember <|-- IMethodBase
      IMember <|-- IEvent
      IMethodBase <|-- IMethod
      IMethodBase <|-- IConstructor
      IDeclaration <|-- IParameter
      IDeclaration <|-- ITypeParameter
      IDeclaration <|-- IAttribute
      IDeclaration <|-- INamespace
      IDeclaration <|-- ICompilation
      INamedType <|-- IExtensionBlock


      IMethodBase o-- IParameter
      IIndexer o-- IParameter
      IEvent o-- IParameter
      IDeclaration o-- IAttribute
      IMethod o-- ITypeParameter
      INamedType o-- ITypeParameter
      INamedType o-- IMemberOrNamedType
      ICompilation o-- INamespace
      INamespace o-- INamedType

Classes

AccessibilityExtensions

Provides extension methods for the Accessibility type to compare accessibility levels.

AttributeExtensions

Extension methods for the IAttribute interface.

CodeDisplayContext

Reserved for future use. Specifies the context for which the display string must be generated.

CodeDisplayFormat

Defines the formatting options of ToDisplayString(CodeDisplayFormat?, CodeDisplayContext?). Only well-known instances of this classes, exposed as properties, are currently supported.

CompilationExtensions

Extension methods for the ICompilation interface.

ConstructorCollectionExtensions

Provides extension methods to the IConstructorCollection interface.

DeclarationExtensions

Extension methods for IDeclaration.

GenericExtensions

Provides extension methods to work with generic declarations.

MemberExtensions

Extension methods for the IMember interface.

MethodCollectionExtensions

Provides extension methods to the IMethodCollection interface.

MethodExtensions

Extension methods for the IMethod interface.

NamedTypeExtensions

Extension methods for the INamedType interface.

NamespaceExtensions

OperatorKindExtensions

Defines extension methods for the OperatorKind class.

RefExtensions

Extension methods for resolving IRef<T> references to their target declarations.

RefKindExtensions

Extension methods for RefKind.

ReferenceKindsExtension

Extension methods for ReferenceKinds.

ReflectionExtensions

Extension methods for reflection types to convert them to Metalama expressions.

TypeExtensions

Provides extension methods for IType.

TypeFactory

Provides methods to obtain IType instances from reflection types, special types, or by constructing new types.

Structs

AsyncInfo

Provides information about the async characteristics of a method, returned by the GetAsyncInfo(IMethod) extension method of IMethod.

DeclarationEnhancements<T>

Provides access to aspects, options, and annotations applied to a declaration. This allows querying metadata added by aspects and accessing hierarchical configuration.

IteratorInfo

Provides information about the iterator characteristics of a method, returned by the GetIteratorInfo(IMethod) extension method of IMethod.

SerializableDeclarationId

Encapsulates a string that uniquely identifies a declaration within a compilation and that is safe to persist in a file or serialize across processes.

SerializableTypeId

Encapsulates a string that uniquely identifies a type within a compilation (except in the situation where the compilation contains several assemblies providing types of the same name) and that is safe to persist in a file.

SourceReference

Represents a syntax node in source code. Using Metalama.Framework.Sdk you can use ToSyntaxNodeOrToken to convert it to a Roslyn object.

SourceSpan

Represents a span of source code.

TypedConstant

Represents a typed value that can be defined, defined to null, or undefined. Used to represent default values, for instance DefaultValue, or attribute arguments.

Interfaces

IAnnotation

A non-generic base interface for the generic IAnnotation<T>. You should always implement the generic interface.

IAnnotation<T>

Represents an annotation - an arbitrary serializable object that aspects can attach to declarations to communicate information to other aspects or subsequent compilation phases.

IAspectDeclarationOrigin

IAssembly

Represents an assembly (typically a reference assembly).

IAssemblyIdentity

Represents an assembly identity, used in project references.

IAttribute

Represents a custom attribute applied to a declaration.

IAttributeData

Represents the data of a custom attribute (type, constructor arguments, and named arguments) without its relationship to the containing declaration.

ICompilation

Represents a set of types compiled together. See also IProject.

ICompilationElement

Exposes a Compilation property.

IConstructor

Represents an instance constructor or a static constructor.

IDeclaration

Represent a declaration.

IDeclarationCache

A service that caches declarations of the current compilation. It is typically used to cache often-used declarations across aspect instances.

IDeclarationFactory

Allows to get instances of the IType interface or to test for type equality or inheritance.

IDeclarationOrigin

Represents the origin of the code, i.e. the artefact or function created the declaration.

IDisplayable

Defines a method ToDisplayString(CodeDisplayFormat?, CodeDisplayContext?) that renders the current declaration into a human-readable string.

IEvent

Represent an event.

IExpression

A compile-time representation of a run-time expression, representing C# syntax that will be generated in transformed code.

IExtensionBlock

Represents an extension block.

IField

Represents a field. Note that fields can be promoted to properties by aspects.

IFieldOrProperty

A base interface for IField and IProperty.

IFieldOrPropertyOrIndexer

A base interface for IProperty, IField and IIndexer.

IGeneric

Represents a generic declaration with type parameters, common to INamedType and IMethod.

IGenericContext

Represents a context in which type parameters are mapped to their values.

IHasAccessors

A base interface for IProperty and IEvent. Exposes GetAccessor(MethodKind).

IHasParameters

Represents a method, constructor, or indexer.

IHasType

Exposes a Type property.

IIndexer

Represents an indexer, i.e. a this[*] property.

IManagedResource

Represents a managed resource.

IMember

Base interface for IMethod, IFieldOrProperty, IEvent, but not INamedType.

IMemberOrNamedType

Base interface for IMethod, IFieldOrPropertyOrIndexer, IEvent, and INamedType.

IMethod

Represents a method, but not a constructor.

IMethodBase

Represents a method or a constructor.

INamedDeclaration

Represents a declaration that has a name.

INamedType

Represents a named type: class, struct, interface, enum, delegate, or record.

INamespace

Represents a namespace inside the current compilation or an external assembly, according to the DeclaringAssembly property.

INamespaceOrNamedType

Represents a namespace or a named type.

IObjectCreationExpression

A compile-time representation of a run-time object creation expression.

IParameter

Represents a parameter of a method or property.

IProperty

Represents a property.

IPropertyOrIndexer

A base interface for IProperty and IIndexer.

IRef

Represents a reference to an IDeclaration or IType that remains valid across different compilation versions (i.e., ICompilation) and, when serialized, across projects and processes. All objects implementing this interface also implement the strongly-typed IRef<T>.

IRef<T>

Represents a strongly-typed reference to an IDeclaration or IType that remains valid across different compilation versions (i.e., ICompilation) and, when serialized, across projects and processes.

ISourceExpression

Represents an IExpression defined in source code, as opposed to a generated expression.

ISourceReferenceImpl

ITupleElement

Represents an element of a tuple type.

ITupleType

Represents a tuple type, such as (int, string) or (decimal Quantity, string ProductCode).

IType

Represents a constructed type, for instance an array, a generic type instance, a pointer. A class, struct, enum or delegate are represented as an INamedType, which derive from IType.

ITypeParameter

Represents a generic type parameter of a method or type, such as T in List<T>.

Enums

Accessibility

Accessibility of types and members, for instance Private or Public.

AccessibilityFlags

ConstructorInitializerKind

Describes the kind of constructor initializer. A constructor initializer is the optional : base(...) or : this(...) clause that appears after the constructor parameter list and invokes another constructor before the current constructor body executes.

ConversionKind

Describes conversion between types possible during comparison.

DeclarationKind

Kinds of IDeclaration.

DeclarationOriginKind

Kinds of IDeclarationOrigin.

DerivedTypesOptions

Options for the GetDerivedTypes(INamedType, DerivedTypesOptions) method.

EnumerableKind

Specifies the kind of enumerable or enumerator type returned by a method.

ExecutionScope

Enumerates the possible execution scopes of a declaration i.e. RunTime, CompileTime or RunTimeOrCompileTime.

FieldKind

Specifies the kind of field.

MethodKind

Kinds of IMethod.

OperatorCategory

Categorizes operator kinds. To get the OperatorCategory from an OperatorKind, use the GetCategory(OperatorKind) extension method.

OperatorKind

Kinds of operators.

RefComparison

Defines strategies to compare two instances of the IRef<T> interface.

RefKind

Kinds of parameters, such as ref, in, out...

ReferenceKinds

Enumerates all kinds of references.

SpecialType

Identifies well-known types for efficient type checking without string comparisons.

TypeKind

Kinds of IType.

TypeKindConstraint

Specifies type kind constraints for generic type parameters.

TypeParameterKind

Specifies whether a type parameter belongs to a type or a method.

VarianceKind

Specifies the kind variance for type parameters: In, Out or None.

Writeability

Enumerates the different abilities of a field or property to be written (set). Values are ordered from most restrictive (None) to least restrictive (All).