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
506 stars 196 forks source link

C# comments in HTML text node in switch case statement classifies further HTML text and C# identifiers as C# comments #11249

Open Peter-Juhasz opened 2 days ago

Peter-Juhasz commented 2 days ago

VS 17.13.0 P1 .NET 9.0.100

https://github.com/user-attachments/assets/78d0c135-612d-4e42-94ed-25a10cbdfa1f

Minimal repro, having a simple URL:

Image

@switch (true)
{
    case true:
    {
        <p>this is a text https://example.org<h3>Test</h3></p>
    }
        break;
}

And then look at this with a multi-line comment, this is just ridiculous:

Image

@switch (true)
{
    case true:
    {
        <p>this is a text https:/*example.org<h3>Test</h3></p>
    }
        break;
}

@code {
    private int Something = 0;
}

(Obviously GitHub's syntax highlighter is utterly broken, since it is based on silly regex instead of a proper parser, so it won't display properly. I can only hope based on this phenomenon it is not the case for Razor...)

phil-allen-msft commented 7 hours ago

This may be from syntactic coloring or semantic coloring; if it turns out to be semantic coloring, it may be an issue on the compiler side.