Delen via


CompilationWithAnalyzers Class

Definition

public ref class CompilationWithAnalyzers
public class CompilationWithAnalyzers
type CompilationWithAnalyzers = class
Public Class CompilationWithAnalyzers
Inheritance
CompilationWithAnalyzers

Constructors

CompilationWithAnalyzers(Compilation, ImmutableArray<DiagnosticAnalyzer>, AnalyzerOptions, CancellationToken)
Obsolete.

Creates a new compilation by attaching diagnostic analyzers to an existing compilation.

CompilationWithAnalyzers(Compilation, ImmutableArray<DiagnosticAnalyzer>, AnalyzerOptions)

Creates a new compilation by attaching diagnostic analyzers to an existing compilation.

CompilationWithAnalyzers(Compilation, ImmutableArray<DiagnosticAnalyzer>, CompilationWithAnalyzersOptions)

Creates a new compilation by attaching diagnostic analyzers to an existing compilation.

Properties

AnalysisOptions

Options to configure analyzer execution.

Analyzers

Analyzers to execute on the compilation.

CancellationToken
Obsolete.

An optional cancellation token which can be used to cancel analysis. Note: This token is only used if the API invoked to get diagnostics doesn't provide a cancellation token.

Compilation

Underlying Compilation with a non-null Microsoft.CodeAnalysis.Compilation.EventQueue, used to drive analyzer execution.

Methods

ClearAnalyzerState(ImmutableArray<DiagnosticAnalyzer>)
Obsolete.

This method should be invoked when the analyzer host is disposing off the given analyzers. It clears the cached internal state (supported descriptors, registered actions, exception handlers, etc.) for analyzers.

GetAllDiagnosticsAsync()

Returns all diagnostics produced by compilation and by all Analyzers.

GetAllDiagnosticsAsync(CancellationToken)

Returns all diagnostics produced by compilation and by all Analyzers.

GetAnalysisResultAsync(AdditionalText, CancellationToken)

Returns an AnalysisResult populated with AdditionalFileDiagnostics produced by all Analyzers from analyzing the given additional file. The given file must be part of AdditionalFiles for the AnalysisOptions for this CompilationWithAnalyzers instance. Depending on analyzers' behavior, some diagnostics that would be reported for the file by an analysis of the complete compilation can be absent.

GetAnalysisResultAsync(AdditionalText, ImmutableArray<DiagnosticAnalyzer>, CancellationToken)

Returns an AnalysisResult populated with AdditionalFileDiagnostics produced by given analyzers from analyzing the given additional file. The given file must be part of AdditionalFiles for the AnalysisOptions for this CompilationWithAnalyzers instance. Depending on analyzers' behavior, some diagnostics that would be reported for the file by an analysis of the complete compilation can be absent.

GetAnalysisResultAsync(AdditionalText, Nullable<TextSpan>, CancellationToken)

Returns an AnalysisResult populated with AdditionalFileDiagnostics produced by all Analyzers from analyzing the given additional file, optionally scoped to a filterSpan. The given file must be part of AdditionalFiles for the AnalysisOptions for this CompilationWithAnalyzers instance. Depending on analyzers' behavior, some diagnostics that would be reported for the file by an analysis of the complete compilation can be absent.

GetAnalysisResultAsync(AdditionalText, Nullable<TextSpan>, ImmutableArray<DiagnosticAnalyzer>, CancellationToken)

Returns an AnalysisResult populated with AdditionalFileDiagnostics produced by given analyzers from analyzing the given additional file, optionally scoped to a filterSpan. The given file must be part of AdditionalFiles for the AnalysisOptions for this CompilationWithAnalyzers instance. Depending on analyzers' behavior, some diagnostics that would be reported for the file by an analysis of the complete compilation can be absent.

GetAnalysisResultAsync(CancellationToken)

Executes all Analyzers and returns the corresponding AnalysisResult with all diagnostics and telemetry info.

GetAnalysisResultAsync(ImmutableArray<DiagnosticAnalyzer>, CancellationToken)

Executes the given analyzers and returns the corresponding AnalysisResult with all diagnostics and telemetry info.

GetAnalysisResultAsync(SemanticModel, Nullable<TextSpan>, CancellationToken)

Returns an AnalysisResult populated with SemanticDiagnostics produced by all Analyzers from analyzing the given model, optionally scoped to a filterSpan. Depending on analyzers' behavior, some diagnostics that would be reported for the tree by an analysis of the complete compilation can be absent.

GetAnalysisResultAsync(SemanticModel, Nullable<TextSpan>, ImmutableArray<DiagnosticAnalyzer>, CancellationToken)

Returns an AnalysisResult populated with SemanticDiagnostics produced by the given analyzers from analyzing the given model, optionally scoped to a filterSpan. Depending on analyzers' behavior, some diagnostics that would be reported for the tree by an analysis of the complete compilation can be absent.

GetAnalysisResultAsync(SyntaxTree, CancellationToken)

Returns an AnalysisResult populated with SyntaxDiagnostics produced by all Analyzers from analyzing the given tree. Depending on analyzers' behavior, some diagnostics that would be reported for the tree by an analysis of the complete compilation can be absent.

GetAnalysisResultAsync(SyntaxTree, ImmutableArray<DiagnosticAnalyzer>, CancellationToken)

Returns an AnalysisResult populated with SyntaxDiagnostics produced by given analyzers from analyzing the given tree. Depending on analyzers' behavior, some diagnostics that would be reported for the tree by an analysis of the complete compilation can be absent.

GetAnalysisResultAsync(SyntaxTree, Nullable<TextSpan>, CancellationToken)

Returns an AnalysisResult populated with SyntaxDiagnostics produced by all Analyzers from analyzing the given tree, optionally scoped to a filterSpan. Depending on analyzers' behavior, some diagnostics that would be reported for the tree by an analysis of the complete compilation can be absent.

GetAnalysisResultAsync(SyntaxTree, Nullable<TextSpan>, ImmutableArray<DiagnosticAnalyzer>, CancellationToken)

Returns an AnalysisResult populated with SyntaxDiagnostics produced by given analyzers from analyzing the given tree, optionally scoped to a filterSpan. Depending on analyzers' behavior, some diagnostics that would be reported for the tree by an analysis of the complete compilation can be absent.

GetAnalyzerCompilationDiagnosticsAsync(CancellationToken)
Obsolete.

Returns diagnostics produced by compilation actions of all Analyzers.

GetAnalyzerCompilationDiagnosticsAsync(ImmutableArray<DiagnosticAnalyzer>, CancellationToken)
Obsolete.

Returns diagnostics produced by compilation actions of given analyzers.

GetAnalyzerDiagnosticsAsync()

Returns diagnostics produced by all Analyzers.

GetAnalyzerDiagnosticsAsync(CancellationToken)

Returns diagnostics produced by all Analyzers.

GetAnalyzerDiagnosticsAsync(ImmutableArray<DiagnosticAnalyzer>, CancellationToken)

Returns diagnostics produced by given analyzers.

GetAnalyzerSemanticDiagnosticsAsync(SemanticModel, Nullable<TextSpan>, CancellationToken)

Returns semantic diagnostics produced by all Analyzers from analyzing the given model, optionally scoped to a filterSpan. Depending on analyzers' behavior, some diagnostics that would be reported for the tree by an analysis of the complete compilation can be absent.

GetAnalyzerSemanticDiagnosticsAsync(SemanticModel, Nullable<TextSpan>, ImmutableArray<DiagnosticAnalyzer>, CancellationToken)

Returns semantic diagnostics produced by the given analyzers from analyzing the given model, optionally scoped to a filterSpan. Depending on analyzers' behavior, some diagnostics that would be reported for the tree by an analysis of the complete compilation can be absent.

GetAnalyzerSyntaxDiagnosticsAsync(SyntaxTree, CancellationToken)

Returns syntax diagnostics produced by all Analyzers from analyzing the given tree. Depending on analyzers' behavior, returned diagnostics can have locations outside the tree, and some diagnostics that would be reported for the tree by an analysis of the complete compilation can be absent.

GetAnalyzerSyntaxDiagnosticsAsync(SyntaxTree, ImmutableArray<DiagnosticAnalyzer>, CancellationToken)

Returns syntax diagnostics produced by given analyzers from analyzing the given tree. Depending on analyzers' behavior, returned diagnostics can have locations outside the tree, and some diagnostics that would be reported for the tree by an analysis of the complete compilation can be absent.

GetAnalyzerSyntaxDiagnosticsAsync(SyntaxTree, Nullable<TextSpan>, CancellationToken)

Returns syntax diagnostics produced by all Analyzers from analyzing the given tree, optionally scoped to a filterSpan. Depending on analyzers' behavior, returned diagnostics can have locations outside the tree or filter span, and some diagnostics that would be reported for the tree by an analysis of the complete compilation can be absent.

GetAnalyzerSyntaxDiagnosticsAsync(SyntaxTree, Nullable<TextSpan>, ImmutableArray<DiagnosticAnalyzer>, CancellationToken)

Returns syntax diagnostics produced by given analyzers from analyzing the given tree, optionally scoped to a filterSpan. Depending on analyzers' behavior, returned diagnostics can have locations outside the tree or filter span, and some diagnostics that would be reported for the tree by an analysis of the complete compilation can be absent.

GetAnalyzerTelemetryInfoAsync(DiagnosticAnalyzer, CancellationToken)

Gets telemetry info for the given analyzer, such as count of registered actions, the total execution time (if LogAnalyzerExecutionTime is true), etc.

GetEffectiveDiagnostics(IEnumerable<Diagnostic>, Compilation)

Given a set of compiler or DiagnosticAnalyzer generated diagnostics, returns the effective diagnostics after applying the below filters:

  1. SpecificDiagnosticOptions specified for the given compilation.
  2. GeneralDiagnosticOption specified for the given compilation.
  3. Diagnostic suppression through applied SuppressMessageAttribute.
  4. Pragma directives for the given compilation.
GetEffectiveDiagnostics(ImmutableArray<Diagnostic>, Compilation)

Given a set of compiler or DiagnosticAnalyzer generated diagnostics, returns the effective diagnostics after applying the below filters:

  1. SpecificDiagnosticOptions specified for the given compilation.
  2. GeneralDiagnosticOption specified for the given compilation.
  3. Diagnostic suppression through applied SuppressMessageAttribute.
  4. Pragma directives for the given compilation.
IsDiagnosticAnalyzerSuppressed(DiagnosticAnalyzer, CompilationOptions, Action<Exception,DiagnosticAnalyzer,Diagnostic>)
Obsolete.

Returns true if all the diagnostics that can be produced by this analyzer are suppressed through options.

Applies to