SyntaxFacts Class
Answers questions about a SyntaxKind that do not need a node to ask them of.
public static class SyntaxFactsMethods
| Name | Description |
|---|---|
| GetText(SyntaxKind) | Returns the text a kind is always spelled with, or an empty string when its text varies. |
| IsNameCharacter(Rune) | Determines whether value may appear inside an XML name. |
| IsNameStartCharacter(Rune) | Determines whether value may begin an XML name. |
| IsTrivia(SyntaxKind) | Determines whether kind is whitespace, a line break, or text skipped inside a tag. |
| IsWhitespace(char) | Determines whether value is whitespace as XML defines it. |
GetText(SyntaxKind)
SyntaxFacts.csReturns the text a kind is always spelled with, or an empty string when its text varies.
public static string GetText(SyntaxKind kind)Parameters
kindSyntaxKind
Returns
Remarks
This is the canonical spelling, and the only one XML allows. The parser still reads <?XML or <!doctype as the construct they were meant to be, reporting the spelling, and the token then carries what the document said; a token built from a kind alone gets the spelling here.
IsNameCharacter(Rune)
SyntaxFacts.csDetermines whether value may appear inside an XML name.
IsNameStartCharacter(Rune)
SyntaxFacts.csDetermines whether value may begin an XML name.
Parameters
valueRune
Returns
Remarks
This is the NameStartChar production of XML 1.0 verbatim. It is not the same set as "a Unicode letter": it excludes some letters, such as ª and µ, and includes characters that are not letters at all. It takes a scalar value rather than a Char because a name character may sit outside the basic plane, where it is written as a surrogate pair that means nothing one half at a time.
IsTrivia(SyntaxKind)
SyntaxFacts.csDetermines whether kind is whitespace, a line break, or text skipped inside a tag.
public static bool IsTrivia(SyntaxKind kind)IsWhitespace(char)
SyntaxFacts.csDetermines whether value is whitespace as XML defines it.
Parameters
valuechar
Returns
Remarks
This is the S production: a space, a tab, a carriage return, or a line feed. It is much narrower than Char.IsWhiteSpace, which also accepts characters such as a no-break space.