Version

AddDiagnostic Method

Gets a modified tree with diagnostic information attached to the specified node.
Syntax
'Declaration
 
Public Function AddDiagnostic( _
   ByVal node As SyntaxNode, _
   ByVal diagnostic As Diagnostic _
) As SyntaxTree
public SyntaxTree AddDiagnostic( 
   SyntaxNode node,
   Diagnostic diagnostic
)

Parameters

node
The node to which the diagnostic information should be attached.
diagnostic
The diagnostic information which should be attached.

Return Value

The new SyntaxTree containing the diagnostic information.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionOccurs when node is null.
System.ArgumentNullExceptionOccurs when diagnostic 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. Diagnostics 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 have errors associated, the calls can be chained:

            var newTree = originalTree.AddDiagnostic(node1, diagnostic1).AddDiagnostic(node2, diagnostic2);
            
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 AddDiagnostic. In this case, the logically equivalent node in the modified tree is associated with diagnostic2 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 7, 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