razor icon indicating copy to clipboard operation
razor copied to clipboard

blazor after visual studio update throws some strange warnings

Open d00lar opened this issue 1 year ago • 6 comments

Is there an existing issue for this?

  • [X] 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

d00lar avatar Sep 17 '24 07:09 d00lar

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

davidwengier avatar Sep 18 '24 03:09 davidwengier

@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?

MariaSolOs avatar Sep 18 '24 03:09 MariaSolOs

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

d00lar avatar Sep 18 '24 10:09 d00lar

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)

CrapuleJack avatar Sep 19 '24 13:09 CrapuleJack

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

d00lar avatar Sep 19 '24 17:09 d00lar

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.

davidwengier avatar Sep 19 '24 22:09 davidwengier

any news on this? :) regards

d00lar avatar Nov 06 '24 08:11 d00lar

phil-allen-msft why it is moved ? is it so hard to fix this?

d00lar avatar Nov 15 '24 18:11 d00lar

This issue is still occurring in VS 17.11.5.

tomairxn avatar Nov 17 '24 20:11 tomairxn

This issue is still occurring in VS 17.12.3

saddamhossain avatar Dec 25 '24 04:12 saddamhossain

We started getting this in VS 17.12.3 when trying to create unit test with bunit. This particular test is for a fairly complicated component, but we've had no luck isolating the offending code. Any word on when/if this will be fixed?

dougclutter avatar Jan 02 '25 15:01 dougclutter

I tried to reproduce the issue using excellent repro provided by @d00lar , but unfortunately unable to reproduce on the latest shipped preview version - 17.13P2

Image

I will try going back to 17.12 to see if it's reproducible there. I would appreciate if folks that can repro this on the latest 17.12 can provide concise repro similar to what @d00lar provided?

alexgav avatar Jan 07 '25 10:01 alexgav

I installed 17.12.3 as well, and still unable to repro using minimal repro steps provided

Image

If someone could share similar simple repro that results in the warnings on 17.12.3 (or 17.13.Preview2) it would really help us investigate. Thank you!

alexgav avatar Jan 07 '25 10:01 alexgav

Hi, everyone!

We’re closing this issue for now. If you encounter the same or a similar problem, please feel free to open a new issue and include detailed reproduction steps to help us investigate.

Thank you for your understanding and support!

jordi1215 avatar Jan 22 '25 18:01 jordi1215