PrismJS / PrismJS/prism

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

Open
#3,764 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
13k
Forks
1.4k
Avg merge
15h 36m
Merged PRs (30d)
3

Description

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);

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied C# snippet through Prism's C# grammar and inspect how the @ symbol and default are classified. Done means @default is highlighted as an identifier rather than as the default keyword; no specific file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, javascript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.