다음을 통해 공유


SyntaxNode.CopyAnnotationsTo<T>(T) Method

Definition

Copies all SyntaxAnnotations, if any, from this SyntaxNode instance and attaches them to a new instance based on node.

public:
generic <typename T>
 where T : Microsoft::CodeAnalysis::SyntaxNode T CopyAnnotationsTo(T node);
public T CopyAnnotationsTo<T> (T node) where T : Microsoft.CodeAnalysis.SyntaxNode;
public T? CopyAnnotationsTo<T> (T? node) where T : Microsoft.CodeAnalysis.SyntaxNode;
member this.CopyAnnotationsTo : 'T -> 'T (requires 'T :> Microsoft.CodeAnalysis.SyntaxNode)
Public Function CopyAnnotationsTo(Of T As SyntaxNode) (node As T) As T

Type Parameters

T

Parameters

node
T

Returns

T

Remarks

If no annotations are copied, just returns node.

It can also be used manually to preserve annotations in a more complex tree modification, even if the type of a node changes.

Applies to