tm-grammars
Version:
Collecton of TextMate grammars in JSON
2,019 lines (2,018 loc) • 144 kB
JSON
{
"displayName": "C#",
"name": "csharp",
"patterns": [
{
"include": "#preprocessor"
},
{
"include": "#comment"
},
{
"include": "#directives"
},
{
"include": "#declarations"
},
{
"include": "#script-top-level"
}
],
"repository": {
"accessor-getter": {
"patterns": [
{
"begin": "\\{",
"beginCaptures": {
"0": {
"name": "punctuation.curlybrace.open.cs"
}
},
"contentName": "meta.accessor.getter.cs",
"end": "}",
"endCaptures": {
"0": {
"name": "punctuation.curlybrace.close.cs"
}
},
"patterns": [
{
"include": "#statement"
}
]
},
{
"include": "#accessor-getter-expression"
},
{
"include": "#punctuation-semicolon"
}
]
},
"accessor-getter-expression": {
"begin": "=>",
"beginCaptures": {
"0": {
"name": "keyword.operator.arrow.cs"
}
},
"contentName": "meta.accessor.getter.cs",
"end": "(?=[;}])",
"patterns": [
{
"include": "#ref-modifier"
},
{
"include": "#expression"
}
]
},
"accessor-setter": {
"patterns": [
{
"begin": "\\{",
"beginCaptures": {
"0": {
"name": "punctuation.curlybrace.open.cs"
}
},
"contentName": "meta.accessor.setter.cs",
"end": "}",
"endCaptures": {
"0": {
"name": "punctuation.curlybrace.close.cs"
}
},
"patterns": [
{
"include": "#statement"
}
]
},
{
"begin": "=>",
"beginCaptures": {
"0": {
"name": "keyword.operator.arrow.cs"
}
},
"contentName": "meta.accessor.setter.cs",
"end": "(?=[;}])",
"patterns": [
{
"include": "#ref-modifier"
},
{
"include": "#expression"
}
]
},
{
"include": "#punctuation-semicolon"
}
]
},
"anonymous-method-expression": {
"patterns": [
{
"begin": "((?:\\b(?:async|static)\\b\\s*)*)(?:(@?[_[:alpha:]][_[:alnum:]]*)\\b|(\\()(?<tuple>(?:[^()]|\\(\\g<tuple>\\))*)(\\)))\\s*(=>)",
"beginCaptures": {
"1": {
"patterns": [
{
"match": "async|static",
"name": "storage.modifier.$0.cs"
}
]
},
"2": {
"name": "entity.name.variable.parameter.cs"
},
"3": {
"name": "punctuation.parenthesis.open.cs"
},
"4": {
"patterns": [
{
"include": "#comment"
},
{
"include": "#explicit-anonymous-function-parameter"
},
{
"include": "#implicit-anonymous-function-parameter"
},
{
"include": "#default-argument"
},
{
"include": "#punctuation-comma"
}
]
},
"5": {
"name": "punctuation.parenthesis.close.cs"
},
"6": {
"name": "keyword.operator.arrow.cs"
}
},
"end": "(?=[),;}])",
"patterns": [
{
"include": "#intrusive"
},
{
"begin": "(?=\\{)",
"end": "(?=[),;}])",
"patterns": [
{
"include": "#block"
},
{
"include": "#intrusive"
}
]
},
{
"begin": "\\b(ref)\\b|(?=\\S)",
"beginCaptures": {
"1": {
"name": "storage.modifier.ref.cs"
}
},
"end": "(?=[),;}])",
"patterns": [
{
"include": "#expression"
}
]
}
]
},
{
"begin": "((?:\\b(?:async|static)\\b\\s*)*)\\b(delegate)\\b\\s*",
"beginCaptures": {
"1": {
"patterns": [
{
"match": "async|static",
"name": "storage.modifier.$0.cs"
}
]
},
"2": {
"name": "storage.type.delegate.cs"
}
},
"end": "(?<=})|(?=[),;}])",
"patterns": [
{
"include": "#intrusive"
},
{
"begin": "\\(",
"beginCaptures": {
"0": {
"name": "punctuation.parenthesis.open.cs"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.parenthesis.close.cs"
}
},
"patterns": [
{
"include": "#intrusive"
},
{
"include": "#explicit-anonymous-function-parameter"
},
{
"include": "#punctuation-comma"
}
]
},
{
"include": "#block"
}
]
}
]
},
"anonymous-object-creation-expression": {
"begin": "\\b(new)\\b\\s*(?=\\{|//|/\\*|$)",
"beginCaptures": {
"1": {
"name": "keyword.operator.expression.new.cs"
}
},
"end": "(?<=})",
"patterns": [
{
"include": "#comment"
},
{
"include": "#initializer-expression"
}
]
},
"argument": {
"patterns": [
{
"match": "\\b(ref|in)\\b",
"name": "storage.modifier.$1.cs"
},
{
"begin": "\\b(out)\\b",
"beginCaptures": {
"1": {
"name": "storage.modifier.out.cs"
}
},
"end": "(?=[]),])",
"patterns": [
{
"include": "#declaration-expression-local"
},
{
"include": "#expression"
}
]
},
{
"include": "#expression"
}
]
},
"argument-list": {
"begin": "\\(",
"beginCaptures": {
"0": {
"name": "punctuation.parenthesis.open.cs"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.parenthesis.close.cs"
}
},
"patterns": [
{
"include": "#named-argument"
},
{
"include": "#argument"
},
{
"include": "#punctuation-comma"
}
]
},
"array-creation-expression": {
"begin": "\\b(new|stackalloc)\\b\\s*(?<type_name>(?:(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*::\\s*)?(?<name_and_type_args>\\g<identifier>\\s*(?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?)(?:\\s*\\.\\s*\\g<name_and_type_args>)*|(?<tuple>\\s*\\((?:[^()]|\\g<tuple>)+\\)))(?:\\s*\\?\\s*)?(?:\\s*\\[(?:\\s*,\\s*)*]\\s*\\??\\s*)*)?\\s*(?=\\[)",
"beginCaptures": {
"1": {
"name": "keyword.operator.expression.$1.cs"
},
"2": {
"patterns": [
{
"include": "#type"
}
]
}
},
"end": "(?<=])",
"patterns": [
{
"include": "#bracketed-argument-list"
}
]
},
"as-expression": {
"captures": {
"1": {
"name": "keyword.operator.expression.as.cs"
},
"2": {
"patterns": [
{
"include": "#type"
}
]
}
},
"match": "(?<!\\.)\\b(as)\\b\\s*(?<type_name>(?:(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*::\\s*)?(?<name_and_type_args>\\g<identifier>\\s*(?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?)(?:\\s*\\.\\s*\\g<name_and_type_args>)*|(?<tuple>\\s*\\((?:[^()]|\\g<tuple>)+\\)))(?:\\s*\\?(?!\\?))?(?:\\s*\\[\\s*(?:,\\s*)*](?:\\s*\\?(?!\\?))?)*)?"
},
"assignment-expression": {
"begin": "(?:[-%*+/]|\\?\\?|[\\&^]|<<|>>>?|\\|)?=(?![=>])",
"beginCaptures": {
"0": {
"patterns": [
{
"include": "#assignment-operators"
}
]
}
},
"end": "(?=[]),;}])",
"patterns": [
{
"include": "#ref-modifier"
},
{
"include": "#expression"
}
]
},
"assignment-operators": {
"patterns": [
{
"match": "(?:[-%*+/]|\\?\\?)=",
"name": "keyword.operator.assignment.compound.cs"
},
{
"match": "(?:[\\&^]|<<|>>>?|\\|)=",
"name": "keyword.operator.assignment.compound.bitwise.cs"
},
{
"match": "=",
"name": "keyword.operator.assignment.cs"
}
]
},
"attribute": {
"patterns": [
{
"include": "#type-name"
},
{
"include": "#type-arguments"
},
{
"include": "#attribute-arguments"
}
]
},
"attribute-arguments": {
"begin": "(\\()",
"beginCaptures": {
"1": {
"name": "punctuation.parenthesis.open.cs"
}
},
"end": "(\\))",
"endCaptures": {
"1": {
"name": "punctuation.parenthesis.close.cs"
}
},
"patterns": [
{
"include": "#attribute-named-argument"
},
{
"include": "#expression"
},
{
"include": "#punctuation-comma"
}
]
},
"attribute-named-argument": {
"begin": "(@?[_[:alpha:]][_[:alnum:]]*)\\s*(?==)",
"beginCaptures": {
"1": {
"name": "entity.name.variable.property.cs"
}
},
"end": "(?=([),]))",
"patterns": [
{
"include": "#operator-assignment"
},
{
"include": "#expression"
}
]
},
"attribute-section": {
"begin": "(\\[)(assembly|module|field|event|method|param|property|return|type)?(:)?",
"beginCaptures": {
"1": {
"name": "punctuation.squarebracket.open.cs"
},
"2": {
"name": "keyword.other.attribute-specifier.cs"
},
"3": {
"name": "punctuation.separator.colon.cs"
}
},
"end": "(])",
"endCaptures": {
"1": {
"name": "punctuation.squarebracket.close.cs"
}
},
"patterns": [
{
"include": "#comment"
},
{
"include": "#attribute"
},
{
"include": "#punctuation-comma"
}
]
},
"await-expression": {
"match": "(?<!\\.\\s*)\\b(await)\\b",
"name": "keyword.operator.expression.await.cs"
},
"await-statement": {
"begin": "(?<!\\.\\s*)\\b(await)\\b",
"beginCaptures": {
"1": {
"name": "keyword.operator.expression.await.cs"
}
},
"end": "(?<=})|(?=[;}])",
"patterns": [
{
"include": "#foreach-statement"
},
{
"include": "#using-statement"
},
{
"include": "#expression"
}
]
},
"base-types": {
"begin": ":",
"beginCaptures": {
"0": {
"name": "punctuation.separator.colon.cs"
}
},
"end": "(?=\\{|where|;)",
"patterns": [
{
"include": "#type"
},
{
"include": "#punctuation-comma"
},
{
"include": "#preprocessor"
}
]
},
"block": {
"begin": "\\{",
"beginCaptures": {
"0": {
"name": "punctuation.curlybrace.open.cs"
}
},
"end": "}",
"endCaptures": {
"0": {
"name": "punctuation.curlybrace.close.cs"
}
},
"patterns": [
{
"include": "#statement"
}
]
},
"boolean-literal": {
"patterns": [
{
"match": "(?<!\\.)\\btrue\\b",
"name": "constant.language.boolean.true.cs"
},
{
"match": "(?<!\\.)\\bfalse\\b",
"name": "constant.language.boolean.false.cs"
}
]
},
"bracketed-argument-list": {
"begin": "\\[",
"beginCaptures": {
"0": {
"name": "punctuation.squarebracket.open.cs"
}
},
"end": "]",
"endCaptures": {
"0": {
"name": "punctuation.squarebracket.close.cs"
}
},
"patterns": [
{
"include": "#named-argument"
},
{
"include": "#argument"
},
{
"include": "#punctuation-comma"
}
]
},
"bracketed-parameter-list": {
"begin": "(?=(\\[))",
"beginCaptures": {
"1": {
"name": "punctuation.squarebracket.open.cs"
}
},
"end": "(?=(]))",
"endCaptures": {
"1": {
"name": "punctuation.squarebracket.close.cs"
}
},
"patterns": [
{
"begin": "(?<=\\[)",
"end": "(?=])",
"patterns": [
{
"include": "#comment"
},
{
"include": "#attribute-section"
},
{
"include": "#parameter"
},
{
"include": "#punctuation-comma"
},
{
"include": "#variable-initializer"
}
]
}
]
},
"break-or-continue-statement": {
"match": "(?<!\\.)\\b(break|continue)\\b",
"name": "keyword.control.flow.$1.cs"
},
"case-guard": {
"patterns": [
{
"include": "#parenthesized-expression"
},
{
"include": "#expression"
}
]
},
"cast-expression": {
"captures": {
"1": {
"name": "punctuation.parenthesis.open.cs"
},
"2": {
"patterns": [
{
"include": "#type"
}
]
},
"7": {
"name": "punctuation.parenthesis.close.cs"
}
},
"match": "(\\()\\s*(?<type_name>(?:(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*::\\s*)?(?<name_and_type_args>\\g<identifier>\\s*(?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?)(?:\\s*\\.\\s*\\g<name_and_type_args>)*|(?<tuple>\\s*\\((?:[^()]|\\g<tuple>)+\\)))(?:\\s*\\?\\s*)?(?:\\s*\\[(?:\\s*,\\s*)*]\\s*\\??\\s*)*)\\s*(\\))(?=\\s*-*!*@?[(_[:alnum:]])"
},
"casted-constant-pattern": {
"begin": "(\\()([.:@_\\s[:alnum:]]+)(\\))(?=[-!+~\\s]*@?[\"'(_[:alnum:]]+)",
"beginCaptures": {
"1": {
"name": "punctuation.parenthesis.open.cs"
},
"2": {
"patterns": [
{
"include": "#type-builtin"
},
{
"include": "#type-name"
}
]
},
"3": {
"name": "punctuation.parenthesis.close.cs"
}
},
"end": "(?=[]\\&),:;=?^|}]|!=|\\b(and|or|when)\\b)",
"patterns": [
{
"include": "#casted-constant-pattern"
},
{
"begin": "\\(",
"beginCaptures": {
"0": {
"name": "punctuation.parenthesis.open.cs"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.parenthesis.close.cs"
}
},
"patterns": [
{
"include": "#constant-pattern"
}
]
},
{
"include": "#constant-pattern"
},
{
"captures": {
"1": {
"name": "entity.name.type.alias.cs"
},
"2": {
"name": "punctuation.separator.coloncolon.cs"
}
},
"match": "(@?[_[:alpha:]][_[:alnum:]]*)\\s*(::)"
},
{
"captures": {
"1": {
"name": "entity.name.type.cs"
},
"2": {
"name": "punctuation.accessor.cs"
}
},
"match": "(@?[_[:alpha:]][_[:alnum:]]*)\\s*(\\.)"
},
{
"match": "@?[_[:alpha:]][_[:alnum:]]*",
"name": "variable.other.constant.cs"
}
]
},
"catch-clause": {
"begin": "(?<!\\.)\\b(catch)\\b",
"beginCaptures": {
"1": {
"name": "keyword.control.exception.catch.cs"
}
},
"end": "(?<=})",
"patterns": [
{
"begin": "\\(",
"beginCaptures": {
"0": {
"name": "punctuation.parenthesis.open.cs"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.parenthesis.close.cs"
}
},
"patterns": [
{
"captures": {
"1": {
"patterns": [
{
"include": "#type"
}
]
},
"6": {
"name": "entity.name.variable.local.cs"
}
},
"match": "(?<type_name>(?:(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*::\\s*)?(?<name_and_type_args>\\g<identifier>\\s*(?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?)(?:\\s*\\.\\s*\\g<name_and_type_args>)*|(?<tuple>\\s*\\((?:[^()]|\\g<tuple>)+\\)))(?:\\s*\\?\\s*)?(?:\\s*\\[(?:\\s*,\\s*)*]\\s*\\??\\s*)*)\\s*(?:(\\g<identifier>)\\b)?"
}
]
},
{
"include": "#when-clause"
},
{
"include": "#comment"
},
{
"include": "#block"
}
]
},
"char-character-escape": {
"match": "\\\\(x\\h{1,4}|u\\h{4}|.)",
"name": "constant.character.escape.cs"
},
"char-literal": {
"begin": "'",
"beginCaptures": {
"0": {
"name": "punctuation.definition.char.begin.cs"
}
},
"end": "(')|([^\\n\\\\])$",
"endCaptures": {
"1": {
"name": "punctuation.definition.char.end.cs"
},
"2": {
"name": "invalid.illegal.newline.cs"
}
},
"name": "string.quoted.single.cs",
"patterns": [
{
"include": "#char-character-escape"
}
]
},
"class-declaration": {
"begin": "(?=(\\brecord\\b\\s+)?\\bclass\\b)",
"end": "(?<=})|(?=;)",
"patterns": [
{
"begin": "(\\b(record)\\b\\s+)?\\b(class)\\b\\s+(@?[_[:alpha:]][_[:alnum:]]*)\\s*",
"beginCaptures": {
"2": {
"name": "storage.type.record.cs"
},
"3": {
"name": "storage.type.class.cs"
},
"4": {
"name": "entity.name.type.class.cs"
}
},
"end": "(?=\\{)|(?=;)",
"patterns": [
{
"include": "#comment"
},
{
"include": "#type-parameter-list"
},
{
"include": "#parenthesized-parameter-list"
},
{
"include": "#base-types"
},
{
"include": "#generic-constraints"
}
]
},
{
"begin": "\\{",
"beginCaptures": {
"0": {
"name": "punctuation.curlybrace.open.cs"
}
},
"end": "}",
"endCaptures": {
"0": {
"name": "punctuation.curlybrace.close.cs"
}
},
"patterns": [
{
"include": "#class-or-struct-members"
}
]
},
{
"include": "#preprocessor"
},
{
"include": "#comment"
}
]
},
"class-or-struct-members": {
"patterns": [
{
"include": "#preprocessor"
},
{
"include": "#comment"
},
{
"include": "#storage-modifier"
},
{
"include": "#type-declarations"
},
{
"include": "#property-declaration"
},
{
"include": "#field-declaration"
},
{
"include": "#event-declaration"
},
{
"include": "#indexer-declaration"
},
{
"include": "#variable-initializer"
},
{
"include": "#constructor-declaration"
},
{
"include": "#destructor-declaration"
},
{
"include": "#operator-declaration"
},
{
"include": "#conversion-operator-declaration"
},
{
"include": "#method-declaration"
},
{
"include": "#attribute-section"
},
{
"include": "#punctuation-semicolon"
}
]
},
"combinator-pattern": {
"match": "\\b(and|or|not)\\b",
"name": "keyword.operator.expression.pattern.combinator.$1.cs"
},
"comment": {
"patterns": [
{
"begin": "(^\\s+)?(///)(?!/)",
"captures": {
"1": {
"name": "punctuation.whitespace.comment.leading.cs"
},
"2": {
"name": "punctuation.definition.comment.cs"
}
},
"name": "comment.block.documentation.cs",
"patterns": [
{
"include": "#xml-doc-comment"
}
],
"while": "^(\\s*)(///)(?!/)"
},
{
"begin": "(^\\s+)?(/\\*\\*)(?!/)",
"captures": {
"1": {
"name": "punctuation.whitespace.comment.leading.cs"
},
"2": {
"name": "punctuation.definition.comment.cs"
}
},
"end": "(^\\s+)?(\\*/)",
"name": "comment.block.documentation.cs",
"patterns": [
{
"begin": "\\G(?=(?~\\*/)$)",
"patterns": [
{
"include": "#xml-doc-comment"
}
],
"while": "^(\\s*+)(\\*(?!/))?(?=(?~\\*/)$)",
"whileCaptures": {
"1": {
"name": "punctuation.whitespace.comment.leading.cs"
},
"2": {
"name": "punctuation.definition.comment.cs"
}
}
},
{
"include": "#xml-doc-comment"
}
]
},
{
"begin": "(^\\s+)?(//).*$",
"captures": {
"1": {
"name": "punctuation.whitespace.comment.leading.cs"
},
"2": {
"name": "punctuation.definition.comment.cs"
}
},
"name": "comment.line.double-slash.cs",
"while": "^(\\s*)(//).*$"
},
{
"begin": "/\\*",
"captures": {
"0": {
"name": "punctuation.definition.comment.cs"
}
},
"end": "\\*/",
"name": "comment.block.cs"
}
]
},
"conditional-operator": {
"patterns": [
{
"match": "\\?(?!\\?|\\s*[.\\[])",
"name": "keyword.operator.conditional.question-mark.cs"
},
{
"match": ":",
"name": "keyword.operator.conditional.colon.cs"
}
]
},
"constant-pattern": {
"patterns": [
{
"include": "#boolean-literal"
},
{
"include": "#null-literal"
},
{
"include": "#numeric-literal"
},
{
"include": "#char-literal"
},
{
"include": "#string-literal"
},
{
"include": "#raw-string-literal"
},
{
"include": "#verbatim-string-literal"
},
{
"include": "#type-operator-expression"
},
{
"include": "#expression-operator-expression"
},
{
"include": "#expression-operators"
},
{
"include": "#casted-constant-pattern"
}
]
},
"constructor-declaration": {
"begin": "(?=@?[_[:alpha:]][_[:alnum:]]*\\s*\\()",
"end": "(?<=})|(?=;)",
"patterns": [
{
"captures": {
"1": {
"name": "entity.name.function.cs"
}
},
"match": "(@?[_[:alpha:]][_[:alnum:]]*)\\b"
},
{
"begin": "(:)",
"beginCaptures": {
"1": {
"name": "punctuation.separator.colon.cs"
}
},
"end": "(?=\\{|=>)",
"patterns": [
{
"include": "#constructor-initializer"
}
]
},
{
"include": "#parenthesized-parameter-list"
},
{
"include": "#preprocessor"
},
{
"include": "#comment"
},
{
"include": "#expression-body"
},
{
"include": "#block"
}
]
},
"constructor-initializer": {
"begin": "\\b(base|this)\\b\\s*(?=\\()",
"beginCaptures": {
"1": {
"name": "variable.language.$1.cs"
}
},
"end": "(?<=\\))",
"patterns": [
{
"include": "#argument-list"
}
]
},
"context-control-paren-statement": {
"patterns": [
{
"include": "#fixed-statement"
},
{
"include": "#lock-statement"
},
{
"include": "#using-statement"
}
]
},
"context-control-statement": {
"match": "\\b(checked|unchecked|unsafe)\\b(?!\\s*[(@_[:alpha:]])",
"name": "keyword.control.context.$1.cs"
},
"conversion-operator-declaration": {
"begin": "\\b(?<explicit_or_implicit_keyword>(?:ex|im)plicit)\\s*\\b(?<operator_keyword>operator)\\s*(?<type_name>(?:ref\\s+(?:readonly\\s+)?)?(?:(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*::\\s*)?(?<name_and_type_args>\\g<identifier>\\s*(?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?)(?:\\s*\\.\\s*\\g<name_and_type_args>)*|(?<tuple>\\s*\\((?:[^()]|\\g<tuple>)+\\)))(?:\\s*\\?\\s*)?(?:\\s*\\[(?:\\s*,\\s*)*]\\s*\\??\\s*)*)\\s*(?=\\()",
"beginCaptures": {
"1": {
"patterns": [
{
"captures": {
"1": {
"name": "storage.modifier.explicit.cs"
}
},
"match": "\\b(explicit)\\b"
},
{
"captures": {
"1": {
"name": "storage.modifier.implicit.cs"
}
},
"match": "\\b(implicit)\\b"
}
]
},
"2": {
"name": "storage.type.operator.cs"
},
"3": {
"patterns": [
{
"include": "#type"
}
]
}
},
"end": "(?<=})|(?=;)",
"patterns": [
{
"include": "#comment"
},
{
"include": "#parenthesized-parameter-list"
},
{
"include": "#expression-body"
},
{
"include": "#block"
}
]
},
"declaration-expression-local": {
"captures": {
"1": {
"name": "storage.type.var.cs"
},
"2": {
"patterns": [
{
"include": "#type"
}
]
},
"7": {
"name": "entity.name.variable.local.cs"
}
},
"match": "(?:\\b(var)\\b|(?<type_name>(?:(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*::\\s*)?(?<name_and_type_args>\\g<identifier>\\s*(?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?)(?:\\s*\\.\\s*\\g<name_and_type_args>)*|(?<tuple>\\s*\\((?:[^()]|\\g<tuple>)+\\)))(?:\\s*\\?\\s*)?(?:\\s*\\[(?:\\s*,\\s*)*]\\s*\\??\\s*)*))\\s+(\\g<identifier>)\\b\\s*(?=[]),])"
},
"declaration-expression-tuple": {
"captures": {
"1": {
"name": "storage.type.var.cs"
},
"2": {
"patterns": [
{
"include": "#type"
}
]
},
"7": {
"name": "entity.name.variable.tuple-element.cs"
}
},
"match": "(?:\\b(var)\\b|(?<type_name>(?:(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*::\\s*)?(?<name_and_type_args>\\g<identifier>\\s*(?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?)(?:\\s*\\.\\s*\\g<name_and_type_args>)*|(?<tuple>\\s*\\((?:[^()]|\\g<tuple>)+\\)))(?:\\s*\\?\\s*)?(?:\\s*\\[(?:\\s*,\\s*)*]\\s*\\??\\s*)*))\\s+(\\g<identifier>)\\b\\s*(?=[),])"
},
"declarations": {
"patterns": [
{
"include": "#namespace-declaration"
},
{
"include": "#type-declarations"
},
{
"include": "#punctuation-semicolon"
}
]
},
"default-argument": {
"begin": "=",
"beginCaptures": {
"0": {
"name": "keyword.operator.assignment.cs"
}
},
"end": "(?=[),])",
"patterns": [
{
"include": "#expression"
}
]
},
"default-literal-expression": {
"captures": {
"1": {
"name": "keyword.operator.expression.default.cs"
}
},
"match": "\\b(default)\\b"
},
"delegate-declaration": {
"begin": "\\b(delegate)\\b\\s+(?<type_name>(?:ref\\s+(?:readonly\\s+)?)?(?:(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*::\\s*)?(?<name_and_type_args>\\g<identifier>\\s*(?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?)(?:\\s*\\.\\s*\\g<name_and_type_args>)*|(?<tuple>\\s*\\((?:[^()]|\\g<tuple>)+\\)))(?:\\s*\\?\\s*)?(?:\\s*\\[(?:\\s*,\\s*)*]\\s*\\??\\s*)*)\\s+(\\g<identifier>)\\s*(<([^<>]+)>)?\\s*(?=\\()",
"beginCaptures": {
"1": {
"name": "storage.type.delegate.cs"
},
"2": {
"patterns": [
{
"include": "#type"
}
]
},
"7": {
"name": "entity.name.type.delegate.cs"
},
"8": {
"patterns": [
{
"include": "#type-parameter-list"
}
]
}
},
"end": "(?=;)",
"patterns": [
{
"include": "#comment"
},
{
"include": "#parenthesized-parameter-list"
},
{
"include": "#generic-constraints"
}
]
},
"designation-pattern": {
"patterns": [
{
"include": "#intrusive"
},
{
"begin": "\\(",
"beginCaptures": {
"0": {
"name": "punctuation.parenthesis.open.cs"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.parenthesis.close.cs"
}
},
"patterns": [
{
"include": "#punctuation-comma"
},
{
"include": "#designation-pattern"
}
]
},
{
"include": "#simple-designation-pattern"
}
]
},
"destructor-declaration": {
"begin": "(~)(@?[_[:alpha:]][_[:alnum:]]*)\\s*(?=\\()",
"beginCaptures": {
"1": {
"name": "punctuation.tilde.cs"
},
"2": {
"name": "entity.name.function.cs"
}
},
"end": "(?<=})|(?=;)",
"patterns": [
{
"include": "#comment"
},
{
"include": "#parenthesized-parameter-list"
},
{
"include": "#expression-body"
},
{
"include": "#block"
}
]
},
"directives": {
"patterns": [
{
"include": "#extern-alias-directive"
},
{
"include": "#using-directive"
},
{
"include": "#attribute-section"
},
{
"include": "#punctuation-semicolon"
}
]
},
"discard-pattern": {
"match": "_(?![_[:alnum:]])",
"name": "variable.language.discard.cs"
},
"do-statement": {
"begin": "(?<!\\.)\\b(do)\\b",
"beginCaptures": {
"1": {
"name": "keyword.control.loop.do.cs"
}
},
"end": "(?=[;}])",
"patterns": [
{
"include": "#statement"
}
]
},
"double-raw-interpolation": {
"begin": "(?<=[^{][^{]|^)(\\{*)(\\{\\{)(?=[^{])",
"beginCaptures": {
"1": {
"name": "string.quoted.double.cs"
},
"2": {
"name": "punctuation.definition.interpolation.begin.cs"
}
},
"end": "}}",
"endCaptures": {
"0": {
"name": "punctuation.definition.interpolation.end.cs"
}
},
"name": "meta.interpolation.cs",
"patterns": [
{
"include": "#expression"
}
]
},
"element-access-expression": {
"begin": "(?:(?:(\\?)\\s*)?(\\.)\\s*|(->)\\s*)?(?:(@?[_[:alpha:]][_[:alnum:]]*)\\s*)?(?:(\\?)\\s*)?(?=\\[)",
"beginCaptures": {
"1": {
"name": "keyword.operator.null-conditional.cs"
},
"2": {
"name": "punctuation.accessor.cs"
},
"3": {
"name": "punctuation.accessor.pointer.cs"
},
"4": {
"name": "variable.other.object.property.cs"
},
"5": {
"name": "keyword.operator.null-conditional.cs"
}
},
"end": "(?<=])(?!\\s*\\[)",
"patterns": [
{
"include": "#bracketed-argument-list"
}
]
},
"else-part": {
"begin": "(?<!\\.)\\b(else)\\b",
"beginCaptures": {
"1": {
"name": "keyword.control.conditional.else.cs"
}
},
"end": "(?<=})|(?=;)",
"patterns": [
{
"include": "#statement"
}
]
},
"enum-declaration": {
"begin": "(?=\\benum\\b)",
"end": "(?<=})|(?=;)",
"patterns": [
{
"begin": "(?=enum)",
"end": "(?=\\{)|(?=;)",
"patterns": [
{
"include": "#comment"
},
{
"captures": {
"1": {
"name": "storage.type.enum.cs"
},
"2": {
"name": "entity.name.type.enum.cs"
}
},
"match": "(enum)\\s+(@?[_[:alpha:]][_[:alnum:]]*)"
},
{
"begin": ":",
"beginCaptures": {
"0": {
"name": "punctuation.separator.colon.cs"
}
},
"end": "(?=\\{)",
"patterns": [
{
"include": "#type"
}
]
}
]
},
{
"begin": "\\{",
"beginCaptures": {
"0": {
"name": "punctuation.curlybrace.open.cs"
}
},
"end": "}",
"endCaptures": {
"0": {
"name": "punctuation.curlybrace.close.cs"
}
},
"patterns": [
{
"include": "#preprocessor"
},
{
"include": "#comment"
},
{
"include": "#attribute-section"
},
{
"include": "#punctuation-comma"
},
{
"begin": "@?[_[:alpha:]][_[:alnum:]]*",
"beginCaptures": {
"0": {
"name": "entity.name.variable.enum-member.cs"
}
},
"end": "(?=([,}]))",
"patterns": [
{
"include": "#comment"
},
{
"include": "#variable-initializer"
}
]
}
]
},
{
"include": "#preprocessor"
},
{
"include": "#comment"
}
]
},
"event-accessors": {
"begin": "\\{",
"beginCaptures": {
"0": {
"name": "punctuation.curlybrace.open.cs"
}
},
"end": "}",
"endCaptures": {
"0": {
"name": "punctuation.curlybrace.close.cs"
}
},
"patterns": [
{
"include": "#comment"
},
{
"include": "#attribute-section"
},
{
"begin": "\\b(add|remove)\\b\\s*(?=[;{]|=>|//|/\\*|$)",
"beginCaptures": {
"1": {
"name": "storage.type.accessor.$1.cs"
}
},
"end": "(?<=[;}])|(?=})",
"patterns": [
{
"include": "#accessor-setter"
}
]
}
]
},
"event-declaration": {
"begin": "\\b(event)\\b\\s*(?<return_type>(?<type_name>(?:(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*::\\s*)?(?<name_and_type_args>\\g<identifier>\\s*(?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?)(?:\\s*\\.\\s*\\g<name_and_type_args>)*|(?<tuple>\\s*\\((?:[^()]|\\g<tuple>)+\\)))(?:\\s*\\?\\s*)?(?:\\s*\\[(?:\\s*,\\s*)*]\\s*\\??\\s*)*)\\s+)(?<interface_name>\\g<type_name>\\s*\\.\\s*)?(\\g<identifier>)\\s*(?=[,;={]|//|/\\*|$)",
"beginCaptures": {
"1": {
"name": "storage.type.event.cs"
},
"2": {
"patterns": [
{
"include": "#type"
}
]
},
"8": {
"patterns": [
{
"include": "#type"
},
{
"include": "#punctuation-accessor"
}
]
},
"9": {
"name": "entity.name.variable.event.cs"
}
},
"end": "(?<=})|(?=;)",
"patterns": [
{
"include": "#comment"
},
{
"include": "#event-accessors"
},
{
"match": "@?[_[:alpha:]][_[:alnum:]]*",
"name": "entity.name.variable.event.cs"
},
{
"include": "#punctuation-comma"
},
{
"begin": "=",
"beginCaptures": {
"0": {
"name": "keyword.operator.assignment.cs"
}
},
"end": "(?<=,)|(?=;)",
"patterns": [
{
"include": "#expression"
},
{
"include": "#punctuation-comma"
}
]
}
]
},
"explicit-anonymous-function-parameter": {
"captures": {
"1": {
"name": "storage.modifier.$1.cs"
},
"2": {
"patterns": [
{
"include": "#type"
}
]
},
"7": {
"name": "entity.name.variable.parameter.cs"
}
},
"match": "(?:\\b(ref|params|out|in)\\b\\s*)?(?<type_name>(?:(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*::\\s*)?(?<name_and_type_args>\\g<identifier>\\s*(?<type_args><(?:[^<>]|\\g<type_args>)*>\\s*)?)(?:\\s*\\.\\s*\\g<name_and_type_args>)*|(?<tuple>\\s*\\((?:[^()]|\\g<tuple>)*\\)))(?:\\s*\\?\\s*)?(?:\\s*\\[(?:\\s*,\\s*)*]\\s*\\??\\s*)*)\\s*\\b(\\g<identifier>)\\b"
},
"expression": {
"patterns": [
{
"include": "#preprocessor"
},
{
"include": "#comment"
},
{
"include": "#expression-operator-expression"
},
{
"include": "#type-operator-expression"
},
{
"include": "#default-literal-expression"
},
{
"include": "#throw-expression"
},
{
"include": "#raw-interpolated-string"
},
{
"include": "#interpolated-string"
},
{
"include": "#verbatim-interpolated-string"
},
{
"include": "#type-builtin"
},
{
"include": "#language-variable"
},
{
"include": "#switch-statement-or-expression"
},
{
"include": "#with-expression"
},
{
"include": "#conditional-operator"
},
{
"include": "#assignment-expression"
},
{
"include": "#expression-operators"
},
{
"include": "#await-expression"
},
{
"include": "#query-expression"
},
{
"include": "#as-expression"
},
{
"include": "#is-expression"
},
{
"include": "#anonymous-method-expression"
},
{
"include": "#object-creation-expression"
},
{
"include": "#array-creation-expression"
},
{
"include": "#anonymous-object-creation-expression"
},
{
"include": "#invocation-expression"
},
{
"include": "#member-access-expression"
},
{
"include": "#element-access-expression"
},
{
"include": "#cast-expression"
},
{
"include": "#literal"
},
{
"include": "#parenthesized-expression"
},
{
"include": "#tuple-deconstruction-assignment"
},
{
"include": "#initializer-expression"
},
{
"include": "#identifier"
}
]
},
"expression-body": {
"begin": "=>",
"beginCaptures": {
"0": {
"name": "keyword.operator.arrow.cs"
}
},
"end": "(?=[),;}])",
"patterns": [
{
"include": "#ref-modifier"
},
{
"include": "#expression"
}
]
},
"expression-operator-expression": {
"begin": "\\b(checked|unchecked|nameof)\\s*(\\()",
"beginCaptures": {
"1": {
"name": "keyword.operator.expression.$1.cs"
},
"2": {
"name": "punctuation.parenthesis.open.cs"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.parenthesis.close.cs"
}
},
"patterns": [
{
"include": "#expression"
}
]
},
"expression-operators": {
"patterns": [
{
"match": "<<|>>>?",
"name": "keyword.operator.bitwise.shift.cs"
},
{
"match": "[!=]=",
"name": "keyword.operator.comparison.cs"
},
{
"match": "<=|>=|[<>]",
"name": "keyword.operator.relational.cs"
},
{
"match": "!|&&|\\|\\|",
"name": "keyword.operator.logical.cs"
},
{
"match": "[\\&^|~]",
"name": "keyword.operator.bitwise.cs"
},
{
"match": "--",
"name": "keyword.operator.decrement.cs"
},
{
"match": "\\+\\+",
"name": "keyword.operator.increment.cs"
},
{
"match": "\\+|-(?!>)|[%*/]",
"name": "keyword.operator.arithmetic.cs"
},
{
"match": "\\?\\?",
"name": "keyword.operator.null-coalescing.cs"
},
{
"match": "\\.\\.",
"name": "keyword.operator.range.cs"
}
]
},
"extern-alias-directive": {
"begin": "\\b(extern)\\s+(alias)\\b",
"beginCaptures": {
"1": {
"name": "keyword.other.directive.extern.cs"
},
"2": {
"name": "keyword.other.directive.alias.cs"
}
},
"end": "(?=;)",
"patterns": [
{
"match": "@?[_[:alpha:]][_[:alnum:]]*",
"name": "variable.other.alias.cs"
}
]
},
"field-declaration": {
"begin": "(?<type_name>(?:(?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*::\\s*)?(?<name_and_type_args>\\g<identifier>\\s*(?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?)(?:\\s*\\.\\s*\\g<name_and_type_args>)*|(?<tuple>\\s*\\((?:[^()]|\\g<tuple>)+\\)))(?:\\s*\\?\\s*)?(?:\\s*\\[(?:\\s*,\\s*)*]\\s*\\??\\s*)*)\\s+(\\g<identifier>)\\s*(?!=[=>])(?=[,;=]|$)",
"beginCaptures": {
"1": {
"patterns": [
{
"include": "#type"
}
]
},
"6": {
"name": "entity.name.variable.field.cs"
}
},
"end": "(?=;)",
"patterns": [
{
"match": "@?[_[:alpha:]][_[:alnum:]]*",
"name": "entity.name.variable.field.cs"
},
{
"include": "#punctuation-comma"
},
{
"include": "#comment"
},
{
"include": "#variable-initializer"
},
{
"include": "#class-or-struct-members"
}
]
},
"finally-clause": {
"begin": "(?<!\\.)\\b(finally)\\b",
"beginCaptures": {
"1": {
"name": "keyword.control.exception.finally.cs"
}
},
"end": "(?<=})",
"patterns": [
{
"include": "#comment"
},
{
"include": "#block"
}
]
},
"fixed-statement": {
"begin": "\\b(fixed)\\b",
"beginCaptures": {
"1": {
"name": "keyword.control.context.fixed.cs"
}
},
"end": "(?<=\\))|(?=[;}])",
"patterns": [
{
"include": "#intrusive"
},
{
"begin": "\\(",
"beginCaptures": {
"0": {
"name": "punctuation.parenthesis.open.cs"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.parenthesis.close.cs"
}
},
"patterns": [
{
"include": "#intrusive"
},
{
"include": "#local-variable-declaration"
}
]
}
]
},
"for-statement": {
"begin": "\\b(for)\\b",
"beginCaptures": {
"1": {
"name": "keyword.control.loop.for.cs"
}
},
"end": "(?<=\\))|(?=[;}])",
"patterns": [
{
"begin": "\\(",
"beginCaptures": {
"0": {
"name": "punctuation.parenthesis.open.cs"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.parenthesis.close.cs"
}
},
"patterns": [
{
"begin": "(?=[^);])",
"end": "(?=[);])",
"patterns": [
{
"include": "#intrusive"
},
{
"include": "#local-variable-declaration"
}
]
},
{
"begin": "(?=;)",
"end": "(?=\\))",
"patterns": [
{
"include": "#intrusive"
},
{
"include": "#expression"
},
{
"include": "#punctuation-comma"
},
{
"include": "#punctuation-semicolon"
}
]
}
]
}
]
},
"foreach-statement": {
"begin": "\\b(foreach)\\b",
"beginCaptures": {
"1": {
"name": "keyword.control.loop.foreach.cs"
}
},
"end": "(?<=\\))|(?=[;}])",
"patterns": [
{
"include": "#intrusive"
},
{
"begin": "\\(",
"beginCaptures": {
"0": {
"name": "punctuation.parenthesis.open.cs"
}
},
"end": "\\)",
"endCaptures": {
"0": {
"name": "punctuation.parenthesis.close.cs"
}
},
"patterns": [
{
"include": "#intrusive"
},
{
"captures": {
"1": {
"name": "storage.modifier.ref.cs"
},