IniSyntaxTree Class

A parsed INI document.

public sealed class IniSyntaxTree : SyntaxTree

Remarks

Parsing never throws and never gives up: whatever the text says, the tree reproduces it exactly, and anything wrong with it is reported through IniSyntaxTree.GetDiagnostics.

Example

var tree = IniSyntaxTree.ParseText("[server]\nport = 8080\n");
var port = tree.GetRoot().GetValue("server", "port");
Assert.Equal("8080", port);
Inheritance
SyntaxTree IniSyntaxTree

Properties

NameDescription
FilePath
OptionsGets the options the text was parsed with.
public override string? FilePath { get; }

Property value

string?

No documentation is available.

Gets the options the text was parsed with.

public IniParseOptions Options { get; }

Property value

IniParseOptions

Methods

NameDescription
Create(IniDocumentSyntax, IniParseOptions?, string?)Creates a tree over root, taking its text from the root itself.
Create(IniDocumentSyntax, string?)Creates a tree over root, taking its text and its options from the root itself.
GetChanges(IniSyntaxTree)Describes how oldTree would have to change to become this one.
GetDiagnostics()Gets every diagnostic in the tree, in source order.
GetRoot()Gets the root of the tree.
GetText()
IsEquivalentTo(IniSyntaxTree?)Determines whether the two trees have the same structure and text, and are read with equal options.
IsEquivalentTo(SyntaxTree?)Determines whether the two trees have the same structure and text, and are read with equal options.
ParseText(SourceText, IniParseOptions?, string?)Parses text.
ParseText(SourceText, string?)Parses text with IniParseOptions.Default.
ParseText(string, IniParseOptions?, string?)Parses text.
ParseText(string, string?)Parses text with IniParseOptions.Default.
WithChangedText(SourceText)Returns a tree over newText, parsed with the same options.
WithChanges(TextChange[])Returns a tree over this text with changes applied.
WithChanges(IEnumerable<TextChange>)Returns a tree over this text with changes applied.
WithRoot(IniDocumentSyntax)Returns a tree whose root is root, read with the options of root.

Create overloads

Create(IniDocumentSyntax, IniParseOptions?, string?)

IniSyntaxTree.cs

Creates a tree over root, taking its text from the root itself.

public static IniSyntaxTree Create(IniDocumentSyntax root, IniParseOptions? options, string? path = null)
Parameters
root IniDocumentSyntax
The root of the tree.
options IniParseOptions?
The options, or null for the IniDocumentSyntax.Options of root.
path string?
Where the text came from, for the diagnostics to refer to.
Returns

IniSyntaxTree

Exceptions
ArgumentNullException
root is null.
Remarks

When options are those of root, the diagnostics are those it carries and the text is not parsed again. Other options read the text differently, so the text of root is parsed again with them, and the tree has the nodes and diagnostics they give; the annotations of root are not carried over then.

Create(IniDocumentSyntax, string?)

IniSyntaxTree.cs

Creates a tree over root, taking its text and its options from the root itself.

public static IniSyntaxTree Create(IniDocumentSyntax root, string? path = null)
Parameters
root IniDocumentSyntax
path string?
Returns

IniSyntaxTree

Exceptions
ArgumentNullException
root is null.
Remarks

The diagnostics are those root carries; the text is not parsed again.

GetChanges(IniSyntaxTree)

IniSyntaxTree.cs

Describes how oldTree would have to change to become this one.

public IReadOnlyList<TextChange> GetChanges(IniSyntaxTree oldTree)

Parameters

oldTree IniSyntaxTree

Returns

IReadOnlyList<TextChange>

Exceptions

ArgumentNullException
oldTree is null.

GetDiagnostics()

IniSyntaxTree.cs

Gets every diagnostic in the tree, in source order.

public override IReadOnlyList<Diagnostic> GetDiagnostics()

Gets the root of the tree.

public IniDocumentSyntax GetRoot()
public override SourceText GetText()

Returns

SourceText

No documentation is available.

IsEquivalentTo overloads

IsEquivalentTo(IniSyntaxTree?)

IniSyntaxTree.cs

Determines whether the two trees have the same structure and text, and are read with equal options.

public bool IsEquivalentTo(IniSyntaxTree? other)
Parameters
other IniSyntaxTree?
Returns

bool

Remarks

Trees read with different options can have the same text and structure, but not the same values.

IsEquivalentTo(SyntaxTree?)

IniSyntaxTree.cs

Determines whether the two trees have the same structure and text, and are read with equal options.

public override bool IsEquivalentTo(SyntaxTree? other)
Parameters
other SyntaxTree?
Returns

bool

Remarks

Trees read with different options can have the same text and structure, but not the same values.

ParseText overloads

ParseText(SourceText, IniParseOptions?, string?)

IniSyntaxTree.cs

Parses text.

public static IniSyntaxTree ParseText(SourceText text, IniParseOptions? options, string? path = null)
Parameters
text SourceText
options IniParseOptions?
path string?
Returns

IniSyntaxTree

Exceptions
ArgumentNullException
text is null.

ParseText(SourceText, string?)

IniSyntaxTree.cs

Parses text with IniParseOptions.Default.

public static IniSyntaxTree ParseText(SourceText text, string? path = null)
Parameters
text SourceText
path string?
Returns

IniSyntaxTree

Exceptions
ArgumentNullException
text is null.

ParseText(string, IniParseOptions?, string?)

IniSyntaxTree.cs

Parses text.

public static IniSyntaxTree ParseText(string text, IniParseOptions? options, string? path = null)
Parameters
text string
The INI document to read.
options IniParseOptions?
How to read it, or null for IniParseOptions.Default.
path string?
Where the text came from, for the diagnostics to refer to.
Returns

IniSyntaxTree

Exceptions
ArgumentNullException
text is null.

ParseText(string, string?)

IniSyntaxTree.cs

Parses text with IniParseOptions.Default.

public static IniSyntaxTree ParseText(string text, string? path = null)
Parameters
text string
The INI document to read.
path string?
Where the text came from, for the diagnostics to refer to.
Returns

IniSyntaxTree

Exceptions
ArgumentNullException
text is null.

WithChangedText(SourceText)

IniSyntaxTree.cs

Returns a tree over newText, parsed with the same options.

public IniSyntaxTree WithChangedText(SourceText newText)

Parameters

newText SourceText

Returns

IniSyntaxTree

Exceptions

ArgumentNullException
newText is null.

WithChanges overloads

WithChanges(TextChange[])

IniSyntaxTree.cs

Returns a tree over this text with changes applied.

public IniSyntaxTree WithChanges(params TextChange[] changes)
Parameters
changes TextChange[]
Returns

IniSyntaxTree

Exceptions
ArgumentNullException
changes is null.

WithChanges(IEnumerable<TextChange>)

IniSyntaxTree.cs

Returns a tree over this text with changes applied.

public IniSyntaxTree WithChanges(IEnumerable<TextChange> changes)
Parameters
changes IEnumerable<TextChange>
Returns

IniSyntaxTree

Exceptions
ArgumentNullException
changes is null.

WithRoot(IniDocumentSyntax)

IniSyntaxTree.cs

Returns a tree whose root is root, read with the options of root.

public IniSyntaxTree WithRoot(IniDocumentSyntax root)

Parameters

root IniDocumentSyntax

Returns

IniSyntaxTree

Exceptions

ArgumentNullException
root is null.