PrismJS / prism

Lightweight, robust, elegant syntax highlighting.

Home Page:https://prismjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C# highlighting is not respecting the @ symbol in front of a parameter.

lananovikova10 opened this issue · comments

commented

Information:

  • Prism version: "1.27.0",
  • Plugins: none
  • Environment: [e.g. Browser, Node, Webpack]

Description
There seems to be a glitch, regarding C# syntax highlighting, not respecting @ symbol before a parameter.

To illustrate, when using the following markdown,

public TChild FirstOfTypeOrDefault(TChild @default = null);

Unexpectedly, 'default' gets highlighted in blue as if it's a keyword.

On the contrary, in this context, '@default' should be treated as a regular parameter and highlighted in black, as '@default' is not a keyword. Therefore, 'default' being highlighted in blue is incorrect.

The expected correct highlighting would treat 'default' as an identifier rather than a keyword, so it should be highlighted in black (or the color assigned for identifiers in your theme) instead of the blue color usually reserved for keywords. This is due to the @ symbol preceding it, which, in C#, effectively makes 'default' a valid identifier instead of a keyword.

Example

public TChild FirstOfTypeOrDefault(TChild @default = null);

The same happens for contextual keywords, e.g. group:

public string SomeMethod(string group)

Group is highlighted in blue as a keyword but it should be black for a parameter name.