SyntaxNodeExtensions.ReplaceSyntax<TRoot> Method

Definition

Creates a new tree of nodes with the specified nodes, tokens and trivia replaced.

C#
public static TRoot ReplaceSyntax<TRoot>(this TRoot root, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxNode> nodes, Func<Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.SyntaxNode> computeReplacementNode, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxToken> tokens, Func<Microsoft.CodeAnalysis.SyntaxToken,Microsoft.CodeAnalysis.SyntaxToken,Microsoft.CodeAnalysis.SyntaxToken> computeReplacementToken, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxTrivia> trivia, Func<Microsoft.CodeAnalysis.SyntaxTrivia,Microsoft.CodeAnalysis.SyntaxTrivia,Microsoft.CodeAnalysis.SyntaxTrivia> computeReplacementTrivia) where TRoot : Microsoft.CodeAnalysis.SyntaxNode;
C#
public static TRoot ReplaceSyntax<TRoot>(this TRoot root, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxNode>? nodes, Func<Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.SyntaxNode>? computeReplacementNode, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxToken>? tokens, Func<Microsoft.CodeAnalysis.SyntaxToken,Microsoft.CodeAnalysis.SyntaxToken,Microsoft.CodeAnalysis.SyntaxToken>? computeReplacementToken, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.SyntaxTrivia>? trivia, Func<Microsoft.CodeAnalysis.SyntaxTrivia,Microsoft.CodeAnalysis.SyntaxTrivia,Microsoft.CodeAnalysis.SyntaxTrivia>? computeReplacementTrivia) where TRoot : Microsoft.CodeAnalysis.SyntaxNode;

Type Parameters

TRoot

The type of the root node.

Parameters

root
TRoot

The root node of the tree of nodes.

nodes
IEnumerable<SyntaxNode>

The nodes to be replaced.

computeReplacementNode
Func<SyntaxNode,SyntaxNode,SyntaxNode>

A function that computes a replacement node for the argument nodes. The first argument is the original node. The second argument is the same node potentially rewritten with replaced descendants.

tokens
IEnumerable<SyntaxToken>

The tokens to be replaced.

computeReplacementToken
Func<SyntaxToken,SyntaxToken,SyntaxToken>

A function that computes a replacement token for the argument tokens. The first argument is the original token. The second argument is the same token potentially rewritten with replaced trivia.

trivia
IEnumerable<SyntaxTrivia>

The trivia to be replaced.

computeReplacementTrivia
Func<SyntaxTrivia,SyntaxTrivia,SyntaxTrivia>

A function that computes replacement trivia for the specified arguments. The first argument is the original trivia. The second argument is the same trivia with potentially rewritten sub structure.

Returns

TRoot

Applies to

Ürün Sürümler
Roslyn 4.2.0, 4.3.0, 4.4.0, 4.5.0, 4.6.0, 4.7.0, 4.8.0, 4.9.2, 3.0.0, 3.1.0, 3.2.0, 3.2.1, 3.3.1, 3.4.0, 3.5.0, 3.6.0, 3.7.0, 3.8.0, 3.9.0, 3.10.0, 3.11.0, 4.0.1, 4.1.0, 4.12.2, 4.13.0