dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
489 stars 190 forks source link

Syntax highlighting for comments in an @inject line is broken #7328

Open Tragetaschen opened 2 years ago

Tragetaschen commented 2 years ago

Describe the bug: I try to add a comment at the end of an @inject line.

Version used: VS2022 17.2 Preview 1

To reproduce:

@inject IEnumerable<int> enumerable // this comment here

The @**@ comment syntax is not available here while the C# syntax is

Expected behavior: Everything after the double slash should be classified/colored as comment

Actual behavior: The last word (here) is not colored. image

NTaylorMullen commented 2 years ago

Lets get an understanding here if this is a Razor compiler issue

ryanbrandenburg commented 2 years ago

Thanks for the report @Tragetaschen!

This is a RazorCompiler issue. What coloration we DO get is coming from TextMate (which get's lost on the last word for some reason, but that's not important). The RazorCompiler reads // onward as UnclassifiedTextLiteral instead of as a CSharpStatementLiteral like it does for the IEnumerable<int> and enumerable words

image

I think the RazorCompiler should either:

  1. Recognize (and classify) this scenario as a C# comment
  2. If a C# comment is not allowed here produce some sort of compiler error or diagnostic indicating that this is unexpected. Something similar to what happens if you try @**@ today: image
ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.