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
502 stars 193 forks source link

blazor after visual studio update throws some strange warnings #10896

Open d00lar opened 1 month ago

d00lar commented 1 month ago

Is there an existing issue for this?

Describe the bug

after update visual studio to 17.11.3 in some componentsthat i open VS throw some warning as

Severity    Code    Description Project File    Line    Suppression State
Warning (active)    TS1109  (JS) Expression expected.   Miscellaneous   D:\xxx\Components\Core\DialogConfirmComponent.razor__virtual.html__virtual.js   9   

as on screen enter image description here

the issue is with this:

OnClick="@(async () => await Validate())"> or OnClick="Validate"

i causing this isssue

@onclick="@(async () => await Validate())"> or @onclick="Validate"

this one do not throws the warning

but BOTH should be correct and not throw any warning as OnClick is valid APi call on mudblazor button https://mudblazor.com/api/button#properties

please fix that in visual studio - the error should be different / maybe pointing into correct line at least... ?

why this was valid in older versions ? why it shows the exception now ?

before update there was no such things...?

Expected Behavior

-it should not throw this warning -doubleclick sould take to error line?

Steps To Reproduce

Minimal Reproducible Example

  1. Have 17.11.3 Visual Studio
  2. Dotnet new install MudBlazor.Templates
  3. New project - MudBlazor Web APP (server rendering mode / global)
  4. Open counter component. delete all.
  5. Paste into this counter component

    
    <MudButton Variant="Variant.Filled" Color="Color.Primary"  OnClick="@(()=>blabla())">Validate</MudButton>
    @code {
    
    public void blabla()
    {
    
    }

}



5. Save and see the warning

### Exceptions (if any)

(JS) expression expected.

### .NET Version

8.0.400
davidwengier commented 1 month ago

@dibarbet @MariaSolOs I thought we stamped out all of these in 17.10? Did something change/regress with misc TS files ?

MariaSolOs commented 1 month ago

@dibarbet @MariaSolOs I thought we stamped out all of these in 17.10? Did something change/regress with misc TS files ?

Nothing has changed on the TS side since then. @dibarbet have there been any suspicious modifications to the TS Roslyn client?

d00lar commented 1 month ago

i downgraded to visual studio 17.10.5 and NO WARNINGS so issue is only in 17.11.3.

CrapuleJack commented 1 month ago

I'm seeing the same behavior / problem

Take note, this as nothing to do with MudBlazor as I am not using it in the affected project (we are using Radzen and the error I get are on some internal component we made)

d00lar commented 1 month ago

I'm seeing the same behavior / problem

Take note, this as nothing to do with MudBlazor as I am not using it in the affected project (we are using Radzen and the error I get are on some internal component we made)

i see so it is global issue with OnClick events in components that want to use OnClick and handle itself the event

davidwengier commented 1 month ago

The general cause is attributes that look like JavaScript events, so the JavaScript LSP server analyzes the code and reports errors (which is correct because the C# is not valid JavaScript).

The Razor editor then filters out the errors, because it knows that the code is C# not JavaScript, which is why the error list doesn't have any entries from the razor file itself.

The issue here is that something else is also surfacing the errors directly from the virtual JavaScript documents, which is why the file names in the error list look like that.

d00lar commented 5 days ago

any news on this? :) regards