Open sandboxFocusImprove this doc
  • TOC

Metalama Documentation

Getting started

Video tutorials

Conceptual documentation

Commented examples

API documentation

Aspect API

Metalama.​Framework.​Advising

Metalama.​Framework.​Aspects

Metalama.​Framework.​Code

Accessibility

Accessibility­Extensions

Async­Info

Attribute­Extensions

Code­Display­Context

Code­Display­Format

Compilation­Extensions

Constructor­Collection­Extensions

Constructor­Initializer­Kind

Conversion­Kind

Declaration­Enhancements<T>

Declaration­Extensions

Declaration­Kind

Declaration­Origin­Kind

Derived­Types­Options

Enumerable­Kind

Execution­Scope

Generic­Extensions

IAnnotation

IAnnotation<T>

IAspect­Declaration­Origin

IAssembly

IAssembly­Identity

IAttribute

IAttribute­Data

ICompilation

ICompilation­Element

IConstructor

IDeclaration

IDeclaration­Cache

IDeclaration­Factory

IDeclaration­Origin

IDisplayable

IEvent

IExpression

IField

IField­Or­Property

IField­Or­Property­Or­Indexer

IGeneric

IGeneric­Context

IHas­Accessors

IHas­Parameters

IHas­Type

IIndexer

IManaged­Resource

IMember

IMember­Or­Named­Type

IMethod

IMethod­Base

INamed­Declaration

INamed­Type

INamespace

INamespace­Or­Named­Type

IObject­Creation­Expression

IParameter

IProperty

IProperty­Or­Indexer

IRef

IRef<T>

ISource­Expression

Iterator­Info

IType

IType­Parameter

Member­Extensions

Method­Collection­Extensions

Method­Extensions

Method­Kind

Named­Type­Extensions

Namespace­Extensions

Operator­Category

Operator­Kind

Operator­Kind­Extensions

Ref­Comparison

Ref­Extensions

Ref­Kind

Ref­Kind­Extensions

Reflection­Extensions

Serializable­Declaration­Id

Serializable­Type­Id

Source­Reference

Source­Span

Special­Type

Typed­Constant

Type­Extensions

Type­Factory

Type­Kind

Type­Kind­Constraint

Type­Parameter­Kind

Variance­Kind

Writeability

Metalama.​Framework.​Code.​Collections

Metalama.​Framework.​Code.​Comparers

Metalama.​Framework.​Code.​Declaration­Builders

Metalama.​Framework.​Code.​Invokers

Metalama.​Framework.​Code.​Syntax­Builders

Metalama.​Framework.​Code.​Types

Metalama.​Framework.​Code­Fixes

Metalama.​Framework.​Diagnostics

Metalama.​Framework.​Eligibility

Metalama.​Framework.​Fabrics

Metalama.​Framework.​Metrics

Metalama.​Framework.​Options

Metalama.​Framework.​Project

Metalama.​Framework.​Run­Time

Metalama.​Framework.​Serialization

Metalama.​Framework.​Services

Metalama.​Framework.​Utilities

Metalama.​Framework.​Validation

Extensions API

Patterns API

Flashtrace API

Introspection API

Advanced API

Post­Sharp API migration

  • Article

Namespace Metalama.Framework.Code

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

Simplified class diagram

IDeclaration
IMemberOrNamedType
IMember
INamedType
IFieldOrProperty
IField
IProperty
IMethodBase
IMethod
IConstructor
IParameter
IGenericParameter
IAttribute
INamespace
ICompilation

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.

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. 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.

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

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

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<T>(IRef<T>, ICompilation, IGenericContext?). All objects implementing this interface also implement the stronly-typed IRef<T>.

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<T>(IRef<T>, ICompilation, IGenericContext?).

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.

RefComparison

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

RefKind

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

SpecialType

Special types, such as Void.

TypeKind

Kinds of IType.

TypeKindConstraint

TypeParameterKind

VarianceKind

Specifies the kind variance: In, Out or None.

Writeability

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