(csharp) Contextual keywords are highlighted incorrectly
See original GitHub issueDescribe the issue
In C#, there are “contextual keywords”, which are not always treated as keywords. They are highlighted incorrectly in a context where they are not treated as a keyword.
Sample Code to Reproduce
public class Move
{
public Move(Point from, Point to) // from should not be highlighted here.
{
var x = from x in y where x.z == 0 select x; // from is highlighted here. (Note that GitHub handles it correctly)
}
}
Expected behavior
from
isn’t highlighted as a keyword.
Additional context
In other contexts (LINQ query), from
should be highlighted as a keyword.
Note: This issue may not be limited to from
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
C# syntax highlighting incorrect in 1.56 · Issue #123333 - GitHub
The new keyword and constructor name are highlighted incorrectly when a variable is assigned after being declared. When assigned and declared in ...
Read more >C# Keywords - Microsoft Learn
Contextual keywords A contextual keyword is used to provide a specific meaning in the code, but it isn't a reserved word in...
Read more >Could using yield as a contextual keyword ever cause an issue
So my question is: Are there any situations where using yield instead of yield return in C# would have broken backwards compatibility, or ......
Read more >Ten C# Keywords That You Shouldn't Be Using - Simple Thread
1) sealed – I went ahead and put what is probably the most controversial keyword in this list first. Sealed.
Read more >C# syntax highlighting not working - Visual Studio Feedback
I've noticed hit-or-miss C# syntax highlighting in Microsoft Visual Studio Community 2019 Version 16.6. 0. After last update 16.6.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Tagging auto-close… we’re no longing going to leave hard contextual parsing issues open as these are by their nature impossible to fix fully without a full parser. If someone would like to work on a PR for the few simple cases, this would be welcome, but it’s not a reason for such issues to become zombie issues forever.
@Youssef1313 Want to try your hand at a PR? I feel like we need a special rule just for
from
orjoin
that looks ahead and makes sure it hasword word? in
and then remove them from the regular keyword list.I think
in
could stay in the regular list, correct?