Disable diagnostics in the preview window #67030
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #67014
Here's my general reasoning on why the simplest and cleanest thing to do here is to just disable this functionality:
First, we are moving to LSP pull-based-diagnostics. In that world, preview-window diagnostics do not work anyways, as the preview window refers to documents that LSP knows nothing about (so it has no URI with which to even query the host about this stuff).
Second, If/when we do update LSP itself to support the concept of 'previews' it will be against the LSP workspace. That workspace either is already running out of proc for us, or it's already the in proc workspace that already does diagnostics out of proc.
So, having the preview workspace compute diagnostics is a point in time thing going away very soon. And given the high amount of perf impact, and the low value (how often is it even shown that there's a squiggle in the preview pane, and how useful is that to even see?), it's best to just disable this functionality fully, and decide if we want it in the future if LSP ever moves to supporting this.
This was always a nifty system that demonstrated that roslyn is truly working on real snapshots that can speculate about the future. But diagnostics are extremely expensive (forcing generators to run, and all analyzers), just to maybe populate a squiggle in a preview window that appears for a few seconds. It's reasonable to disable this functionality for the large win we get not doing duplicate work. And this is better than still having hte preview call to OOP to do the work, still causing the forking, source-generators and analyzers to all run (albeit in OOP instead of inproc).