SemanticModel.GetDiagnostics Method

Definition

Get all the errors within the syntax tree associated with this object. Includes errors involving compiling method bodies or initializers, in addition to the errors returned by GetDeclarationDiagnostics.

public abstract System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Diagnostic> GetDiagnostics (Microsoft.CodeAnalysis.Text.TextSpan? span = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetDiagnostics : Nullable<Microsoft.CodeAnalysis.Text.TextSpan> * System.Threading.CancellationToken -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Diagnostic>
Public MustOverride Function GetDiagnostics (Optional span As Nullable(Of TextSpan) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ImmutableArray(Of Diagnostic)

Parameters

span
Nullable<TextSpan>

Optional span within the syntax tree for which to get diagnostics. If no argument is specified, then diagnostics for the entire tree are returned.

cancellationToken
CancellationToken

A cancellation token that can be used to cancel the process of obtaining the diagnostics.

Returns

Remarks

Because this method must semantically bind all method bodies and initializers to check for diagnostics, it may take a significant amount of time. Unlike GetDeclarationDiagnostics, diagnostics for method bodies and initializers are not cached, any semantic information used to obtain the diagnostics is discarded.

Applies to