Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS and VS Code Razor Highlighting false negatives #4332

Closed
mikesigs opened this issue Sep 12, 2021 · 8 comments
Closed

VS and VS Code Razor Highlighting false negatives #4332

mikesigs opened this issue Sep 12, 2021 · 8 comments
Labels
bug Something isn't working vs vscode
Milestone

Comments

@mikesigs
Copy link

I am getting started with Blazor this weekend and I'm finding the Razor highlighting in VS Code to be really bad. It's difficult to work on code when your editor is telling you something is wrong, but the compiler is telling you it's right.

Here are a few examples that all compile and run properly, but show a false positive error with RED highlighting:

Inline Ternary Expression

image

Inline Lambda Expression

image

It formats and runs properly without the quotes.
image

Quoted Handler Function

image

Again, this formats and runs properly without the quotes.
image

@mikesigs mikesigs changed the title I am getting started with Blazor this weekend and I'm also finding the Razor highlighting in VS Code to be really bad. It's difficult to work on code when your editor is telling you something is wrong, but the compiler is telling you it's right. VS Code Razor Highlighting false negatives Sep 12, 2021
@javiercn
Copy link
Member

@mikesigs thanks for contacting us.

@NTaylorMullen @ryanbrandenburg can you take a look?

@NTaylorMullen
Copy link
Contributor

NTaylorMullen commented Sep 16, 2021

@mikesigs thanks for the report! We'll be sure to take a peak.

Until we can get VSCode working again for you would you be open to trying Visual Studio 2022 Preview release (assuming you're on windows at least)? Asking because it's free and the issue does not reproduce there.

@allisonchou allisonchou transferred this issue from dotnet/aspnetcore Oct 1, 2021
@allisonchou allisonchou added bug Something isn't working vscode labels Oct 1, 2021
@allisonchou allisonchou added this to the Backlog milestone Oct 1, 2021
@winstliu
Copy link
Contributor

So, some notes:

  • When the tag is not in a codeblock, Textmate doesn't recognize any of the explicit expression as C#. Semantic highlighting sees the @ transition but that's it.
    Explicit C# transition not recognized
  • When the tag is in a codeblock, Textmate sees @onclick as an implicit expression, not an @on{event} attribute. That's when things start to go off the rails because at this point Textmate has no clue we're actually in an attribute, leading to a bunch of "invalid" HTML tokens.
    onevent attribute seen as implicit expression
    HTML falling back to error tokens

I also plan to take a look at this one because it's the other big syntax highlighting issue I noticed when trying out Blazor in VS Code.

@winstliu
Copy link
Contributor

I also plan to take a look at this one

(Did some digging and turns out it was removed intentionally with the new tracking issue being #4323.)

@NTaylorMullen
Copy link
Contributor

I also plan to take a look at this one

(Did some digging and turns out it was removed intentionally with the new tracking issue being #4323.)

Ah not necessarily "intentionally" it's just that in order to make this scenario work for TextMate we'd need to hardcode the understanding of @ based attributes and which ones apply. Currently the Blazor runtime declares runtime based components which tell us which @ attributes are "real" and which ones aren't. Based on that knowledge we apply semantic colorization to override what TextMate views. That being said we don't have that support in VSCode yet.

I think our best case route for this would be to ensure TextMate could recover gracefully to ensure that semantic colorization (when we're able to bring it to VSCode) can change colors without destroying the remainder of the TextMate understanding

@ryanbrandenburg ryanbrandenburg changed the title VS Code Razor Highlighting false negatives VS and VS Code Razor Highlighting false negatives Aug 30, 2022
@ryanbrandenburg
Copy link
Contributor

When we fix this lets be sure to check that it fixes VS's behavior as well.

@rfrancisco
Copy link

rfrancisco commented Apr 23, 2023

Any updates on this issue?

@allisonchou
Copy link
Contributor

This should be fixed via #9336

@ghost ghost locked as resolved and limited conversation to collaborators Nov 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working vs vscode
Projects
None yet
Development

No branches or pull requests

7 participants