'Declaration Public Function AddDiagnostic( _ ByVal node As SyntaxNode, _ ByVal diagnostic As Diagnostic _ ) As SyntaxTree
public SyntaxTree AddDiagnostic( SyntaxNode node, Diagnostic diagnostic )
Exception | Description |
---|---|
System.ArgumentNullException | Occurs when node is null. |
System.ArgumentNullException | Occurs when diagnostic is null. |
System.ArgumentException | Occurs when the Infragistics.Documents.TextDocumentSnapshot of node does not match the Snapshot of the SyntaxTree. |
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.
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