CSharpSyntaxTree Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The parsed representation of a C# source document.
public ref class CSharpSyntaxTree abstract : Microsoft::CodeAnalysis::SyntaxTree
public abstract class CSharpSyntaxTree : Microsoft.CodeAnalysis.SyntaxTree
type CSharpSyntaxTree = class
inherit SyntaxTree
Public MustInherit Class CSharpSyntaxTree
Inherits SyntaxTree
- Inheritance
Constructors
CSharpSyntaxTree() |
Properties
DiagnosticOptions |
Obsolete.
Option to specify custom behavior for each warning in this tree. (Inherited from SyntaxTree) |
Encoding |
The text encoding of the source document. (Inherited from SyntaxTree) |
FilePath |
The path of the source document file. (Inherited from SyntaxTree) |
HasCompilationUnitRoot |
Returns true if this syntax tree has a root with SyntaxKind "CompilationUnit". (Inherited from SyntaxTree) |
Length |
The length of the text of the syntax tree. (Inherited from SyntaxTree) |
Options |
The options used by the parser to produce the syntax tree. |
OptionsCore |
Methods
CloneNodeAsRoot<T>(T) |
Produces a clone of a CSharpSyntaxNode which will have current syntax tree as its parent. Caller must guarantee that if the same instance of CSharpSyntaxNode makes multiple calls to this function, only one result is observable. |
Create(CSharpSyntaxNode, CSharpParseOptions, String, Encoding) |
Creates a new syntax tree from a syntax node. |
Create(CSharpSyntaxNode, CSharpParseOptions, String, Encoding, ImmutableDictionary<String,ReportDiagnostic>) |
Obsolete.
Creates a new syntax tree from a syntax node. |
Create(CSharpSyntaxNode, CSharpParseOptions, String, Encoding, ImmutableDictionary<String,ReportDiagnostic>, Nullable<Boolean>) |
Obsolete.
Creates a new syntax tree from a syntax node. |
GetChangedSpans(SyntaxTree) |
Produces a pessimistic list of spans that denote the regions of text in this tree that are changed from the text of the old tree. |
GetChanges(SyntaxTree) |
Gets a list of text changes that when applied to the old tree produce this tree. |
GetCompilationUnitRoot(CancellationToken) |
Gets the root of the syntax tree statically typed as CompilationUnitSyntax. |
GetDiagnostics(CancellationToken) |
Gets a list of all the diagnostics in the syntax tree. |
GetDiagnostics(SyntaxNode) |
Gets a list of all the diagnostics in the sub tree that has the specified node as its root. |
GetDiagnostics(SyntaxNodeOrToken) |
Gets a list of all the diagnostics in either the sub tree that has the specified node as its root or associated with the token and its related trivia. |
GetDiagnostics(SyntaxToken) |
Gets a list of all the diagnostics associated with the token and any related trivia. |
GetDiagnostics(SyntaxTrivia) |
Gets a list of all the diagnostics associated with the trivia. |
GetLineMappings(CancellationToken) |
Returns empty sequence if there are no line mapping directives in the tree. Otherwise, returns a sequence of pairs of spans: each describing a mapping of a span of the tree between two consecutive #line directives. If the first directive is not on the first line the first pair describes mapping of the span preceding the first directive. The last pair of the sequence describes mapping of the span following the last #line directive. |
GetLineMappings(CancellationToken) |
Returns empty sequence if there are no line mapping directives in the tree. Otherwise, returns a sequence of pairs of spans: each describing a mapping of a span of the tree between two consecutive #line directives. If the first directive is not on the first line the first pair describes mapping of the span preceding the first directive. The last pair of the sequence describes mapping of the span following the last #line directive. (Inherited from SyntaxTree) |
GetLineSpan(TextSpan, CancellationToken) |
Gets the location in terms of path, line and column for a given span. |
GetLineVisibility(Int32, CancellationToken) |
Returns the visibility for the line at the given position. |
GetLocation(TextSpan) |
Gets a Location for the specified text |
GetMappedLineSpan(TextSpan, CancellationToken) |
Gets the location in terms of path, line and column after applying source line mapping directives ( |
GetReference(SyntaxNode) |
Gets a SyntaxReference for a specified syntax node. SyntaxReferences can be used to regain access to a syntax node without keeping the entire tree and source text in memory. (Inherited from SyntaxTree) |
GetRoot(CancellationToken) |
Gets the root node of the syntax tree. |
GetRootAsync(CancellationToken) |
Gets the root node of the syntax tree asynchronously. |
GetRootAsyncCore(CancellationToken) | |
GetRootCore(CancellationToken) | |
GetText(CancellationToken) |
Gets the text of the source document. (Inherited from SyntaxTree) |
GetTextAsync(CancellationToken) |
Gets the text of the source document asynchronously. (Inherited from SyntaxTree) |
HasHiddenRegions() |
Gets a boolean value indicating whether there are any hidden regions in the tree. |
IsEquivalentTo(SyntaxTree, Boolean) |
Determines if two trees are the same, disregarding trivia differences. |
ParseText(SourceText, CSharpParseOptions, String, CancellationToken) |
Produces a syntax tree by parsing the source text. |
ParseText(SourceText, CSharpParseOptions, String, ImmutableDictionary<String,ReportDiagnostic>, CancellationToken) |
Obsolete.
Produces a syntax tree by parsing the source text. |
ParseText(SourceText, CSharpParseOptions, String, ImmutableDictionary<String,ReportDiagnostic>, Nullable<Boolean>, CancellationToken) |
Obsolete.
Produces a syntax tree by parsing the source text. |
ParseText(String, CSharpParseOptions, String, Encoding, CancellationToken) |
Produces a syntax tree by parsing the source text. |
ParseText(String, CSharpParseOptions, String, Encoding, ImmutableDictionary<String,ReportDiagnostic>, CancellationToken) |
Obsolete.
Produces a syntax tree by parsing the source text. |
ParseText(String, CSharpParseOptions, String, Encoding, ImmutableDictionary<String,ReportDiagnostic>, Nullable<Boolean>, CancellationToken) |
Obsolete.
Produces a syntax tree by parsing the source text. |
ToString() |
Returns a String that represents the entire source text of this SyntaxTree. (Inherited from SyntaxTree) |
TryGetRoot(CSharpSyntaxNode) |
Gets the root node of the syntax tree if it is already available. |
TryGetRoot(SyntaxNode) |
Gets the root of the syntax tree if it is available. (Inherited from SyntaxTree) |
TryGetRootCore(SyntaxNode) | |
TryGetText(SourceText) |
Gets the syntax tree's text if it is available. (Inherited from SyntaxTree) |
WithChangedText(SourceText) |
Creates a new syntax based off this tree using a new source text. |
WithDiagnosticOptions(ImmutableDictionary<String,ReportDiagnostic>) |
Obsolete.
Returns a new tree whose DiagnosticOptions are the specified value and other properties are copied from the current tree. (Inherited from SyntaxTree) |
WithFilePath(String) |
Returns a new tree whose FilePath is the specified node and other properties are copied from the current tree. (Inherited from SyntaxTree) |
WithRootAndOptions(SyntaxNode, ParseOptions) |
Returns a new tree whose root and options are as specified and other properties are copied from the current tree. (Inherited from SyntaxTree) |
Extension Methods
GetCompilationUnitRoot(SyntaxTree, CancellationToken) | |
GetCompilationUnitRoot(SyntaxTree) |
Gets the root CompilationUnitSyntax for a specified SyntaxTree. |