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

dotnet watch is not picking up changes on .cshtml files using Razor Pages #67243

Closed
jeffpapp opened this issue Feb 27, 2023 · 5 comments · Fixed by #70501
Closed

dotnet watch is not picking up changes on .cshtml files using Razor Pages #67243

jeffpapp opened this issue Feb 27, 2023 · 5 comments · Fixed by #70501

Comments

@jeffpapp
Copy link

Describe the bug

I have dotnet watch running, and when I edit and save a .cshtml file it detects the file change but then reports no changes to apply.

dotnet watch ⌚ File changed: .\<Path to file>.cshtml.
dotnet watch ⌚ No hot reload changes to apply.

I have to kill dotnet watch and restart to pickup my changes.

I have a Microsoft_CodeAnalysis_EditAndContinue_LogDir set and I get a Blocked update status, but the only error I get is The using directive for 'XXX' appeared previously as global using.

Here is the full log with project information removed

EmitSolutionUpdate: '<null>'
Found 1 potentially changed document(s) in project '<Path to Project>.csproj'
Project summary for '<Path to Project>.csproj': ValidChanges
Document changed, added, or deleted: 'Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_<FileName>_cshtml.g.cs'
Emitting update of '<Path to Project>.csproj'
Solution update status: Blocked
Solution update diagnostics: dotnet/sdk#1 [<Path to Project>.csproj: 
<Path to file>.cs(8,7): hidden CS8933: The using directive for '<TYPE>' appeared previously as global using, ...]

Further technical details

  • Include the output of dotnet --info
.NET SDK:
 Version:   7.0.201
 Commit:    68f2d7e7a3

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19044
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.201\

Host:
  Version:      7.0.3
  Architecture: x64
  Commit:       0a2bda10e8

.NET SDKs installed:
  6.0.301 [C:\Program Files\dotnet\sdk]
  6.0.305 [C:\Program Files\dotnet\sdk]
  6.0.309 [C:\Program Files\dotnet\sdk]
  7.0.100 [C:\Program Files\dotnet\sdk]
  7.0.103 [C:\Program Files\dotnet\sdk]
  7.0.200 [C:\Program Files\dotnet\sdk]
  7.0.201 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  C:\Projects\AOPlus\global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
    • Running VS 17.5
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Feb 27, 2023
@jeffpapp
Copy link
Author

Even after cleaning up all unnecessary using statements in my codebase I still get the same behavior with this in the log file which I have no control over

Solution update diagnostics: dotnet/sdk#1 [<Path>.csproj: <Path>\obj\Debug\net7.0\.NETCoreApp,Version=v7.0.AssemblyAttributes.cs(2,7): hidden CS8933: The using directive for 'System' appeared previously as global using, ...]

@jeffpapp
Copy link
Author

I have narrowed down at least one issue to an ASP.NET Core Minimal API endpoint with a method parameter with a default value.

See the attached sample project.

Running dotnet watch and then changing some text on the Index.cshtml page will results in dotnet watch ⌚ No hot reload changes to apply.

Remove line 18 in Program.cs and run again and hot reload will start working.

Even keeping line 18 in Program.cs and removing the = false on the bool parameter in Endpoints.cs works.

Hopefully this is helpful to narrow down the issue

WebApplication6.zip

@tmat tmat self-assigned this Feb 28, 2023
@tmat
Copy link
Member

tmat commented Mar 1, 2023

I think this is a combination of reloadable types and anonymous delegates.

Never mind, it's an issue with anonymous delegates #57295.

@tmat tmat transferred this issue from dotnet/sdk Mar 9, 2023
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@tmat
Copy link
Member

tmat commented Mar 9, 2023

The compiler crashes (NRE) in

> Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Symbols.AnonymousTypeManager.AnonymousTypeOrDelegateTemplateSymbol.Name.get() Line 135    C# 

Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.TryFindAnonymousDelegateWithIndexedName(Microsoft.CodeAnalysis.CSharp.Symbols.AnonymousTypeManager.AnonymousDelegateTemplateSymbol type, out Microsoft.CodeAnalysis.Emit.AnonymousTypeValue otherType) Line 704    C#

Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.VisitNamedType(Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol sourceType) Line 555    C#

Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.Accept<Microsoft.CodeAnalysis.CSharp.Symbol>(Microsoft.CodeAnalysis.CSharp.CSharpSymbolVisitor<Microsoft.CodeAnalysis.CSharp.Symbol> visitor) Line 742    C#

Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CSharpSymbolVisitor<Microsoft.CodeAnalysis.CSharp.Symbol>.Visit(Microsoft.CodeAnalysis.CSharp.Symbol symbol) Line 15    C#

See test SynthesizedDelegate_MethodGroup

tmat added a commit to tmat/roslyn that referenced this issue Mar 9, 2023
tmat added a commit to tmat/roslyn that referenced this issue Mar 9, 2023
tmat added a commit to tmat/roslyn that referenced this issue Mar 10, 2023
tmat added a commit that referenced this issue Mar 15, 2023
* Improve EnC test helpers, add repro for #67243

* Use defaults

* Rename
@jcouv jcouv added Area-Compilers Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 31, 2023
@jcouv jcouv added this to the 17.7 milestone Mar 31, 2023
@tmat tmat modified the milestones: 17.7, 17.9 Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants