Skip to content

Commit 9c146eb

Browse files
Put back a check for IVsMonitorSelection to avoid generator updates
Right now it appears we have a bug that when that update runs, it updates the Solution.WorkspaceVersion which breaks the ability for TryApplyChanges to work later. CodeModel doesn't deal with that case so leaving this in causes CodeModel tests to get flaky.
1 parent e3feb59 commit 9c146eb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/VisualStudio/Core/Def/ProjectSystem/VisualStudioWorkspaceImpl_SourceGenerators.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using Microsoft.CodeAnalysis.Host;
77
using Microsoft.VisualStudio.Shell;
8+
using Microsoft.VisualStudio.Shell.Interop;
89

910
namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
1011

@@ -44,6 +45,12 @@ private void SubscribeToSourceGeneratorImpactingEvents()
4445
workspaceStatusService.StatusChanged += (_, _) => EnqueueUpdateSourceGeneratorVersion(projectId: null, forceRegeneration: false);
4546

4647
// Now kick off at least the initial work to run generators.
48+
49+
// HACK: don't run this in unit tests as this will break CodeModel
50+
if (ServiceProvider.GlobalProvider.GetService(typeof(IVsMonitorSelection)) == null)
51+
return;
52+
// END HACK
53+
4754
this.EnqueueUpdateSourceGeneratorVersion(projectId: null, forceRegeneration: false);
4855
}
4956

0 commit comments

Comments
 (0)