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

Razor TextMate grammar does not handle nullability well in @code blocks #4472

Closed
tn-5 opened this issue Aug 11, 2020 · 8 comments · Fixed by #7019
Closed

Razor TextMate grammar does not handle nullability well in @code blocks #4472

tn-5 opened this issue Aug 11, 2020 · 8 comments · Fixed by #7019
Assignees
Labels
bug Something isn't working
Milestone

Comments

@tn-5
Copy link

tn-5 commented Aug 11, 2020

As soon as a property is declared that is of a nullable type, i.e. ? suffix, the syntax highlighting of the rest of the file seems to get confused.

Reproduce

  • Generate standard template project: dotnet new blazorserver
  • Open in VS Code
  • Open FetchData.razor
  • Observe syntax highlighting correctly highlights WeatherForecast as a class/type

Add nullable field

  • Add string? test; before the WeatherForecast declaration
  • Observe that the highlighting of WeatherForecast is still correct

Add nullable property

  • Add string? test1 {get; set;} before the WeatherForecast declaration
  • Observe that the highlighting of WeatherForecastnow reverts to generic text

It does not seem to make any difference if the setting on the project file is enabled or not.

@ChristopherHaws
Copy link

ChristopherHaws commented Sep 16, 2020

I've had to turn off the new Language Services because this has made my tooling completely unusable. I was having to code blind and see if there were errors via build which is no fun.

This project builds successfully but the razor tools break at the ? on line 19:
image

@NTaylorMullen
Copy link
Contributor

@JoeRobich does O#'s C# grammar support this in VSCode?

@JoeRobich
Copy link
Member

No the C# textmate grammar is still quite a bit behind. We would recommend enabling Semantic Highlighting.

@JoeRobich
Copy link
Member

@tn-5 Could you open an issue against https://github.com/dotnet/csharp-tmLanguage?

@marinasundstrom
Copy link

Good. I also noticed this recently.
I think the nullable feature needs some more love in the toolchain if it is gonna be widely adopted.

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

I also have this issue :(

@zeekbrown
Copy link

I am also having this issue as well.

@ryanbrandenburg ryanbrandenburg removed this from the Backlog milestone Oct 17, 2022
@ghost ghost added the untriaged label Oct 17, 2022
@ryanbrandenburg
Copy link
Contributor

A note since it seems to have been lost, the issue was filed against csharp-tmLanguage as dotnet/csharp-tmLanguage#191.

@DustinCampbell DustinCampbell added this to the 17.5 Planning milestone Oct 20, 2022
@ghost ghost removed the untriaged label Oct 20, 2022
@DustinCampbell DustinCampbell changed the title VSCode Razor highlighting does not handle nullability well in @code blocks Razor TextMate grammar does not handle nullability well in @code blocks Oct 20, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.