AnalysisContext Class

Definition

Context for initializing an analyzer. Analyzer initialization can use an AnalysisContext to register actions to be executed at any of:

  • compilation start,
  • compilation end,
  • completion of parsing a code document,
  • completion of semantic analysis of a code document,
  • completion of semantic analysis of a symbol,
  • start of semantic analysis of a method body or an expression appearing outside a method body,
  • completion of semantic analysis of a method body or an expression appearing outside a method body, or
  • completion of semantic analysis of a syntax node.
public ref class AnalysisContext abstract
public abstract class AnalysisContext
type AnalysisContext = class
Public MustInherit Class AnalysisContext
Inheritance
AnalysisContext

Constructors

AnalysisContext()

Methods

ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags)

Configure analysis mode of generated code for this analyzer. Non-configured analyzers will default to an appropriate default mode for generated code. It is recommended for the analyzer to invoke this API with the required GeneratedCodeAnalysisFlags setting.

EnableConcurrentExecution()

Enable concurrent execution of analyzer actions registered by this analyzer. An analyzer that registers for concurrent execution can have better performance than a non-concurrent analyzer. However, such an analyzer must ensure that its actions can execute correctly in parallel.

RegisterAdditionalFileAction(Action<AdditionalFileAnalysisContext>)

Register an action to be executed for each non-code document. An additional file action reports Diagnostics about the AdditionalText of a document.

RegisterCodeBlockAction(Action<CodeBlockAnalysisContext>)

Register an action to be executed after semantic analysis of a method body or an expression appearing outside a method body. A code block action reports Diagnostics about code blocks.

RegisterCodeBlockStartAction<TLanguageKindEnum>(Action<CodeBlockStartAnalysisContext<TLanguageKindEnum>>)

Register an action to be executed at the start of semantic analysis of a method body or an expression appearing outside a method body. A code block start action can register other actions and/or collect state information to be used in diagnostic analysis, but cannot itself report any Diagnostics.

RegisterCompilationAction(Action<CompilationAnalysisContext>)

Register an action to be executed for a complete compilation. A compilation action reports Diagnostics about the Compilation.

RegisterCompilationStartAction(Action<CompilationStartAnalysisContext>)

Register an action to be executed at compilation start. A compilation start action can register other actions and/or collect state information to be used in diagnostic analysis, but cannot itself report any Diagnostics.

RegisterOperationAction(Action<OperationAnalysisContext>, ImmutableArray<OperationKind>)

Register an action to be executed at completion of semantic analysis of an IOperation with an appropriate Kind. An operation action can report Diagnostics about IOperations, and can also collect state information to be used by other operation actions or code block end actions.

RegisterOperationAction(Action<OperationAnalysisContext>, OperationKind[])

Register an action to be executed at completion of semantic analysis of an IOperation with an appropriate Kind. An operation action can report Diagnostics about IOperations, and can also collect state information to be used by other operation actions or code block end actions.

RegisterOperationBlockAction(Action<OperationBlockAnalysisContext>)

Register an action to be executed after semantic analysis of a method body or an expression appearing outside a method body. An operation block action reports Diagnostics about operation blocks.

RegisterOperationBlockStartAction(Action<OperationBlockStartAnalysisContext>)

Register an action to be executed at the start of semantic analysis of a method body or an expression appearing outside a method body. An operation block start action can register other actions and/or collect state information to be used in diagnostic analysis, but cannot itself report any Diagnostics.

RegisterSemanticModelAction(Action<SemanticModelAnalysisContext>)

Register an action to be executed at completion of semantic analysis of a document, which will operate on the SemanticModel of the document. A semantic model action reports Diagnostics about the model.

RegisterSymbolAction(Action<SymbolAnalysisContext>, ImmutableArray<SymbolKind>)

Register an action to be executed at completion of semantic analysis of an ISymbol with an appropriate Kind. A symbol action reports Diagnostics about ISymbols.

RegisterSymbolAction(Action<SymbolAnalysisContext>, SymbolKind[])

Register an action to be executed at completion of semantic analysis of an ISymbol with an appropriate Kind. A symbol action reports Diagnostics about ISymbols.

RegisterSymbolStartAction(Action<SymbolStartAnalysisContext>, SymbolKind)

Register an action to be executed at start of semantic analysis of an ISymbol and its members with an appropriate Kind.

RegisterSyntaxNodeAction<TLanguageKindEnum>(Action<SyntaxNodeAnalysisContext>, ImmutableArray<TLanguageKindEnum>)

Register an action to be executed at completion of semantic analysis of a SyntaxNode with an appropriate Kind. A syntax node action can report Diagnostics about SyntaxNodes, and can also collect state information to be used by other syntax node actions or code block end actions.

RegisterSyntaxNodeAction<TLanguageKindEnum>(Action<SyntaxNodeAnalysisContext>, TLanguageKindEnum[])

Register an action to be executed at completion of semantic analysis of a SyntaxNode with an appropriate Kind. A syntax node action can report Diagnostics about SyntaxNodes, and can also collect state information to be used by other syntax node actions or code block end actions.

RegisterSyntaxTreeAction(Action<SyntaxTreeAnalysisContext>)

Register an action to be executed at completion of parsing of a code document. A syntax tree action reports Diagnostics about the SyntaxTree of a document.

TryGetValue<TValue>(AdditionalText, AdditionalTextValueProvider<TValue>, TValue)

Attempts to compute or get the cached value provided by the given valueProvider for the given text. Note that the pair {valueProvider, text} acts as the key. Reusing the same valueProvider instance across analyzer actions and/or analyzer instances can improve the overall analyzer performance by avoiding recomputation of the values.

TryGetValue<TValue>(SourceText, SourceTextValueProvider<TValue>, TValue)

Attempts to compute or get the cached value provided by the given valueProvider for the given text. Note that the pair {valueProvider, text} acts as the key. Reusing the same valueProvider instance across analyzer actions and/or analyzer instances can improve the overall analyzer performance by avoiding recomputation of the values.

Applies to