UNPKG

shiki

Version:
1,891 lines 138 kB
{ "name": "csharp", "scopeName": "source.cs", "fileTypes": ["cs"], "uuid": "f7de61e2-bdde-4e2a-a139-8221b179584e", "patterns": [ { "include": "#preprocessor" }, { "include": "#comment" }, { "include": "#directives" }, { "include": "#declarations" }, { "include": "#script-top-level" } ], "repository": { "directives": { "patterns": [ { "include": "#extern-alias-directive" }, { "include": "#using-directive" }, { "include": "#attribute-section" }, { "include": "#punctuation-semicolon" } ] }, "declarations": { "patterns": [ { "include": "#namespace-declaration" }, { "include": "#type-declarations" }, { "include": "#punctuation-semicolon" } ] }, "script-top-level": { "patterns": [ { "include": "#method-declaration" }, { "include": "#statement" }, { "include": "#punctuation-semicolon" } ] }, "type-declarations": { "patterns": [ { "include": "#preprocessor" }, { "include": "#comment" }, { "include": "#storage-modifier" }, { "include": "#class-declaration" }, { "include": "#delegate-declaration" }, { "include": "#enum-declaration" }, { "include": "#interface-declaration" }, { "include": "#record-declaration" }, { "include": "#struct-declaration" }, { "include": "#attribute-section" }, { "include": "#punctuation-semicolon" } ] }, "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" } ] }, "interface-members": { "patterns": [ { "include": "#preprocessor" }, { "include": "#comment" }, { "include": "#property-declaration" }, { "include": "#event-declaration" }, { "include": "#indexer-declaration" }, { "include": "#method-declaration" }, { "include": "#attribute-section" }, { "include": "#punctuation-semicolon" } ] }, "statement": { "patterns": [ { "include": "#preprocessor" }, { "include": "#comment" }, { "include": "#while-statement" }, { "include": "#do-statement" }, { "include": "#for-statement" }, { "include": "#foreach-statement" }, { "include": "#if-statement" }, { "include": "#else-part" }, { "include": "#switch-statement" }, { "include": "#goto-statement" }, { "include": "#return-statement" }, { "include": "#break-or-continue-statement" }, { "include": "#throw-statement" }, { "include": "#yield-statement" }, { "include": "#await-statement" }, { "include": "#try-statement" }, { "include": "#checked-unchecked-statement" }, { "include": "#lock-statement" }, { "include": "#using-statement" }, { "include": "#labeled-statement" }, { "include": "#object-creation-expression" }, { "include": "#array-creation-expression" }, { "include": "#anonymous-object-creation-expression" }, { "include": "#local-declaration" }, { "include": "#block" }, { "include": "#expression" }, { "include": "#punctuation-semicolon" } ] }, "expression": { "patterns": [ { "include": "#preprocessor" }, { "include": "#comment" }, { "include": "#checked-unchecked-expression" }, { "include": "#typeof-or-default-expression" }, { "include": "#nameof-expression" }, { "include": "#throw-expression" }, { "include": "#raw-interpolated-string" }, { "include": "#interpolated-string" }, { "include": "#verbatim-interpolated-string" }, { "include": "#this-or-base-expression" }, { "include": "#switch-expression" }, { "include": "#conditional-operator" }, { "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" } ] }, "extern-alias-directive": { "begin": "\\s*(extern)\\b\\s*(alias)\\b\\s*(@?[_[:alpha:]][_[:alnum:]]*)", "beginCaptures": { "1": { "name": "keyword.other.extern.cs" }, "2": { "name": "keyword.other.alias.cs" }, "3": { "name": "variable.other.alias.cs" } }, "end": "(?=;)" }, "using-directive": { "patterns": [ { "begin": "\\b(using)\\b\\s+(static)\\s+", "beginCaptures": { "1": { "name": "keyword.other.using.cs" }, "2": { "name": "keyword.other.static.cs" } }, "end": "(?=;)", "patterns": [ { "include": "#type" } ] }, { "begin": "\\b(using)\\s+(?=(@?[_[:alpha:]][_[:alnum:]]*)\\s*=)", "beginCaptures": { "1": { "name": "keyword.other.using.cs" }, "2": { "name": "entity.name.type.alias.cs" } }, "end": "(?=;)", "patterns": [ { "include": "#comment" }, { "include": "#type" }, { "include": "#operator-assignment" } ] }, { "begin": "\\b(using)\\s*", "beginCaptures": { "1": { "name": "keyword.other.using.cs" } }, "end": "(?=;)", "patterns": [ { "include": "#comment" }, { "name": "entity.name.type.namespace.cs", "match": "@?[_[:alpha:]][_[:alnum:]]*" }, { "include": "#operator-assignment" } ] } ] }, "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" } ] }, "attribute": { "patterns": [ { "include": "#type-name" }, { "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" } ] }, "namespace-declaration": { "begin": "\\b(namespace)\\s+", "beginCaptures": { "1": { "name": "keyword.other.namespace.cs" } }, "end": "(?<=\\})|(?=;)", "patterns": [ { "include": "#comment" }, { "name": "entity.name.type.namespace.cs", "match": "@?[_[:alpha:]][_[:alnum:]]*" }, { "include": "#punctuation-accessor" }, { "begin": "\\{", "beginCaptures": { "0": { "name": "punctuation.curlybrace.open.cs" } }, "end": "\\}", "endCaptures": { "0": { "name": "punctuation.curlybrace.close.cs" } }, "patterns": [ { "include": "#declarations" }, { "include": "#using-directive" }, { "include": "#punctuation-semicolon" } ] } ] }, "storage-modifier": { "name": "storage.modifier.cs", "match": "(?<!\\.)\\b(new|public|protected|internal|private|abstract|virtual|override|sealed|static|partial|readonly|volatile|const|extern|async|unsafe|ref|required)\\b" }, "class-declaration": { "begin": "(?=\\bclass\\b)", "end": "(?<=\\})", "patterns": [ { "begin": "(?x)\n\\b(class)\\b\\s+\n(@?[_[:alpha:]][_[:alnum:]]*)\\s*", "beginCaptures": { "1": { "name": "keyword.other.class.cs" }, "2": { "name": "entity.name.type.class.cs" } }, "end": "(?=\\{)", "patterns": [ { "include": "#comment" }, { "include": "#type-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" } ] }, "delegate-declaration": { "begin": "(?x)\n(?:\\b(delegate)\\b)\\s+\n(?<type_name>\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref return\n (?:\n (?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (?<name_and_type_args> # identifier + type arguments (if any)\n \\g<identifier>\\s*\n (?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g<name_and_type_args>)* | # Are there any more names being dotted into?\n (?<tuple>\\s*\\((?:[^\\(\\)]|\\g<tuple>)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s+\n(\\g<identifier>)\\s*\n(<([^<>]+)>)?\\s*\n(?=\\()", "beginCaptures": { "1": { "name": "keyword.other.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" } ] }, "enum-declaration": { "begin": "(?=\\benum\\b)", "end": "(?<=\\})", "patterns": [ { "begin": "(?=enum)", "end": "(?=\\{)", "patterns": [ { "include": "#comment" }, { "match": "(enum)\\s+(@?[_[:alpha:]][_[:alnum:]]*)", "captures": { "1": { "name": "keyword.other.enum.cs" }, "2": { "name": "entity.name.type.enum.cs" } } }, { "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" } ] }, "interface-declaration": { "begin": "(?=\\binterface\\b)", "end": "(?<=\\})", "patterns": [ { "begin": "(?x)\n(interface)\\b\\s+\n(@?[_[:alpha:]][_[:alnum:]]*)", "beginCaptures": { "1": { "name": "keyword.other.interface.cs" }, "2": { "name": "entity.name.type.interface.cs" } }, "end": "(?=\\{)", "patterns": [ { "include": "#comment" }, { "include": "#type-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": "#interface-members" } ] }, { "include": "#preprocessor" }, { "include": "#comment" } ] }, "record-declaration": { "begin": "(?=\\brecord\\b)", "end": "(?<=\\})", "patterns": [ { "begin": "(?x)\n(record)\\b\\s+\n(@?[_[:alpha:]][_[:alnum:]]*)", "beginCaptures": { "1": { "name": "keyword.other.record.cs" }, "2": { "name": "entity.name.type.record.cs" } }, "end": "(?=\\{)", "patterns": [ { "include": "#comment" }, { "include": "#type-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" } ] }, "struct-declaration": { "begin": "(?=\\bstruct\\b)", "end": "(?<=\\})", "patterns": [ { "begin": "(?x)\n(struct)\\b\\s+\n(@?[_[:alpha:]][_[:alnum:]]*)", "beginCaptures": { "1": { "name": "keyword.other.struct.cs" }, "2": { "name": "entity.name.type.struct.cs" } }, "end": "(?=\\{)", "patterns": [ { "include": "#comment" }, { "include": "#type-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" } ] }, "type-parameter-list": { "begin": "\\<", "beginCaptures": { "0": { "name": "punctuation.definition.typeparameters.begin.cs" } }, "end": "\\>", "endCaptures": { "0": { "name": "punctuation.definition.typeparameters.end.cs" } }, "patterns": [ { "match": "\\b(in|out)\\b", "captures": { "1": { "name": "storage.modifier.cs" } } }, { "match": "(@?[_[:alpha:]][_[:alnum:]]*)\\b", "captures": { "1": { "name": "entity.name.type.type-parameter.cs" } } }, { "include": "#comment" }, { "include": "#punctuation-comma" }, { "include": "#attribute-section" } ] }, "base-types": { "begin": ":", "beginCaptures": { "0": { "name": "punctuation.separator.colon.cs" } }, "end": "(?=\\{|where)", "patterns": [ { "include": "#type" }, { "include": "#punctuation-comma" }, { "include": "#preprocessor" } ] }, "generic-constraints": { "begin": "(where)\\s+(@?[_[:alpha:]][_[:alnum:]]*)\\s*(:)", "beginCaptures": { "1": { "name": "keyword.other.where.cs" }, "2": { "name": "entity.name.type.type-parameter.cs" }, "3": { "name": "punctuation.separator.colon.cs" } }, "end": "(?=\\{|where|;|=>)", "patterns": [ { "name": "keyword.other.class.cs", "match": "\\bclass\\b" }, { "name": "keyword.other.struct.cs", "match": "\\bstruct\\b" }, { "match": "(new)\\s*(\\()\\s*(\\))", "captures": { "1": { "name": "keyword.other.new.cs" }, "2": { "name": "punctuation.parenthesis.open.cs" }, "3": { "name": "punctuation.parenthesis.close.cs" } } }, { "include": "#type" }, { "include": "#punctuation-comma" }, { "include": "#generic-constraints" } ] }, "field-declaration": { "begin": "(?x)\n(?<type_name>\n (?:\n (?:\n (?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (?<name_and_type_args> # identifier + type arguments (if any)\n \\g<identifier>\\s*\n (?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g<name_and_type_args>)* | # Are there any more names being dotted into?\n (?<tuple>\\s*\\((?:[^\\(\\)]|\\g<tuple>)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s+\n(\\g<identifier>)\\s* # first field name\n(?!=>|==)(?=,|;|=|$)", "beginCaptures": { "1": { "patterns": [ { "include": "#type" } ] }, "6": { "name": "entity.name.variable.field.cs" } }, "end": "(?=;)", "patterns": [ { "name": "entity.name.variable.field.cs", "match": "@?[_[:alpha:]][_[:alnum:]]*" }, { "include": "#punctuation-comma" }, { "include": "#comment" }, { "include": "#variable-initializer" }, { "include": "#class-or-struct-members" } ] }, "property-declaration": { "begin": "(?x)\n\n# The negative lookahead below ensures that we don't match nested types\n# or other declarations as properties.\n(?![[:word:][:space:]]*\\b(?:class|interface|struct|enum|event)\\b)\n\n(?<return_type>\n (?<type_name>\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref return\n (?:\n (?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (?<name_and_type_args> # identifier + type arguments (if any)\n \\g<identifier>\\s*\n (?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g<name_and_type_args>)* | # Are there any more names being dotted into?\n (?<tuple>\\s*\\((?:[^\\(\\)]|\\g<tuple>)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\\s+\n)\n(?<interface_name>\\g<type_name>\\s*\\.\\s*)?\n(?<property_name>\\g<identifier>)\\s*\n(?=\\{|=>|$)", "beginCaptures": { "1": { "patterns": [ { "include": "#type" } ] }, "7": { "patterns": [ { "include": "#type" }, { "include": "#punctuation-accessor" } ] }, "8": { "name": "entity.name.variable.property.cs" } }, "end": "(?<=\\})|(?=;)", "patterns": [ { "include": "#comment" }, { "include": "#property-accessors" }, { "include": "#expression-body" }, { "include": "#variable-initializer" }, { "include": "#class-or-struct-members" } ] }, "indexer-declaration": { "begin": "(?x)\n(?<return_type>\n (?<type_name>\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref return\n (?:\n (?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (?<name_and_type_args> # identifier + type arguments (if any)\n \\g<identifier>\\s*\n (?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g<name_and_type_args>)* | # Are there any more names being dotted into?\n (?<tuple>\\s*\\((?:[^\\(\\)]|\\g<tuple>)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\\s+\n)\n(?<interface_name>\\g<type_name>\\s*\\.\\s*)?\n(?<indexer_name>this)\\s*\n(?=\\[)", "beginCaptures": { "1": { "patterns": [ { "include": "#type" } ] }, "7": { "patterns": [ { "include": "#type" }, { "include": "#punctuation-accessor" } ] }, "8": { "name": "keyword.other.this.cs" } }, "end": "(?<=\\})|(?=;)", "patterns": [ { "include": "#comment" }, { "include": "#bracketed-parameter-list" }, { "include": "#property-accessors" }, { "include": "#expression-body" }, { "include": "#variable-initializer" } ] }, "event-declaration": { "begin": "(?x)\n\\b(event)\\b\\s*\n(?<return_type>\n (?<type_name>\n (?:\n (?:\n (?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (?<name_and_type_args> # identifier + type arguments (if any)\n \\g<identifier>\\s*\n (?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g<name_and_type_args>)* | # Are there any more names being dotted into?\n (?<tuple>\\s*\\((?:[^\\(\\)]|\\g<tuple>)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\\s+\n)\n(?<interface_name>\\g<type_name>\\s*\\.\\s*)?\n(?<event_names>\\g<identifier>(?:\\s*,\\s*\\g<identifier>)*)\\s*\n(?=\\{|;|$)", "beginCaptures": { "1": { "name": "keyword.other.event.cs" }, "2": { "patterns": [ { "include": "#type" } ] }, "8": { "patterns": [ { "include": "#type" }, { "include": "#punctuation-accessor" } ] }, "9": { "patterns": [ { "name": "entity.name.variable.event.cs", "match": "@?[_[:alpha:]][_[:alnum:]]*" }, { "include": "#punctuation-comma" } ] } }, "end": "(?<=\\})|(?=;)", "patterns": [ { "include": "#comment" }, { "include": "#event-accessors" }, { "include": "#punctuation-comma" } ] }, "property-accessors": { "begin": "\\{", "beginCaptures": { "0": { "name": "punctuation.curlybrace.open.cs" } }, "end": "\\}", "endCaptures": { "0": { "name": "punctuation.curlybrace.close.cs" } }, "patterns": [ { "name": "storage.modifier.cs", "match": "\\b(private|protected|internal)\\b" }, { "name": "keyword.other.get.cs", "match": "\\b(get)\\b" }, { "name": "keyword.other.set.cs", "match": "\\b(set)\\b" }, { "name": "keyword.other.init.cs", "match": "\\b(init)\\b" }, { "include": "#comment" }, { "include": "#attribute-section" }, { "include": "#expression-body" }, { "include": "#block" }, { "include": "#punctuation-semicolon" } ] }, "event-accessors": { "begin": "\\{", "beginCaptures": { "0": { "name": "punctuation.curlybrace.open.cs" } }, "end": "\\}", "endCaptures": { "0": { "name": "punctuation.curlybrace.close.cs" } }, "patterns": [ { "name": "keyword.other.add.cs", "match": "\\b(add)\\b" }, { "name": "keyword.other.remove.cs", "match": "\\b(remove)\\b" }, { "include": "#comment" }, { "include": "#attribute-section" }, { "include": "#expression-body" }, { "include": "#block" }, { "include": "#punctuation-semicolon" } ] }, "method-declaration": { "begin": "(?x)\n(?<return_type>\n (?<type_name>\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref return\n (?:\n (?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (?<name_and_type_args> # identifier + type arguments (if any)\n \\g<identifier>\\s*\n (?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g<name_and_type_args>)* | # Are there any more names being dotted into?\n (?<tuple>\\s*\\((?:[^\\(\\)]|\\g<tuple>)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n )\\s+\n)\n(?<interface_name>\\g<type_name>\\s*\\.\\s*)?\n(\\g<identifier>)\\s*\n(<([^<>]+)>)?\\s*\n(?=\\()", "beginCaptures": { "1": { "patterns": [ { "include": "#type" } ] }, "7": { "patterns": [ { "include": "#type" }, { "include": "#punctuation-accessor" } ] }, "8": { "name": "entity.name.function.cs" }, "9": { "patterns": [ { "include": "#type-parameter-list" } ] } }, "end": "(?<=\\})|(?=;)", "patterns": [ { "include": "#comment" }, { "include": "#parenthesized-parameter-list" }, { "include": "#generic-constraints" }, { "include": "#expression-body" }, { "include": "#block" } ] }, "constructor-declaration": { "begin": "(?=@?[_[:alpha:]][_[:alnum:]]*\\s*\\()", "end": "(?<=\\})|(?=;)", "patterns": [ { "match": "(@?[_[:alpha:]][_[:alnum:]]*)\\b", "captures": { "1": { "name": "entity.name.function.cs" } } }, { "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": "keyword.other.base.cs" }, "2": { "name": "keyword.other.this.cs" } }, "end": "(?<=\\))", "patterns": [ { "include": "#argument-list" } ] }, "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" } ] }, "operator-declaration": { "begin": "(?x)\n(?<type_name>\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref return\n (?:\n (?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (?<name_and_type_args> # identifier + type arguments (if any)\n \\g<identifier>\\s*\n (?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g<name_and_type_args>)* | # Are there any more names being dotted into?\n (?<tuple>\\s*\\((?:[^\\(\\)]|\\g<tuple>)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s*\n(?<operator_keyword>(?:\\b(?:operator)))\\s*\n(?<operator>(?:\\+|-|\\*|/|%|&|\\||\\^|\\<\\<|\\>\\>|==|!=|\\>|\\<|\\>=|\\<=|!|~|\\+\\+|--|true|false))\\s*\n(?=\\()", "beginCaptures": { "1": { "patterns": [ { "include": "#type" } ] }, "6": { "name": "keyword.other.operator-decl.cs" }, "7": { "name": "entity.name.function.cs" } }, "end": "(?<=\\})|(?=;)", "patterns": [ { "include": "#comment" }, { "include": "#parenthesized-parameter-list" }, { "include": "#expression-body" }, { "include": "#block" } ] }, "conversion-operator-declaration": { "begin": "(?x)\n(?<explicit_or_implicit_keyword>(?:\\b(?:explicit|implicit)))\\s*\n(?<operator_keyword>(?:\\b(?:operator)))\\s*\n(?<type_name>\n (?:\n (?:ref\\s+(?:readonly\\s+)?)? # ref return\n (?:\n (?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (?<name_and_type_args> # identifier + type arguments (if any)\n \\g<identifier>\\s*\n (?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g<name_and_type_args>)* | # Are there any more names being dotted into?\n (?<tuple>\\s*\\((?:[^\\(\\)]|\\g<tuple>)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s*\n(?=\\()", "beginCaptures": { "1": { "patterns": [ { "match": "\\b(explicit)\\b", "captures": { "1": { "name": "keyword.other.explicit.cs" } } }, { "match": "\\b(implicit)\\b", "captures": { "1": { "name": "keyword.other.implicit.cs" } } } ] }, "2": { "name": "keyword.other.operator-decl.cs" }, "3": { "patterns": [ { "include": "#type" } ] } }, "end": "(?<=\\})|(?=;)", "patterns": [ { "include": "#comment" }, { "include": "#parenthesized-parameter-list" }, { "include": "#expression-body" }, { "include": "#block" } ] }, "block": { "begin": "\\{", "beginCaptures": { "0": { "name": "punctuation.curlybrace.open.cs" } }, "end": "\\}", "endCaptures": { "0": { "name": "punctuation.curlybrace.close.cs" } }, "patterns": [ { "include": "#statement" } ] }, "variable-initializer": { "begin": "(?<!=|!)(=)(?!=|>)", "beginCaptures": { "1": { "name": "keyword.operator.assignment.cs" } }, "end": "(?=[,\\)\\];}])", "patterns": [ { "include": "#ref-modifier" }, { "include": "#expression" } ] }, "expression-body": { "begin": "=>", "beginCaptures": { "0": { "name": "keyword.operator.arrow.cs" } }, "end": "(?=[,\\);}])", "patterns": [ { "include": "#ref-modifier" }, { "include": "#expression" } ] }, "goto-statement": { "begin": "(?<!\\.)\\b(goto)\\b", "beginCaptures": { "1": { "name": "keyword.control.goto.cs" } }, "end": "(?=;)", "patterns": [ { "begin": "\\b(case)\\b", "beginCaptures": { "1": { "name": "keyword.control.case.cs" } }, "end": "(?=;)", "patterns": [ { "include": "#expression" } ] }, { "match": "\\b(default)\\b", "captures": { "1": { "name": "keyword.control.default.cs" } } }, { "name": "entity.name.label.cs", "match": "@?[_[:alpha:]][_[:alnum:]]*" } ] }, "return-statement": { "begin": "(?<!\\.)\\b(return)\\b", "beginCaptures": { "1": { "name": "keyword.control.flow.return.cs" } }, "end": "(?=;)", "patterns": [ { "include": "#ref-modifier" }, { "include": "#expression" } ] }, "break-or-continue-statement": { "match": "(?<!\\.)\\b(?:(break)|(continue))\\b", "captures": { "1": { "name": "keyword.control.flow.break.cs" }, "2": { "name": "keyword.control.flow.continue.cs" } } }, "throw-statement": { "begin": "(?<!\\.)\\b(throw)\\b", "beginCaptures": { "1": { "name": "keyword.control.flow.throw.cs" } }, "end": "(?=;)", "patterns": [ { "include": "#expression" } ] }, "yield-statement": { "patterns": [ { "include": "#yield-return-statement" }, { "include": "#yield-break-statement" } ] }, "yield-return-statement": { "begin": "(?<!\\.)\\b(yield)\\b\\s*\\b(return)\\b", "beginCaptures": { "1": { "name": "keyword.control.flow.yield.cs" }, "2": { "name": "keyword.control.flow.return.cs" } }, "end": "(?=;)", "patterns": [ { "include": "#expression" } ] }, "yield-break-statement": { "match": "(?<!\\.)\\b(yield)\\b\\s*\\b(break)\\b", "captures": { "1": { "name": "keyword.control.flow.yield.cs" }, "2": { "name": "keyword.control.flow.break.cs" } } }, "await-statement": { "begin": "(?<!\\.)\\b(await)\\b", "beginCaptures": { "1": { "name": "keyword.other.await.cs" } }, "end": "(?=;)", "patterns": [ { "include": "#statement" } ] }, "if-statement": { "begin": "(?<!\\.)\\b(if)\\b\\s*(?=\\()", "beginCaptures": { "1": { "name": "keyword.control.conditional.if.cs" } }, "end": "(?<=\\})|(?=;)", "patterns": [ { "begin": "\\(", "beginCaptures": { "0": { "name": "punctuation.parenthesis.open.cs" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.parenthesis.close.cs" } }, "patterns": [ { "include": "#expression" } ] }, { "include": "#statement" } ] }, "else-part": { "begin": "(?<!\\.)\\b(else)\\b", "beginCaptures": { "1": { "name": "keyword.control.conditional.else.cs" } }, "end": "(?<=\\})|(?=;)", "patterns": [ { "include": "#statement" } ] }, "switch-statement": { "begin": "(?<!\\.)\\b(switch)\\b\\s*(?=\\()", "beginCaptures": { "1": { "name": "keyword.control.switch.cs" } }, "end": "(?<=\\})", "patterns": [ { "begin": "\\(", "beginCaptures": { "0": { "name": "punctuation.parenthesis.open.cs" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.parenthesis.close.cs" } }, "patterns": [ { "include": "#expression" } ] }, { "begin": "\\{", "beginCaptures": { "0": { "name": "punctuation.curlybrace.open.cs" } }, "end": "\\}", "endCaptures": { "0": { "name": "punctuation.curlybrace.close.cs" } }, "patterns": [ { "include": "#switch-label" }, { "include": "#statement" } ] } ] }, "switch-expression": { "begin": "(?x) (?<!\\.)\\b(switch)\\b", "beginCaptures": { "1": { "name": "keyword.control.switch.cs" } }, "end": "(?<=\\})", "endCaptures": { "0": { "name": "punctuation.curlybrace.close.cs" } }, "patterns": [ { "begin": "\\{", "beginCaptures": { "0": { "name": "punctuation.curlybrace.open.cs" } }, "end": "\\}", "endCaptures": { "0": { "name": "punctuation.curlybrace.close.cs" } }, "patterns": [ { "include": "#comment" }, { "include": "#literal" }, { "include": "#switch-var-pattern" }, { "include": "#switch-property-expression" }, { "include": "#member-access-expression" }, { "include": "#switch-pattern" }, { "include": "#expression-body" }, { "include": "#punctuation-comma" } ] } ] }, "switch-pattern": { "begin": "(?x) # e.g. int x OR var x\n(?<type_name>\n (?:\n (?:\n (?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (?<name_and_type_args> # identifier + type arguments (if any)\n \\g<identifier>\\s*\n (?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g<name_and_type_args>)* | # Are there any more names being dotted into?\n (?<tuple>\\s*\\((?:[^\\(\\)]|\\g<tuple>)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)\\s+\n(\\g<identifier>)\\b\\s*", "beginCaptures": { "1": { "patterns": [ { "include": "#type" } ] }, "2": { "name": "entity.name.variable.local.cs" } }, "end": "(?==>)", "patterns": [ { "include": "#comment" }, { "include": "#switch-when-clause" } ] }, "switch-property-expression": { "begin": "(?x) # e.g. int x OR var x\n(?<type_name>\n (?:\n (?:\n (?:(?<identifier>@?[_[:alpha:]][_[:alnum:]]*)\\s*\\:\\:\\s*)? # alias-qualification\n (?<name_and_type_args> # identifier + type arguments (if any)\n \\g<identifier>\\s*\n (?<type_args>\\s*<(?:[^<>]|\\g<type_args>)+>\\s*)?\n )\n (?:\\s*\\.\\s*\\g<name_and_type_args>)* | # Are there any more names being dotted into?\n (?<tuple>\\s*\\((?:[^\\(\\)]|\\g<tuple>)+\\))\n )\n (?:\\s*\\?\\s*)? # nullable suffix?\n (?:\\s* # array suffix?\n \\[\n (?:\\s*,\\s*)* # commata for multi-dimensional arrays\n \\]\n \\s*\n (?:\\?)? # arrays can be nullable reference types\n \\s*\n )*\n )\n)?\\s*\n(\\{)", "beginCaptures": { "1": { "patterns": [ { "include": "#type" } ] }, "6": { "name": "punctuation.curlybrace.open.cs" } }, "end": "\\}", "endCaptures