SyntaxFactory Class

Builds TOML nodes, tokens, and trivia.

public static class SyntaxFactory

Remarks

A node built here is not part of any document, so its span starts at zero. Putting it into a tree with SyntaxNodeExtensions.ReplaceNode gives it a real position, without re-reading any text.

The methods that take .NET values write them the way TOML requires: keys are quoted when they cannot be bare, strings are escaped, and floats always read back as floats. The ones that take tokens use them as they are.

Properties

NameDescription
CarriageReturnLineFeedA Windows line break.
LineFeedA Unix line break.
SpaceA single space.
TabA single tab.

CarriageReturnLineFeed

SyntaxFactory.cs

A Windows line break.

public static SyntaxTrivia CarriageReturnLineFeed { get; }

Property value

SyntaxTrivia

A Unix line break.

public static SyntaxTrivia LineFeed { get; }

Property value

SyntaxTrivia

A single space.

public static SyntaxTrivia Space { get; }

Property value

SyntaxTrivia

A single tab.

public static SyntaxTrivia Tab { get; }

Property value

SyntaxTrivia

Methods

NameDescription
AreEquivalent(TomlSyntaxNode?, TomlSyntaxNode?)Determines whether the two nodes have the same structure and text.
BadToken(string)Creates a token holding text the parser could make no sense of.
Comment(string)Creates comment trivia.
EndOfLine(string)Creates a line break: \n or \r\n, the only two TOML has.
Key(SyntaxTokenList)Creates a key from its parts and the dots between them.
Key(string[])Creates a key from the names of its parts, quoting each that cannot be bare.
KeyPart(string)Creates one part of a key: a bare key when name can be one, a basic string otherwise.
List<TNode>()
List<TNode>(IEnumerable<TNode>)
Literal(bool)Creates true or false.
Literal(DateOnly)Creates a local date token, such as 1979-05-27.
Literal(DateTime)Creates a local date-time token, such as 1979-05-27T07:32:00. The kind of value is ignored.
Literal(DateTimeOffset)Creates an offset date-time token, such as 1979-05-27T07:32:00Z.
Literal(double)Creates a float token, written so that it reads back as the same float.
Literal(long)Creates an integer token, written in decimal.
Literal(string)Creates a basic string token holding value, escaped as TOML requires.
Literal(TimeOnly)Creates a local time token, such as 07:32:00.
MissingToken(SyntaxKind)Creates a zero-width token standing in for one the text does not have.
ParseDocument(string, TomlParseOptions?)Parses text and returns its root.
ParseSyntaxTree(string, TomlParseOptions?, string?)Parses text into a tree.
ParseValue(string, TomlParseOptions?)Parses text as a single value, such as [1, 2] or '''literal'''.
SeparatedList<TNode>()
SeparatedList<TNode>(IEnumerable<SyntaxNodeOrToken>)Creates a list from nodes and the separators to put between them.
SeparatedList<TNode>(IEnumerable<TNode>)Creates a list of nodes with a comma and a space between each pair.
SingletonList<TNode>(TNode)
SingletonSeparatedList<TNode>(TNode)
Token(SyntaxTriviaList, SyntaxKind, SyntaxTriviaList)Creates a token whose text is fixed by its kind, with trivia on either side.
Token(SyntaxKind)Creates a token whose text is fixed by its kind, such as a bracket or true.
TokenList()
TokenList(SyntaxToken)
TokenList(SyntaxToken[])
TokenList(IEnumerable<SyntaxToken>)
TomlArray(SeparatedSyntaxList<TomlValueSyntax>)
TomlArray(SyntaxToken, SeparatedSyntaxList<TomlValueSyntax>, SyntaxToken)
TomlArray(TomlValueSyntax[])Creates an array such as [1, 2, 3].
TomlArrayOfTables(string[])Creates an array-of-tables header such as [[products]].
TomlBoolean(SyntaxToken)
TomlBoolean(bool)
TomlDateTime(SyntaxToken)Creates a date, a time, or both, taking the kind of the node from the token.
TomlDateTime(DateOnly)
TomlDateTime(DateTime)
TomlDateTime(DateTimeOffset)
TomlDateTime(TimeOnly)
TomlDocument(SyntaxList<TomlEntrySyntax>, SyntaxToken)Creates a document from entries.
TomlDocument(TomlEntrySyntax[])Creates a document from entries, ending the line of each that does not end its own.
TomlFloat(SyntaxToken)
TomlFloat(double)
TomlInlineTable(SeparatedSyntaxList<TomlPropertySyntax>)Creates an inline table with a space inside each brace, or {} when it is empty.
TomlInlineTable(SyntaxToken, SeparatedSyntaxList<TomlPropertySyntax>, SyntaxToken)
TomlInlineTable(TomlPropertySyntax[])Creates an inline table such as { x = 1, y = 2 }.
TomlInteger(SyntaxToken)
TomlInteger(long)
TomlProperty(TomlKeySyntax, SyntaxToken, TomlValueSyntax)
TomlProperty(TomlKeySyntax, TomlValueSyntax)Creates key = value.
TomlProperty(string, TomlValueSyntax)Creates name = value, quoting name when it cannot be a bare key.
TomlSkippedText(SyntaxTokenList)
TomlSkippedText(string)
TomlSkippedValue(SyntaxTokenList)Creates a value that holds tokens as they are, or a missing value when there are none.
TomlString(SyntaxToken)Creates a string from a token of any of the four string kinds.
TomlString(string)Creates a basic string holding value, escaped as TOML requires.
TomlTable(SyntaxToken, TomlKeySyntax, SyntaxToken)Creates a table header, or an array-of-tables header when openBracketToken is [[.
TomlTable(string[])Creates a table header such as [server], or [server.http] from several names.
Trivia(SyntaxKind, string)Creates trivia of any kind, with text used as it is.
TriviaList()
TriviaList(SyntaxTrivia)
TriviaList(SyntaxTrivia[])
TriviaList(IEnumerable<SyntaxTrivia>)
Whitespace(string)Creates whitespace trivia: one or more spaces and tabs, the only whitespace TOML has.

AreEquivalent(TomlSyntaxNode?, TomlSyntaxNode?)

SyntaxFactory.cs

Determines whether the two nodes have the same structure and text.

public static bool AreEquivalent(TomlSyntaxNode? oldNode, TomlSyntaxNode? newNode)

Parameters

oldNode TomlSyntaxNode?
newNode TomlSyntaxNode?

Returns

bool

BadToken(string)

SyntaxFactory.cs

Creates a token holding text the parser could make no sense of.

public static SyntaxToken BadToken(string text)

Parameters

text string

Returns

SyntaxToken

Exceptions

ArgumentNullException
text is null.

Comment(string)

SyntaxFactory.cs

Creates comment trivia.

public static SyntaxTrivia Comment(string text)

Parameters

text string

Returns

SyntaxTrivia

Exceptions

ArgumentNullException
text is null.
ArgumentException
text is not a TOML comment: it does not start with #, or it holds a line break, a control character other than tab, or a lone surrogate.

EndOfLine(string)

SyntaxFactory.cs

Creates a line break: \n or \r\n, the only two TOML has.

public static SyntaxTrivia EndOfLine(string text)

Parameters

text string

Returns

SyntaxTrivia

Exceptions

ArgumentNullException
text is null.
ArgumentException
text is neither \n nor \r\n.

Key overloads

Key(SyntaxTokenList)

SyntaxFactory.cs

Creates a key from its parts and the dots between them.

public static TomlKeySyntax Key(SyntaxTokenList tokens)
Parameters
tokens SyntaxTokenList
Returns

TomlKeySyntax

Key(string[])

SyntaxFactory.cs

Creates a key from the names of its parts, quoting each that cannot be bare.

public static TomlKeySyntax Key(params string[] names)
Parameters
names string[]
Returns

TomlKeySyntax

Exceptions
ArgumentNullException
names or one of its items is null.
ArgumentException
names is empty.
Example

Key("site", "google.com") is site."google.com".

KeyPart(string)

SyntaxFactory.cs

Creates one part of a key: a bare key when name can be one, a basic string otherwise.

public static SyntaxToken KeyPart(string name)

Parameters

name string

Returns

SyntaxToken

Exceptions

ArgumentNullException
name is null.
ArgumentException
name holds a lone surrogate, which TOML cannot represent.

List overloads

List<TNode>()

SyntaxFactory.cs
public static SyntaxList<TNode> List<TNode>() where TNode : TomlSyntaxNode
Type parameters
TNode
Returns

SyntaxList<TNode>

No documentation is available.

List<TNode>(IEnumerable<TNode>)

SyntaxFactory.cs
public static SyntaxList<TNode> List<TNode>(IEnumerable<TNode> nodes) where TNode : TomlSyntaxNode
Type parameters
TNode
Parameters
nodes IEnumerable<TNode>
Returns

SyntaxList<TNode>

Exceptions
ArgumentNullException
nodes is null.

Literal overloads

Literal(bool)

SyntaxFactory.cs

Creates true or false.

public static SyntaxToken Literal(bool value)
Parameters
value bool
Returns

SyntaxToken

Literal(DateOnly)

SyntaxFactory.cs

Creates a local date token, such as 1979-05-27.

public static SyntaxToken Literal(DateOnly value)
Parameters
value DateOnly
Returns

SyntaxToken

Literal(DateTime)

SyntaxFactory.cs

Creates a local date-time token, such as 1979-05-27T07:32:00. The kind of value is ignored.

public static SyntaxToken Literal(DateTime value)
Parameters
value DateTime
Returns

SyntaxToken

Literal(DateTimeOffset)

SyntaxFactory.cs

Creates an offset date-time token, such as 1979-05-27T07:32:00Z.

public static SyntaxToken Literal(DateTimeOffset value)
Parameters
value DateTimeOffset
Returns

SyntaxToken

Literal(double)

SyntaxFactory.cs

Creates a float token, written so that it reads back as the same float.

public static SyntaxToken Literal(double value)
Parameters
value double
Returns

SyntaxToken

Literal(long)

SyntaxFactory.cs

Creates an integer token, written in decimal.

public static SyntaxToken Literal(long value)
Parameters
value long
Returns

SyntaxToken

Literal(string)

SyntaxFactory.cs

Creates a basic string token holding value, escaped as TOML requires.

public static SyntaxToken Literal(string value)
Parameters
value string
Returns

SyntaxToken

Exceptions
ArgumentNullException
value is null.
ArgumentException
value holds a lone surrogate, a character TOML cannot hold, escaped or not.

Literal(TimeOnly)

SyntaxFactory.cs

Creates a local time token, such as 07:32:00.

public static SyntaxToken Literal(TimeOnly value)
Parameters
value TimeOnly
Returns

SyntaxToken

MissingToken(SyntaxKind)

SyntaxFactory.cs

Creates a zero-width token standing in for one the text does not have.

public static SyntaxToken MissingToken(SyntaxKind kind)

Parameters

kind SyntaxKind

Returns

SyntaxToken

ParseDocument(string, TomlParseOptions?)

SyntaxFactory.cs

Parses text and returns its root.

public static TomlDocumentSyntax ParseDocument(string text, TomlParseOptions? options = null)

Parameters

text string
options TomlParseOptions?

Returns

TomlDocumentSyntax

Exceptions

ArgumentNullException
text is null.

ParseSyntaxTree(string, TomlParseOptions?, string?)

SyntaxFactory.cs

Parses text into a tree.

public static TomlSyntaxTree ParseSyntaxTree(string text, TomlParseOptions? options = null, string? path = null)

Parameters

text string
options TomlParseOptions?
path string?

Returns

TomlSyntaxTree

Exceptions

ArgumentNullException
text is null.

ParseValue(string, TomlParseOptions?)

SyntaxFactory.cs

Parses text as a single value, such as [1, 2] or '''literal'''.

public static TomlValueSyntax ParseValue(string text, TomlParseOptions? options = null)

Parameters

text string
options TomlParseOptions?

Returns

TomlValueSyntax

Exceptions

ArgumentNullException
text is null.

Remarks

Text after the value makes the whole of it a TomlSkippedValueSyntax. Whether text held one value the grammar accepts and nothing else is what SyntaxNode.ContainsDiagnostics says. A key defined twice in an inline table is not a grammar mistake: TomlSyntaxTree.GetDiagnostics reports it once the value is part of a document.

SeparatedList overloads

SeparatedList<TNode>()

SyntaxFactory.cs
public static SeparatedSyntaxList<TNode> SeparatedList<TNode>() where TNode : TomlSyntaxNode
Type parameters
TNode
Returns

SeparatedSyntaxList<TNode>

No documentation is available.

SeparatedList<TNode>(IEnumerable<SyntaxNodeOrToken>)

SyntaxFactory.cs

Creates a list from nodes and the separators to put between them.

public static SeparatedSyntaxList<TNode> SeparatedList<TNode>(IEnumerable<SyntaxNodeOrToken> nodesAndSeparators) where TNode : TomlSyntaxNode
Type parameters
TNode
Parameters
nodesAndSeparators IEnumerable<SyntaxNodeOrToken>
Returns

SeparatedSyntaxList<TNode>

Exceptions
ArgumentNullException
nodesAndSeparators is null.

SeparatedList<TNode>(IEnumerable<TNode>)

SyntaxFactory.cs

Creates a list of nodes with a comma and a space between each pair.

public static SeparatedSyntaxList<TNode> SeparatedList<TNode>(IEnumerable<TNode> nodes) where TNode : TomlSyntaxNode
Type parameters
TNode
Parameters
nodes IEnumerable<TNode>
Returns

SeparatedSyntaxList<TNode>

Exceptions
ArgumentNullException
nodes or one of its items is null.
Remarks

A node that ends with a comment, such as one from SyntaxFactory.ParseValue, gets a line break after it, or the comment would hide the comma or the bracket that follows it.

SingletonList<TNode>(TNode)

SyntaxFactory.cs
public static SyntaxList<TNode> SingletonList<TNode>(TNode node) where TNode : TomlSyntaxNode

Type parameters

TNode

Parameters

node TNode

Returns

SyntaxList<TNode>

No documentation is available.

SingletonSeparatedList<TNode>(TNode)

SyntaxFactory.cs
public static SeparatedSyntaxList<TNode> SingletonSeparatedList<TNode>(TNode node) where TNode : TomlSyntaxNode

Type parameters

TNode

Parameters

node TNode

Returns

SeparatedSyntaxList<TNode>

No documentation is available.

Token overloads

Token(SyntaxTriviaList, SyntaxKind, SyntaxTriviaList)

SyntaxFactory.cs

Creates a token whose text is fixed by its kind, with trivia on either side.

public static SyntaxToken Token(SyntaxTriviaList leading, SyntaxKind kind, SyntaxTriviaList trailing)
Parameters
leading SyntaxTriviaList
kind SyntaxKind
trailing SyntaxTriviaList
Returns

SyntaxToken

Exceptions
ArgumentException
kind is not a token whose text is fixed, such as a key or a value.

Token(SyntaxKind)

SyntaxFactory.cs

Creates a token whose text is fixed by its kind, such as a bracket or true.

public static SyntaxToken Token(SyntaxKind kind)
Parameters
kind SyntaxKind
Returns

SyntaxToken

Exceptions
ArgumentException
kind is not a token whose text is fixed, such as a key or a value.

TokenList overloads

TokenList()

SyntaxFactory.cs
public static SyntaxTokenList TokenList()

No documentation is available.

TokenList(SyntaxToken)

SyntaxFactory.cs
public static SyntaxTokenList TokenList(SyntaxToken token)
Parameters
token SyntaxToken
Returns

SyntaxTokenList

No documentation is available.

TokenList(SyntaxToken[])

SyntaxFactory.cs
public static SyntaxTokenList TokenList(params SyntaxToken[] tokens)
Parameters
tokens SyntaxToken[]
Returns

SyntaxTokenList

No documentation is available.

TokenList(IEnumerable<SyntaxToken>)

SyntaxFactory.cs
public static SyntaxTokenList TokenList(IEnumerable<SyntaxToken> tokens)
Parameters
tokens IEnumerable<SyntaxToken>
Returns

SyntaxTokenList

Exceptions
ArgumentNullException
tokens is null.

TomlArray overloads

TomlArray(SeparatedSyntaxList<TomlValueSyntax>)

SyntaxFactory.cs
public static TomlArraySyntax TomlArray(SeparatedSyntaxList<TomlValueSyntax> elements)

No documentation is available.

TomlArray(SyntaxToken, SeparatedSyntaxList<TomlValueSyntax>, SyntaxToken)

SyntaxFactory.cs
public static TomlArraySyntax TomlArray(SyntaxToken openBracketToken, SeparatedSyntaxList<TomlValueSyntax> elements, SyntaxToken closeBracketToken)
Parameters
openBracketToken SyntaxToken
elements SeparatedSyntaxList<TomlValueSyntax>
closeBracketToken SyntaxToken
Returns

TomlArraySyntax

No documentation is available.

TomlArray(TomlValueSyntax[])

SyntaxFactory.cs

Creates an array such as [1, 2, 3].

public static TomlArraySyntax TomlArray(params TomlValueSyntax[] values)
Parameters
values TomlValueSyntax[]
Returns

TomlArraySyntax

TomlArrayOfTables(string[])

SyntaxFactory.cs

Creates an array-of-tables header such as [[products]].

public static TomlTableSyntax TomlArrayOfTables(params string[] names)

Parameters

names string[]

Returns

TomlTableSyntax

Exceptions

ArgumentNullException
names is null.
ArgumentException
names is empty.

TomlBoolean overloads

TomlBoolean(SyntaxToken)

SyntaxFactory.cs
public static TomlBooleanSyntax TomlBoolean(SyntaxToken booleanToken)
Parameters
booleanToken SyntaxToken
Returns

TomlBooleanSyntax

Exceptions
ArgumentException
booleanToken is neither true nor false.

TomlBoolean(bool)

SyntaxFactory.cs
public static TomlBooleanSyntax TomlBoolean(bool value)
Parameters
value bool
Returns

TomlBooleanSyntax

No documentation is available.

TomlDateTime overloads

TomlDateTime(SyntaxToken)

SyntaxFactory.cs

Creates a date, a time, or both, taking the kind of the node from the token.

public static TomlDateTimeSyntax TomlDateTime(SyntaxToken dateTimeToken)
Parameters
dateTimeToken SyntaxToken
Returns

TomlDateTimeSyntax

Exceptions
ArgumentException
dateTimeToken is not a date or a time.

TomlDateTime(DateOnly)

SyntaxFactory.cs
public static TomlDateTimeSyntax TomlDateTime(DateOnly value)
Parameters
value DateOnly
Returns

TomlDateTimeSyntax

No documentation is available.

TomlDateTime(DateTime)

SyntaxFactory.cs
public static TomlDateTimeSyntax TomlDateTime(DateTime value)
Parameters
value DateTime
Returns

TomlDateTimeSyntax

No documentation is available.

TomlDateTime(DateTimeOffset)

SyntaxFactory.cs
public static TomlDateTimeSyntax TomlDateTime(DateTimeOffset value)
Parameters
value DateTimeOffset
Returns

TomlDateTimeSyntax

No documentation is available.

TomlDateTime(TimeOnly)

SyntaxFactory.cs
public static TomlDateTimeSyntax TomlDateTime(TimeOnly value)
Parameters
value TimeOnly
Returns

TomlDateTimeSyntax

No documentation is available.

TomlDocument overloads

TomlDocument(SyntaxList<TomlEntrySyntax>, SyntaxToken)

SyntaxFactory.cs

Creates a document from entries.

public static TomlDocumentSyntax TomlDocument(SyntaxList<TomlEntrySyntax> entries, SyntaxToken endOfFileToken)
Parameters
entries SyntaxList<TomlEntrySyntax>
endOfFileToken SyntaxToken
Returns

TomlDocumentSyntax

Remarks

An entry followed by another one on the same line gets a line break after it, and so does a comment in front of an entry, or the text would read as something else. The last entry is left as it is.

TomlDocument(TomlEntrySyntax[])

SyntaxFactory.cs

Creates a document from entries, ending the line of each that does not end its own.

public static TomlDocumentSyntax TomlDocument(params TomlEntrySyntax[] entries)
Parameters
entries TomlEntrySyntax[]
Returns

TomlDocumentSyntax

TomlFloat overloads

TomlFloat(SyntaxToken)

SyntaxFactory.cs
public static TomlFloatSyntax TomlFloat(SyntaxToken floatToken)
Parameters
floatToken SyntaxToken
Returns

TomlFloatSyntax

Exceptions
ArgumentException
floatToken is not a float.

TomlFloat(double)

SyntaxFactory.cs
public static TomlFloatSyntax TomlFloat(double value)
Parameters
value double
Returns

TomlFloatSyntax

No documentation is available.

TomlInlineTable overloads

TomlInlineTable(SeparatedSyntaxList<TomlPropertySyntax>)

SyntaxFactory.cs

Creates an inline table with a space inside each brace, or {} when it is empty.

public static TomlInlineTableSyntax TomlInlineTable(SeparatedSyntaxList<TomlPropertySyntax> properties)

TomlInlineTable(SyntaxToken, SeparatedSyntaxList<TomlPropertySyntax>, SyntaxToken)

SyntaxFactory.cs
public static TomlInlineTableSyntax TomlInlineTable(SyntaxToken openBraceToken, SeparatedSyntaxList<TomlPropertySyntax> properties, SyntaxToken closeBraceToken)
Parameters
openBraceToken SyntaxToken
properties SeparatedSyntaxList<TomlPropertySyntax>
closeBraceToken SyntaxToken
Returns

TomlInlineTableSyntax

No documentation is available.

TomlInlineTable(TomlPropertySyntax[])

SyntaxFactory.cs

Creates an inline table such as { x = 1, y = 2 }.

public static TomlInlineTableSyntax TomlInlineTable(params TomlPropertySyntax[] properties)
Parameters
properties TomlPropertySyntax[]
Returns

TomlInlineTableSyntax

TomlInteger overloads

TomlInteger(SyntaxToken)

SyntaxFactory.cs
public static TomlIntegerSyntax TomlInteger(SyntaxToken integerToken)
Parameters
integerToken SyntaxToken
Returns

TomlIntegerSyntax

Exceptions
ArgumentException
integerToken is not an integer.

TomlInteger(long)

SyntaxFactory.cs
public static TomlIntegerSyntax TomlInteger(long value)
Parameters
value long
Returns

TomlIntegerSyntax

No documentation is available.

TomlProperty overloads

TomlProperty(TomlKeySyntax, SyntaxToken, TomlValueSyntax)

SyntaxFactory.cs
public static TomlPropertySyntax TomlProperty(TomlKeySyntax key, SyntaxToken equalsToken, TomlValueSyntax value)
Parameters
key TomlKeySyntax
equalsToken SyntaxToken
value TomlValueSyntax
Returns

TomlPropertySyntax

Exceptions
ArgumentNullException
key or value is null.
ArgumentException
value starts with a line break or a comment, which would put it on a line of its own.

TomlProperty(TomlKeySyntax, TomlValueSyntax)

SyntaxFactory.cs

Creates key = value.

public static TomlPropertySyntax TomlProperty(TomlKeySyntax key, TomlValueSyntax value)
Parameters
key TomlKeySyntax
value TomlValueSyntax
Returns

TomlPropertySyntax

Exceptions
ArgumentNullException
key or value is null.
ArgumentException
value starts with a line break or a comment, which would put it on a line of its own.

TomlProperty(string, TomlValueSyntax)

SyntaxFactory.cs

Creates name = value, quoting name when it cannot be a bare key.

public static TomlPropertySyntax TomlProperty(string name, TomlValueSyntax value)
Parameters
name string
value TomlValueSyntax
Returns

TomlPropertySyntax

Exceptions
ArgumentNullException
name or value is null.
Remarks

name is one name, even if it has dots in it. Use SyntaxFactory.Key for a dotted key.

TomlSkippedText overloads

TomlSkippedText(SyntaxTokenList)

SyntaxFactory.cs
public static TomlSkippedTextSyntax TomlSkippedText(SyntaxTokenList tokens)
Parameters
tokens SyntaxTokenList
Returns

TomlSkippedTextSyntax

No documentation is available.

TomlSkippedText(string)

SyntaxFactory.cs
public static TomlSkippedTextSyntax TomlSkippedText(string text)
Parameters
text string
Returns

TomlSkippedTextSyntax

Exceptions
ArgumentNullException
text is null.

TomlSkippedValue(SyntaxTokenList)

SyntaxFactory.cs

Creates a value that holds tokens as they are, or a missing value when there are none.

public static TomlSkippedValueSyntax TomlSkippedValue(SyntaxTokenList tokens)

TomlString overloads

TomlString(SyntaxToken)

SyntaxFactory.cs

Creates a string from a token of any of the four string kinds.

public static TomlStringSyntax TomlString(SyntaxToken stringToken)
Parameters
stringToken SyntaxToken
Returns

TomlStringSyntax

Exceptions
ArgumentException
stringToken is not a string.

TomlString(string)

SyntaxFactory.cs

Creates a basic string holding value, escaped as TOML requires.

public static TomlStringSyntax TomlString(string value)
Parameters
value string
Returns

TomlStringSyntax

Exceptions
ArgumentNullException
value is null.

TomlTable overloads

TomlTable(SyntaxToken, TomlKeySyntax, SyntaxToken)

SyntaxFactory.cs

Creates a table header, or an array-of-tables header when openBracketToken is [[.

public static TomlTableSyntax TomlTable(SyntaxToken openBracketToken, TomlKeySyntax key, SyntaxToken closeBracketToken)
Parameters
openBracketToken SyntaxToken
key TomlKeySyntax
closeBracketToken SyntaxToken
Returns

TomlTableSyntax

Exceptions
ArgumentNullException
key is null.

TomlTable(string[])

SyntaxFactory.cs

Creates a table header such as [server], or [server.http] from several names.

public static TomlTableSyntax TomlTable(params string[] names)
Parameters
names string[]
Returns

TomlTableSyntax

Exceptions
ArgumentNullException
names is null.
ArgumentException
names is empty.

Trivia(SyntaxKind, string)

SyntaxFactory.cs

Creates trivia of any kind, with text used as it is.

public static SyntaxTrivia Trivia(SyntaxKind kind, string text)

Parameters

kind SyntaxKind
text string

Returns

SyntaxTrivia

Exceptions

ArgumentNullException
text is null.

Remarks

Nothing checks that text is what kind says, which is what lets a tree hold exactly what a document has, mistakes included. Prefer SyntaxFactory.Whitespace, SyntaxFactory.EndOfLine, and SyntaxFactory.Comment, which refuse text that would change what the tokens around it mean.

TriviaList overloads

TriviaList()

SyntaxFactory.cs
public static SyntaxTriviaList TriviaList()

No documentation is available.

TriviaList(SyntaxTrivia)

SyntaxFactory.cs
public static SyntaxTriviaList TriviaList(SyntaxTrivia trivia)
Parameters
trivia SyntaxTrivia
Returns

SyntaxTriviaList

No documentation is available.

TriviaList(SyntaxTrivia[])

SyntaxFactory.cs
public static SyntaxTriviaList TriviaList(params SyntaxTrivia[] trivia)
Parameters
trivia SyntaxTrivia[]
Returns

SyntaxTriviaList

No documentation is available.

TriviaList(IEnumerable<SyntaxTrivia>)

SyntaxFactory.cs
public static SyntaxTriviaList TriviaList(IEnumerable<SyntaxTrivia> trivia)
Parameters
trivia IEnumerable<SyntaxTrivia>
Returns

SyntaxTriviaList

Exceptions
ArgumentNullException
trivia is null.

Whitespace(string)

SyntaxFactory.cs

Creates whitespace trivia: one or more spaces and tabs, the only whitespace TOML has.

public static SyntaxTrivia Whitespace(string text)

Parameters

text string

Returns

SyntaxTrivia

Exceptions

ArgumentNullException
text is null.
ArgumentException
text is empty, or holds something other than spaces and tabs.