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(params SyntaxTree[]), ReplaceSyntaxTree(SyntaxTree, SyntaxTree) or AddResources(params 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

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(params ManagedResource[])
AddResources(IEnumerable<ManagedResource>)
AddSyntaxTreeTransformations(params SyntaxTreeTransformation[])
AddSyntaxTreeTransformations(IEnumerable<SyntaxTreeTransformation>)
AddSyntaxTrees(params SyntaxTree[])
AddSyntaxTrees(IEnumerable<SyntaxTree>)
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.