Microsoft.CodeAnalysis.CSharp by Microsoft

<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.8.2" />

.NET API 4,681,136 bytes

 CSharpSyntaxTree

public abstract class CSharpSyntaxTree : SyntaxTree
The parsed representation of a C# source document.
public abstract CSharpParseOptions Options { get; }

The options used by the parser to produce the syntax tree.

protected CSharpSyntaxTree()

public static SyntaxTree Create(CSharpSyntaxNode root, CSharpParseOptions options = null, string path = "", Encoding encoding = null)

Creates a new syntax tree from a syntax node.

public static SyntaxTree ParseText(string text, CSharpParseOptions options = null, string path = "", Encoding encoding = null, CancellationToken cancellationToken = null)

Produces a syntax tree by parsing the source text.

public static SyntaxTree ParseText(SourceText text, CSharpParseOptions options = null, string path = "", CancellationToken cancellationToken = null)

Produces a syntax tree by parsing the source text.

protected T CloneNodeAsRoot<T>(T node)

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.

Gets the root of the syntax tree statically typed as CompilationUnitSyntax.

public abstract CSharpSyntaxNode GetRoot(CancellationToken cancellationToken = null)

Gets the root node of the syntax tree.

public virtual Task<CSharpSyntaxNode> GetRootAsync(CancellationToken cancellationToken = null)

Gets the root node of the syntax tree asynchronously.

public abstract bool TryGetRoot(out CSharpSyntaxNode root)

Gets the root node of the syntax tree if it is already available.