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

[Hot Reload] Source Generator Based Error Breaks Hot Reload #36825

Closed
TanayParikh opened this issue Sep 22, 2021 · 8 comments
Closed

[Hot Reload] Source Generator Based Error Breaks Hot Reload #36825

TanayParikh opened this issue Sep 22, 2021 · 8 comments
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. External This is an issue in a component not contained in this repository. It is open for tracking purposes. feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-hot-reload This issue is related to the Hot Reload feaature
Milestone

Comments

@TanayParikh
Copy link
Contributor

Screen.Recording.2021-09-21.at.8.09.03.PM.mov

Repro:

Start with:

<input type="text" @bind-value="@SomethingWithoutASetter" placeholder="Title">

@code {
    public string SomethingWithoutASetter { get; } = string.Empty;
}

This doesn't give any error in VSCode, but it does give the source generator error:

/Users/tanay/dev/NoteTakingSample2/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Pages_Card_razor.g.cs(250,136): error CS0200: Property or indexer 'Card.SomethingWithoutASetter' cannot be assigned to -- it is read only [/Users/tanay/dev/NoteTakingSample2/NoteTakingSample2.csproj]

However, even after removing the offending <input> tag entirely the source generator error persists (perhaps it should've been marked as a rude edit?). Must exit dotnet watch and restart to resume functionality.

@TanayParikh TanayParikh added bug This issue describes a behavior which is not expected - a bug. area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-hot-reload This issue is related to the Hot Reload feaature labels Sep 22, 2021
@TanayParikh
Copy link
Contributor Author

This doesn't give any error in VSCode, but it does give the source generator error:

/Users/tanay/dev/NoteTakingSample2/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Pages_Card_razor.g.cs(250,136): error CS0200: Property or indexer 'Card.SomethingWithoutASetter' cannot be assigned to -- it is read only [/Users/tanay/dev/NoteTakingSample2/NoteTakingSample2.csproj]

Is this a known issue @NTaylorMullen or should I create a separate issue for the missing VSCode diagnostic?

@NTaylorMullen
Copy link
Contributor

Not a known issue that I know of at least. Sounds like SourceGenerator errors aren't being propagated to the IDE in VSCode? Probably an omnisharp-roslyn thing if I had to guess

@pranavkm
Copy link
Contributor

That's a regular compiler error, no? Does it appear when you do dotnet build?

@mkArtakMSFT mkArtakMSFT added this to the 6.0.0 milestone Sep 22, 2021
@TanayParikh
Copy link
Contributor Author

Not a known issue that I know of at least. Sounds like SourceGenerator errors aren't being propagated to the IDE in VSCode? Probably an omnisharp-roslyn thing if I had to guess

image

Error shows up in the error pane (under generated C# file), which explains why the squiggle isn't there for the .razor file. Do we need to remap?

@pranavkm
Copy link
Contributor

@chsienki this looks like a source generator caching bug. We were able to workaround this by configuring the disable-generator-cache feature. @TanayParikh was using an RTM labeled installer / SDK, so it's possible that the versions there might by out-of-date.

Do you happen to know if there was any recent changes made here that might have regressed this?

@pranavkm pranavkm added the External This is an issue in a component not contained in this repository. It is open for tracking purposes. label Sep 22, 2021
@pranavkm
Copy link
Contributor

FYI @jaredpar since @chsienki is OOF

@jaredpar
Copy link
Member

We were able to workaround this by configuring the disable-generator-cache feature. @TanayParikh was using an RTM labeled installer / SDK, so it's possible that the versions there might by out-of-date.

This definitively means you're using a pre-RC1 version of the compiler. As a part of fixing the caching bug we ripped that option out of the compiler entirely. It was flipped into an opt-in option. Hence if that is fixing the behavior then you're using a compiler that does not have the fix.

@mkArtakMSFT
Copy link
Member

Closing as this is now fixed plus it's (was) a compiler issue

@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. External This is an issue in a component not contained in this repository. It is open for tracking purposes. feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-hot-reload This issue is related to the Hot Reload feaature
Projects
None yet
Development

No branches or pull requests

5 participants