MetalamaAPI documentationAdvanced APIMetalama.​CompilerTransformer­Context
Open sandboxFocus

TransformerContext Class

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 the original Compilation. Transformers typically modify the compilation by using methods on this TransformerContext, though such modifications are not reflection on this property.

Options

Gets options of the current TransformerContext.

Resources

Gets the list of managed resources.

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.