Open sandboxFocusImprove this doc

Advanced extensibility API (SDK)

The Metalama.Framework.Sdk package enables extending Metalama using the Roslyn API. These APIs provide low-level access to compilation transformations and are intended for advanced scenarios where the standard advice API is insufficient.

For conceptual guidance on using these APIs, see Extending Metalama with the Roslyn API.

Namespace reference

Namespace Description
Metalama.Compiler Provides the lowest-level API for writing source transformers. Implementations of ISourceTransformer can modify the Roslyn compilation directly without any aspect concepts. Use this when you need to transform code independently of the Metalama aspect pipeline.
Metalama.Framework.Engine.AspectWeavers Enables implementing Metalama aspects at the Roslyn level using the IAspectWeaver interface. Unlike Metalama.Compiler, aspect weavers integrate with the Metalama Framework pipeline and have access to aspect instances and the Metalama code model. For step-by-step guidance, see Aspect weavers.
Metalama.Framework.Engine.CodeModel Bridges the Metalama code model (IDeclaration, IType) with Roslyn symbols (ISymbol). The SymbolExtensions class provides extension methods such as GetSymbol and GetDeclaration for converting between the two models. The IPartialCompilation interface represents a compilation that can be transformed by aspect weavers. For usage examples, see Using the Roslyn API from aspects.
Metalama.Framework.Engine.Collections Contains specialized collection interfaces and types used internally by the SDK, including IReadOnlyMultiValueDictionary<TKey, TValue>.
Metalama.Framework.Engine.Formatting Contains annotations and extension methods for marking generated code in syntax trees. When implementing an IAspectWeaver, use the FormattingAnnotations class to annotate generated syntax nodes so Metalama can format them correctly.