Version

AddAnnotation Method

Gets a modified tree with an annotation attached to the specified node.
Syntax
'Declaration
 
Public Function AddAnnotation( _
   ByVal node As SyntaxNode, _
   ByVal annotation As SyntaxAnnotation _
) As SyntaxTree
public SyntaxTree AddAnnotation( 
   SyntaxNode node,
   SyntaxAnnotation annotation
)

Parameters

node
The node to which the annotation should be attached.
annotation
The annotation to add to the node.

Return Value

The new SyntaxTree containing the annotation.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionOccurs when node is null.
System.ArgumentNullExceptionOccurs when annotation is null.
System.ArgumentExceptionOccurs when the Infragistics.Documents.TextDocumentSnapshot of node does not match the Snapshot of the SyntaxTree.
Remarks

If a syntax tree has diagnostics or annotations attached to a node within it, the resulting syntax tree is an equivalent syntax tree. It represents the same structure, but has additional information associated. An annotation can be attached to any node in the current tree or any tree which is equivalent to the current tree. For example, if two nodes need to be annotated, the calls can be chained:

            var newTree = originalTree.AddAnnotation(node1, annotation1).AddAnnotation(node2, annotation2);
            
The two nodes were obtained from the original tree, but node2 is annotated on the modified tree which is returned from the first call to AddAnnotation. In this case, the logically equivalent node in the modified tree is annotated with annotation2 and a newly modified tree is returned and stored in newTree.

Trees can be tested for equivalence by seeing if their Snapshot values are the same.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also