SyntaxFacts Class

Answers questions about CSS kinds and names without needing a tree.

public static class SyntaxFacts

Methods

NameDescription
GetAtRuleKind(string)Gets the kind of the at-rule named name at the top level of a style sheet or in a block that is not specific to it.
GetClosingKind(SyntaxKind)Gets the closing token of a block opened by kind, or SyntaxKind.None.
GetDelimKind(char)Gets the kind of the delimiter c, or SyntaxKind.DelimToken when it has none of its own.
GetText(SyntaxKind)Gets the text of a token whose kind fixes it, or an empty string for any other kind.
IsAnyToken(SyntaxKind)
IsAtRule(SyntaxKind)Determines whether kind is an at-rule.
IsComment(SyntaxKind)
IsCssWideKeyword(string)Determines whether name is a keyword every property accepts, such as inherit.
IsCustomPropertyName(string)Determines whether name is a custom property name: two dashes followed by anything.
IsDelim(SyntaxKind)Determines whether kind is a delim token of the tokenizer, with a kind of its own or not.
IsFontFeatureValueBlockName(string)Determines whether name is a feature block, such as swash, which @font-feature-values may hold.
IsKnownFunctionalPseudoClass(string)Determines whether name is a pseudo-class written as a function, such as is or nth-child.
IsKnownFunctionalPseudoElement(string)Determines whether name is a pseudo-element written as a function, such as part.
IsKnownPseudoClass(string)Determines whether name is a pseudo-class written without arguments, such as hover.
IsKnownPseudoElement(string)Determines whether name is a pseudo-element written without arguments, such as before.
IsLegacyPseudoElement(string)Determines whether name is one of the four pseudo-elements CSS 2 wrote with a single colon.
IsNumeric(SyntaxKind)Determines whether kind is a token whose value is a number: a number, a percentage, or a dimension.
IsPageMarginRuleName(string)Determines whether name is a page margin rule, such as top-left, which @page may hold.
IsRule(SyntaxKind)Determines whether kind is a rule, qualified or at-rule.
IsTrivia(SyntaxKind)
IsValidIdentifier(string)Determines whether name is an identifier that needs no escaping in CSS.
IsVendorPrefixed(string)Determines whether name is vendor-prefixed, such as -webkit-scrollbar.

GetAtRuleKind(string)

SyntaxFacts.cs

Gets the kind of the at-rule named name at the top level of a style sheet or in a block that is not specific to it.

public static SyntaxKind GetAtRuleKind(string name)

Parameters

name string
The name without the @, compared without regard to ASCII case.

Returns

SyntaxKind The kind of the rule, or SyntaxKind.UnknownAtRule. A page margin rule such as @top-left and a feature block such as @swash are only known inside the rule they belong to, so they are unknown here.

Exceptions

ArgumentNullException
name is null.

GetClosingKind(SyntaxKind)

SyntaxFacts.cs

Gets the closing token of a block opened by kind, or SyntaxKind.None.

public static SyntaxKind GetClosingKind(SyntaxKind kind)

Parameters

kind SyntaxKind

Returns

SyntaxKind

GetDelimKind(char)

SyntaxFacts.cs

Gets the kind of the delimiter c, or SyntaxKind.DelimToken when it has none of its own.

public static SyntaxKind GetDelimKind(char c)

Parameters

c char

Returns

SyntaxKind

GetText(SyntaxKind)

SyntaxFacts.cs

Gets the text of a token whose kind fixes it, or an empty string for any other kind.

public static string GetText(SyntaxKind kind)

Parameters

kind SyntaxKind

Returns

string

IsAnyToken(SyntaxKind)

SyntaxFacts.cs
public static bool IsAnyToken(SyntaxKind kind)

Parameters

kind SyntaxKind

Returns

bool

No documentation is available.

IsAtRule(SyntaxKind)

SyntaxFacts.cs

Determines whether kind is an at-rule.

public static bool IsAtRule(SyntaxKind kind)

Parameters

kind SyntaxKind

Returns

bool

IsComment(SyntaxKind)

SyntaxFacts.cs
public static bool IsComment(SyntaxKind kind)

Parameters

kind SyntaxKind

Returns

bool

No documentation is available.

IsCssWideKeyword(string)

SyntaxFacts.cs

Determines whether name is a keyword every property accepts, such as inherit.

public static bool IsCssWideKeyword(string name)

Parameters

name string

Returns

bool

Exceptions

ArgumentNullException
name is null.

IsCustomPropertyName(string)

SyntaxFacts.cs

Determines whether name is a custom property name: two dashes followed by anything.

public static bool IsCustomPropertyName(string name)

Parameters

name string

Returns

bool

Exceptions

ArgumentNullException
name is null.

IsDelim(SyntaxKind)

SyntaxFacts.cs

Determines whether kind is a delim token of the tokenizer, with a kind of its own or not.

public static bool IsDelim(SyntaxKind kind)

Parameters

kind SyntaxKind

Returns

bool

IsFontFeatureValueBlockName(string)

SyntaxFacts.cs

Determines whether name is a feature block, such as swash, which @font-feature-values may hold.

public static bool IsFontFeatureValueBlockName(string name)

Parameters

name string

Returns

bool

Exceptions

ArgumentNullException
name is null.

IsKnownFunctionalPseudoClass(string)

SyntaxFacts.cs

Determines whether name is a pseudo-class written as a function, such as is or nth-child.

public static bool IsKnownFunctionalPseudoClass(string name)

Parameters

name string

Returns

bool

Exceptions

ArgumentNullException
name is null.

IsKnownFunctionalPseudoElement(string)

SyntaxFacts.cs

Determines whether name is a pseudo-element written as a function, such as part.

public static bool IsKnownFunctionalPseudoElement(string name)

Parameters

name string

Returns

bool

Exceptions

ArgumentNullException
name is null.

IsKnownPseudoClass(string)

SyntaxFacts.cs

Determines whether name is a pseudo-class written without arguments, such as hover.

public static bool IsKnownPseudoClass(string name)

Parameters

name string

Returns

bool

Exceptions

ArgumentNullException
name is null.

IsKnownPseudoElement(string)

SyntaxFacts.cs

Determines whether name is a pseudo-element written without arguments, such as before.

public static bool IsKnownPseudoElement(string name)

Parameters

name string

Returns

bool

Exceptions

ArgumentNullException
name is null.

IsLegacyPseudoElement(string)

SyntaxFacts.cs

Determines whether name is one of the four pseudo-elements CSS 2 wrote with a single colon.

public static bool IsLegacyPseudoElement(string name)

Parameters

name string

Returns

bool

Exceptions

ArgumentNullException
name is null.

IsNumeric(SyntaxKind)

SyntaxFacts.cs

Determines whether kind is a token whose value is a number: a number, a percentage, or a dimension.

public static bool IsNumeric(SyntaxKind kind)

Parameters

kind SyntaxKind

Returns

bool

IsPageMarginRuleName(string)

SyntaxFacts.cs

Determines whether name is a page margin rule, such as top-left, which @page may hold.

public static bool IsPageMarginRuleName(string name)

Parameters

name string

Returns

bool

Exceptions

ArgumentNullException
name is null.

IsRule(SyntaxKind)

SyntaxFacts.cs

Determines whether kind is a rule, qualified or at-rule.

public static bool IsRule(SyntaxKind kind)

Parameters

kind SyntaxKind

Returns

bool

IsTrivia(SyntaxKind)

SyntaxFacts.cs
public static bool IsTrivia(SyntaxKind kind)

Parameters

kind SyntaxKind

Returns

bool

No documentation is available.

IsValidIdentifier(string)

SyntaxFacts.cs

Determines whether name is an identifier that needs no escaping in CSS.

public static bool IsValidIdentifier(string name)

Parameters

name string

Returns

bool

Exceptions

ArgumentNullException
name is null.

IsVendorPrefixed(string)

SyntaxFacts.cs

Determines whether name is vendor-prefixed, such as -webkit-scrollbar.

public static bool IsVendorPrefixed(string name)

Parameters

name string

Returns

bool

Exceptions

ArgumentNullException
name is null.