Add a hack to remove output from the Razor generator if suppressed#61675
Conversation
|
Random question @jasonmalinowski: When Ryan and I were debugging this we could see the source generated documents in the analyzers tree in Solution Explorer. It didn't click at the time, but that was probably the sign that things were wrong, because that is unexpected, correct? And if so, does this fix remove them again? |
|
@davidwengier Yes, "unfortunately" -- that would have been a hint indeed that something was wrong/changed from before. |
9e6bc43 to
baee87f
Compare
src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.CompilationTracker.cs
Outdated
Show resolved
Hide resolved
dotnet#24928 made a change to the Razor generator to ensure that even if the generator is suppressed, it's still going to run and cache it's outputs so later runs aren't a from-scratch run on a performance-critical path. However, a bug meant that if the generator was suppressed, it'd still run the first time it's invoked, and will still output files even though it was supposed to be suppressed. The approach taken here is to suppress the addition of the files, but at the very end of the chain only -- the generation and walking in the middle of the incremental chain is left untouched, so that still has the existing caching behavior. This fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1545938 but we're still considering dotnet/roslyn#61675 as a tactical fix instead.
The Razor generator is controlled by a flag that lives in an .editorconfig file; in the IDE we generally don't run the generator and instead use the design-time files added through the legacy IDynamicFileInfo API. When we're doing Hot Reload we then remove those legacy files and remove the .editorconfig file that is supposed to disable the generator; for the Hot Reload pass we then are running the generator. This is done in the CompileTimeSolutionProvider. dotnet/sdk#24928 introduced an issue where even though the Razor generator is being told to not run, it still runs anyways. As a tactical fix rather than reverting that PR, for Visual Studio 17.3 Preview 2 we are going to do a hack here which is to rip out generated files. In discussion, simply reverting the SDK change was problematic because it would reintroduce some notable performance issues that it was intended to fix in the first place. Fixing the generator directly is also possible (and we'll be doing a follow-up PR to try doing that), but is also a fairly risky change given the amount of testing that was required to test the PR in the first place. This we think is the least-risky option we have, even though it itself is touching a fairly sensitive area of our codebase. The intent is to remove this hack by Preview 3 with a properly tested fix in the generator.
baee87f to
59e3918
Compare
Would adding a manual check for the presence of files under the Analyzers node be a good early warning sign, to avoid the long investigation through multiple teams to track this down? Or is it no better a signal than "the whole document has red squiggles" which got us here? |
@davidwengier Yes, potentially, but the red squiggles all about ambiguous types was also a pretty good giveaway if you know how this system is supposed to work too. We're also updating tests for the generator properly in dotnet/sdk#25833 so long investigations don't happen either. 😄 |
dotnet#24928 made a change to the Razor generator to ensure that even if the generator is suppressed, it's still going to run and cache it's outputs so later runs aren't a from-scratch run on a performance-critical path. However, a bug meant that if the generator was suppressed, it'd still run the first time it's invoked, and will still output files even though it was supposed to be suppressed. The approach taken here is to suppress the addition of the files, but at the very end of the chain only -- the generation and walking in the middle of the incremental chain is left untouched, so that still has the existing caching behavior. This fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1545938 but we're still considering dotnet/roslyn#61675 as a tactical fix instead.
dotnet/sdk#24928 made a change to the Razor generator to ensure that even if the generator is suppressed, it's still going to run and cache it's outputs so later runs aren't a from-scratch run on a performance-critical path. However, a bug meant that if the generator was suppressed, it'd still run the first time it's invoked, and will still output files even though it was supposed to be suppressed. The approach taken here is to suppress the addition of the files, but at the very end of the chain only -- the generation and walking in the middle of the incremental chain is left untouched, so that still has the existing caching behavior. This fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1545938 but we're still considering dotnet/roslyn#61675 as a tactical fix instead.
dotnet/sdk#24928 made a change to the Razor generator to ensure that even if the generator is suppressed, it's still going to run and cache it's outputs so later runs aren't a from-scratch run on a performance-critical path. However, a bug meant that if the generator was suppressed, it'd still run the first time it's invoked, and will still output files even though it was supposed to be suppressed. The approach taken here is to suppress the addition of the files, but at the very end of the chain only -- the generation and walking in the middle of the incremental chain is left untouched, so that still has the existing caching behavior. This fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1545938 properly; dotnet/roslyn#61675 was put in as a tactical fix first.
The Razor generator is controlled by a flag that lives in an .editorconfig file; in the IDE we generally don't run the generator
and instead use the design-time files added through the legacy IDynamicFileInfo API. When we're doing Hot Reload we then
remove those legacy files and remove the .editorconfig file that is supposed to disable the generator; for the Hot Reload pass we then are running the generator. This is done in the CompileTimeSolutionProvider.
dotnet/sdk#24928 introduced an issue where even though the Razor generator is being told to not run, it still runs anyways. As a tactical fix rather than reverting that PR, for Visual Studio 17.3 Preview 2 we are going to do a hack here which is to rip out generated files. In discussion, simply reverting the SDK change was problematic because it would reintroduce some notable performance issues that it was intended to fix in the first place. Fixing the generator directly is also possible (and we'll be doing a follow-up PR to try doing that), but is also a fairly risky change given the amount of testing that was required to test the PR in the first place. This we think is the least-risky option we have, even though it itself is touching a fairly sensitive area of our codebase.
The intent is to remove this hack by Preview 3 with a properly tested fix in the generator.
This is a tactical fix for https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1545938