Delen via


SemanticModel.GetMethodBodyDiagnostics Method

Definition

Get all of the method body and initializer errors within the syntax tree associated with this object. Does not get errors involving incorrect syntax or declarations.

public abstract System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Diagnostic> GetMethodBodyDiagnostics (Microsoft.CodeAnalysis.Text.TextSpan? span = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetMethodBodyDiagnostics : Nullable<Microsoft.CodeAnalysis.Text.TextSpan> * System.Threading.CancellationToken -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Diagnostic>
Public MustOverride Function GetMethodBodyDiagnostics (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

The method body errors for a syntax tree are not cached. The first time this method is called, all method bodies are analyzed for diagnostics. Calling this a second time will repeat this work.

Applies to