Metalama//API Documentation/Advanced API/Metalama.​Compiler/Transformer­Context
Open sandboxFocus

Class TransformerContext

Context passed to a source transformer when Execute(TransformerContext) is called. The implementation can modify the compilation using the methods AddSyntaxTrees(SyntaxTree[]), ReplaceSyntaxTree(SyntaxTree, SyntaxTree) or AddResources(ManagedResource[]). It can report a diagnostic using ReportDiagnostic(Diagnostic) or suppress diagnostics using RegisterDiagnosticFilter(SuppressionDescriptor, Action<DiagnosticFilteringRequest>).

Inheritance
TransformerContext
Namespace: Metalama.Compiler
Assembly: Metalama.Compiler.Interface.dll
Syntax
public sealed class TransformerContext : Object

Properties

Name Description
AnalyzerConfigOptionsProvider

Gets the AnalyzerConfigOptionsProvider, which allows to access .editorconfig options.

Compilation

Gets or sets the Compilation. Transformers typically replace the value of this property.

Options

Gets options of the current TransformerContext.

Plugins

Gets plugins that were registered by being marked with the Metalama.CompilerPluginAttribute attribute.

Resources

Gets the list of managed resources.

Services

Gets the services initialized by the compiler. This property can be null when the compiler API is called from the Workspace scenario, e.g. in Metalama.Try.

Methods

Name Description
AddResources(ManagedResource[])
AddResources(IEnumerable<ManagedResource>)
AddSyntaxTrees(SyntaxTree[])
AddSyntaxTrees(IEnumerable<SyntaxTree>)
AddSyntaxTreeTransformations(SyntaxTreeTransformation[])
AddSyntaxTreeTransformations(IEnumerable<SyntaxTreeTransformation>)
LoadReferencedAssembly(IAssemblySymbol)
RegisterDiagnosticFilter(SuppressionDescriptor, Action<DiagnosticFilteringRequest>)

Registers a delegate that can suppress a diagnostic.

ReplaceSyntaxTree(SyntaxTree, SyntaxTree)
ReportDiagnostic(Diagnostic)

Adds a Diagnostic to the user's compilation.