Skip to content

Commit 438638e

Browse files
Move tracking of builds to unit-test solution crawler code (#78905)
2 parents 5e2e54a + c924833 commit 438638e

14 files changed

+20
-90
lines changed

src/EditorFeatures/Core/Remote/SolutionChecksumUpdater.cs

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ internal sealed class SolutionChecksumUpdater
2525
{
2626
private readonly Workspace _workspace;
2727

28-
/// <summary>
29-
/// We're not at a layer where we are guaranteed to have an IGlobalOperationNotificationService. So allow for
30-
/// it being null.
31-
/// </summary>
32-
private readonly IGlobalOperationNotificationService? _globalOperationService;
33-
3428
private readonly IDocumentTrackingService _documentTrackingService;
3529

3630
/// <summary>
@@ -54,17 +48,13 @@ internal sealed class SolutionChecksumUpdater
5448
private const string SynchronizeTextChangesStatusSucceededKeyName = nameof(SolutionChecksumUpdater) + "." + SynchronizeTextChangesStatusSucceededMetricName;
5549
private const string SynchronizeTextChangesStatusFailedKeyName = nameof(SolutionChecksumUpdater) + "." + SynchronizeTextChangesStatusFailedMetricName;
5650

57-
private bool _isSynchronizeWorkspacePaused;
58-
5951
public SolutionChecksumUpdater(
6052
Workspace workspace,
6153
IAsynchronousOperationListenerProvider listenerProvider,
6254
CancellationToken shutdownToken)
6355
{
6456
var listener = listenerProvider.GetListener(FeatureAttribute.SolutionChecksumUpdater);
6557

66-
_globalOperationService = workspace.Services.SolutionServices.ExportProvider.GetExports<IGlobalOperationNotificationService>().FirstOrDefault()?.Value;
67-
6858
_workspace = workspace;
6959
_documentTrackingService = workspace.Services.GetRequiredService<IDocumentTrackingService>();
7060

@@ -87,12 +77,6 @@ public SolutionChecksumUpdater(
8777
_workspaceChangedImmediateDisposer = _workspace.RegisterWorkspaceChangedImmediateHandler(OnWorkspaceChangedImmediate);
8878
_documentTrackingService.ActiveDocumentChanged += OnActiveDocumentChanged;
8979

90-
if (_globalOperationService != null)
91-
{
92-
_globalOperationService.Started += OnGlobalOperationStarted;
93-
_globalOperationService.Stopped += OnGlobalOperationStopped;
94-
}
95-
9680
// Enqueue the work to sync the initial data over.
9781
_synchronizeActiveDocumentQueue.AddWork();
9882
_synchronizeWorkspaceQueue.AddWork();
@@ -101,53 +85,21 @@ public SolutionChecksumUpdater(
10185
public void Shutdown()
10286
{
10387
// Try to stop any work that is in progress.
104-
PauseSynchronizingPrimaryWorkspace();
105-
106-
_documentTrackingService.ActiveDocumentChanged -= OnActiveDocumentChanged;
107-
_workspaceChangedDisposer.Dispose();
108-
_workspaceChangedImmediateDisposer.Dispose();
109-
110-
if (_globalOperationService != null)
111-
{
112-
_globalOperationService.Started -= OnGlobalOperationStarted;
113-
_globalOperationService.Stopped -= OnGlobalOperationStopped;
114-
}
115-
}
116-
117-
private void OnGlobalOperationStarted(object? sender, EventArgs e)
118-
=> PauseSynchronizingPrimaryWorkspace();
119-
120-
private void OnGlobalOperationStopped(object? sender, EventArgs e)
121-
=> ResumeSynchronizingPrimaryWorkspace();
122-
123-
private void PauseSynchronizingPrimaryWorkspace()
124-
{
125-
// An expensive global operation started (like a build). Pause ourselves and cancel any outstanding work in
126-
// progress to synchronize the solution.
12788
lock (_gate)
12889
{
12990
_synchronizeWorkspaceQueue.CancelExistingWork();
130-
_isSynchronizeWorkspacePaused = true;
13191
}
132-
}
13392

134-
private void ResumeSynchronizingPrimaryWorkspace()
135-
{
136-
lock (_gate)
137-
{
138-
_isSynchronizeWorkspacePaused = false;
139-
_synchronizeWorkspaceQueue.AddWork();
140-
}
93+
_documentTrackingService.ActiveDocumentChanged -= OnActiveDocumentChanged;
94+
_workspaceChangedDisposer.Dispose();
95+
_workspaceChangedImmediateDisposer.Dispose();
14196
}
14297

14398
private void OnWorkspaceChanged(WorkspaceChangeEventArgs _)
14499
{
145-
// Check if we're currently paused. If so ignore this notification. We don't want to any work in response
146-
// to whatever the workspace is doing.
147100
lock (_gate)
148101
{
149-
if (!_isSynchronizeWorkspacePaused)
150-
_synchronizeWorkspaceQueue.AddWork();
102+
_synchronizeWorkspaceQueue.AddWork();
151103
}
152104
}
153105

src/EditorFeatures/TestUtilities/EditorTestCompositions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Microsoft.CodeAnalysis.Editor.Implementation.Notification;
88
using Microsoft.CodeAnalysis.LanguageServer;
99
using Microsoft.CodeAnalysis.Test.Utilities;
10-
using Microsoft.CodeAnalysis.Test.Utilities.Notification;
1110
using Microsoft.CodeAnalysis.Text;
1211
using Microsoft.CodeAnalysis.UnitTests.Fakes;
1312
using Microsoft.CodeAnalysis.UnitTests.Remote;
@@ -57,7 +56,6 @@ public static class EditorTestCompositions
5756
typeof(TestObscuringTipManager)); // TODO: https://devdiv.visualstudio.com/DevDiv/_workitems?id=544569
5857

5958
public static readonly TestComposition EditorFeatures = FeaturesTestCompositions.Features
60-
.AddParts(typeof(TestGlobalOperationNotificationService))
6159
.Add(Editor)
6260
.AddAssemblies(
6361
typeof(TextEditorResources).Assembly,

src/EditorFeatures/TestUtilities/Notification/TestGlobalOperationNotificationService.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Workspaces/Core/Portable/Notification/AbstractGlobalOperationNotificationService.GlobalOperationRegistration.cs renamed to src/Features/Core/Portable/ExternalAccess/UnitTesting/Notification/AbstractGlobalOperationNotificationService.GlobalOperationRegistration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
using System;
66

7-
namespace Microsoft.CodeAnalysis.Notification;
7+
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Notification;
88

99
internal partial class AbstractGlobalOperationNotificationService
1010
{

src/Workspaces/Core/Portable/Notification/AbstractGlobalOperationNotificationService.cs renamed to src/Features/Core/Portable/ExternalAccess/UnitTesting/Notification/AbstractGlobalOperationNotificationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using Microsoft.CodeAnalysis.Threading;
1212
using Roslyn.Utilities;
1313

14-
namespace Microsoft.CodeAnalysis.Notification;
14+
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Notification;
1515

1616
internal abstract partial class AbstractGlobalOperationNotificationService : IGlobalOperationNotificationService
1717
{

src/Workspaces/Core/Portable/Notification/IGlobalOperationNotificationService.cs renamed to src/Features/Core/Portable/ExternalAccess/UnitTesting/Notification/IGlobalOperationNotificationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
using System;
66

7-
namespace Microsoft.CodeAnalysis.Notification;
7+
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Notification;
88

99
/// <summary>
1010
/// Optional interface that can be used to hear about when expensive global operations (like a 'build') occur in the

src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingGlobalOperationAwareIdleProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
using System;
66
using System.Threading;
7-
using Microsoft.CodeAnalysis.Notification;
7+
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Notification;
88
using Microsoft.CodeAnalysis.Shared.TestHooks;
99

1010
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.SolutionCrawler;

src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.AbstractUnitTestingPriorityProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
using System.Collections.Immutable;
77
using System.Threading;
88
using System.Threading.Tasks;
9+
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Notification;
910
using Microsoft.CodeAnalysis.Internal.Log;
10-
using Microsoft.CodeAnalysis.Notification;
1111
using Microsoft.CodeAnalysis.Shared.TestHooks;
1212

1313
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.SolutionCrawler;

src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingIncrementalAnalyzerProcessor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Threading.Tasks;
1111
using Microsoft.CodeAnalysis.ErrorReporting;
1212
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api;
13+
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Notification;
1314
using Microsoft.CodeAnalysis.Host;
1415
using Microsoft.CodeAnalysis.Internal.Log;
1516
using Microsoft.CodeAnalysis.LanguageService;

src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingLowPriorityProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using Microsoft.CodeAnalysis.ErrorReporting;
11+
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Notification;
1112
using Microsoft.CodeAnalysis.Internal.Log;
12-
using Microsoft.CodeAnalysis.Notification;
1313
using Microsoft.CodeAnalysis.Shared.TestHooks;
1414

1515
namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.SolutionCrawler;

0 commit comments

Comments
 (0)