Open sandboxFocusImprove this doc

Namespace Metalama.Framework.Code

This namespace encompasses the representation of both the source code and the transformed code.

Simplified class diagram

classDiagram
      IDeclaration <|-- IMemberOrNamedType
      IMemberOrNamedType <|-- IMember
      IMemberOrNamedType <|-- INamedType
      IMember <|-- IFieldOrProperty
      IFieldOrProperty <|-- IField
      IFieldOrProperty <|-- IProperty
      IMember <|-- IMethodBase
      IMethodBase <|-- IMethod
      IMethodBase <|-- IConstructor
      IDeclaration <|-- IParameter
      IDeclaration <|-- IGenericParameter
      IDeclaration <|-- IAttribute
      IDeclaration <|-- INamespace
      IDeclaration <|-- ICompilation


      IMethodBase o-- IParameter
      IProperty o-- IParameter
      IDeclaration o-- IAttribute
      IMethod o-- IGenericParameter
      INamedType o-- IGenericParameter
      INamedType o-- IMemberOrNamedType
      ICompilation o-- INamespace
      INamespace o-- INamedType

Classes

AccessibilityExtensions

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

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

RefExtensions

Extension methods for the IRef<T> interface.

RefKindExtensions

Extension methods for RefKind.

ReflectionExtensions

TypeExtensions

Provides extension methods for IType.

TypeFactory

Exposes methods that return instances of the IType interface.

Structs

AsyncInfo

Information about an async method, returned by the GetAsyncInfo(IMethod) extension method of IMethod.

DeclarationEnhancements<T>

Gives access to the aspects, options and annotations on a declaration.

IteratorInfo

Information about an iterator method, returned by the GetIteratorInfo(IMethod) extension method of IMethod.

SerializableDeclarationId

Encapsulates a string that uniquely identifies a declaration 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.

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>

An annotation is an arbitrary but serializable object that can then be retrieved using the GetAnnotations<TAnnotation>() method of the Enhancements<T>(T) object. Annotations are a way of communication between aspects or classes of aspects.

IAspectDeclarationOrigin

IAssembly

Represents an assembly (typically a reference assembly).

IAssemblyIdentity

Represents an assembly identity, used in project references.

IAttribute

Represent a custom attributes.

IAttributeData

Represent the members of a custom attribute, but not 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.

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. To create an expression, use ExpressionFactory or ExpressionBuilder. Note that IField, IProperty and IParameter also implement the IExpression interface.

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

An interface, common to INamedType and IMethod, that represents a generic declaration, i.e. a declaration with type parameters.

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

INamedType

Represents a class, struct, interface, enum, or delegate.

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

IRef<T>

Represents a reference to an IDeclaration or IType, which is valid across different compilation versions (i.e. ICompilation) and, when serialized, across projects and processes. References can be resolved using GetTarget(ICompilation, ReferenceResolutionOptions), given an compilation, or using the GetTarget<T>(IRef<T>, ReferenceResolutionOptions) extension method for the compilation of the current context.

ISourceExpression

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

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 parameter of a method or type.

Enums

Accessibility

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

ConstructorInitializerKind

Describes the kind of constructor initializer.

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

Kinds of iterators.

ExecutionScope

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

MethodKind

Kinds of IMethodBase.

OperatorCategory

OperatorKind

Kinds of operators.

RefKind

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

ReferenceResolutionOptions

Options that determine how GetTarget(ICompilation, ReferenceResolutionOptions) and related methods work.

SpecialType

Special types, such as Void.

TypeKind

Kinds of IType.

TypeKindConstraint

VarianceKind

Specifies the kind variance: In, Out or None.

Writeability

Enumerates the different abilities of a field or property to be written (set).