Formatter.Format Method

Definition

Overloads

Format(SyntaxNode, Workspace, OptionSet, CancellationToken)

Formats the whitespace of a syntax tree.

Format(SyntaxNode, SyntaxAnnotation, Workspace, OptionSet, CancellationToken)

Formats the whitespace in areas of a syntax tree corresponding to annotated nodes.

Format(SyntaxNode, TextSpan, Workspace, OptionSet, CancellationToken)

Formats the whitespace in areas of a syntax tree identified by a span.

Format(SyntaxNode, IEnumerable<TextSpan>, Workspace, OptionSet, CancellationToken)

Formats the whitespace in areas of a syntax tree identified by multiple non-overlapping spans.

Format(SyntaxNode, Workspace, OptionSet, CancellationToken)

Formats the whitespace of a syntax tree.

public static Microsoft.CodeAnalysis.SyntaxNode Format (Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.Workspace workspace, Microsoft.CodeAnalysis.Options.OptionSet options = null, System.Threading.CancellationToken cancellationToken = null);
static member Format : Microsoft.CodeAnalysis.SyntaxNode * Microsoft.CodeAnalysis.Workspace * Microsoft.CodeAnalysis.Options.OptionSet * System.Threading.CancellationToken -> Microsoft.CodeAnalysis.SyntaxNode

Parameters

node
SyntaxNode

The root node of a syntax tree to format.

workspace
Workspace

A workspace used to give the formatting context.

options
OptionSet

An optional set of formatting options. If these options are not supplied the current set of options from the workspace will be used.

cancellationToken
CancellationToken

An optional cancellation token.

Returns

The formatted tree's root node.

Format(SyntaxNode, SyntaxAnnotation, Workspace, OptionSet, CancellationToken)

Formats the whitespace in areas of a syntax tree corresponding to annotated nodes.

public static Microsoft.CodeAnalysis.SyntaxNode Format (Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.SyntaxAnnotation annotation, Microsoft.CodeAnalysis.Workspace workspace, Microsoft.CodeAnalysis.Options.OptionSet options = null, System.Threading.CancellationToken cancellationToken = null);
static member Format : Microsoft.CodeAnalysis.SyntaxNode * Microsoft.CodeAnalysis.SyntaxAnnotation * Microsoft.CodeAnalysis.Workspace * Microsoft.CodeAnalysis.Options.OptionSet * System.Threading.CancellationToken -> Microsoft.CodeAnalysis.SyntaxNode

Parameters

node
SyntaxNode

The root node of a syntax tree to format.

annotation
SyntaxAnnotation

The annotation used to find nodes to identify spans to format.

workspace
Workspace

A workspace used to give the formatting context.

options
OptionSet

An optional set of formatting options. If these options are not supplied the current set of options from the workspace will be used.

cancellationToken
CancellationToken

An optional cancellation token.

Returns

The formatted tree's root node.

Format(SyntaxNode, TextSpan, Workspace, OptionSet, CancellationToken)

Formats the whitespace in areas of a syntax tree identified by a span.

public static Microsoft.CodeAnalysis.SyntaxNode Format (Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.Text.TextSpan span, Microsoft.CodeAnalysis.Workspace workspace, Microsoft.CodeAnalysis.Options.OptionSet options = null, System.Threading.CancellationToken cancellationToken = null);
static member Format : Microsoft.CodeAnalysis.SyntaxNode * Microsoft.CodeAnalysis.Text.TextSpan * Microsoft.CodeAnalysis.Workspace * Microsoft.CodeAnalysis.Options.OptionSet * System.Threading.CancellationToken -> Microsoft.CodeAnalysis.SyntaxNode

Parameters

node
SyntaxNode

The root node of a syntax tree to format.

span
TextSpan

The span within the node's full span to format.

workspace
Workspace

A workspace used to give the formatting context.

options
OptionSet

An optional set of formatting options. If these options are not supplied the current set of options from the workspace will be used.

cancellationToken
CancellationToken

An optional cancellation token.

Returns

The formatted tree's root node.

Format(SyntaxNode, IEnumerable<TextSpan>, Workspace, OptionSet, CancellationToken)

Formats the whitespace in areas of a syntax tree identified by multiple non-overlapping spans.

public static Microsoft.CodeAnalysis.SyntaxNode Format (Microsoft.CodeAnalysis.SyntaxNode node, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.Text.TextSpan> spans, Microsoft.CodeAnalysis.Workspace workspace, Microsoft.CodeAnalysis.Options.OptionSet options = null, System.Threading.CancellationToken cancellationToken = null);
static member Format : Microsoft.CodeAnalysis.SyntaxNode * seq<Microsoft.CodeAnalysis.Text.TextSpan> * Microsoft.CodeAnalysis.Workspace * Microsoft.CodeAnalysis.Options.OptionSet * System.Threading.CancellationToken -> Microsoft.CodeAnalysis.SyntaxNode

Parameters

node
SyntaxNode

The root node of a syntax tree to format.

spans
IEnumerable<TextSpan>

The spans within the node's full span to format.

workspace
Workspace

A workspace used to give the formatting context.

options
OptionSet

An optional set of formatting options. If these options are not supplied the current set of options from the workspace will be used.

cancellationToken
CancellationToken

An optional cancellation token.

Returns

The formatted tree's root node.

Applies to