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

blazor after visual studio update throws some strange warnings #10896

Open
1 task done
d00lar opened this issue Sep 17, 2024 · 6 comments
Open
1 task done

blazor after visual studio update throws some strange warnings #10896

d00lar opened this issue Sep 17, 2024 · 6 comments

Comments

@d00lar
Copy link

d00lar commented Sep 17, 2024

Is there an existing issue for this?

  • I have searched the existing issues

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()
   {
        
   }

}
  1. Save and see the warning

Exceptions (if any)

(JS) expression expected.

.NET Version

8.0.400

@javiercn javiercn transferred this issue from dotnet/aspnetcore Sep 17, 2024
@davidwengier
Copy link
Contributor

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

@MariaSolOs
Copy link

@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
Copy link
Author

d00lar commented Sep 18, 2024

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

@CrapuleJack
Copy link

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
Copy link
Author

d00lar commented Sep 19, 2024

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants