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

Merge the new UnitTesting solution crawler into Main #64368

Merged
merged 199 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
199 commits
Select commit Hold shift + click to select a range
5f6c752
Initial stubs to report solution events to OOP
CyrusNajmabadi Sep 19, 2022
c9bb965
In progress
CyrusNajmabadi Sep 19, 2022
5f52883
in progress
CyrusNajmabadi Sep 19, 2022
813dc11
in progress
CyrusNajmabadi Sep 19, 2022
3375fe8
in progress
CyrusNajmabadi Sep 19, 2022
5da7e9e
Make static
CyrusNajmabadi Sep 19, 2022
3566e8f
In progress
CyrusNajmabadi Sep 19, 2022
5def02f
Call into notification service
CyrusNajmabadi Sep 19, 2022
c0b1085
IN progress
CyrusNajmabadi Sep 19, 2022
e5e1bca
Renames
CyrusNajmabadi Sep 19, 2022
77e8315
Renames
CyrusNajmabadi Sep 19, 2022
f358af8
remote side
CyrusNajmabadi Sep 19, 2022
f53250f
make workspace service
CyrusNajmabadi Sep 19, 2022
97f12e8
End to end
CyrusNajmabadi Sep 19, 2022
f9b59c3
Formatting
CyrusNajmabadi Sep 19, 2022
cfc5ab6
Delete
CyrusNajmabadi Sep 19, 2022
360284f
Cleanup
CyrusNajmabadi Sep 19, 2022
3f11d77
nrt
CyrusNajmabadi Sep 19, 2022
d90eacf
Fork the solutoin crawler code to the unit testing EA lib
CyrusNajmabadi Sep 19, 2022
f968d3e
Fork the solutoin crawler code to the unit testing EA lib
CyrusNajmabadi Sep 19, 2022
bc8af14
rename
CyrusNajmabadi Sep 19, 2022
c97fb12
rename
CyrusNajmabadi Sep 19, 2022
cc3a370
rename
CyrusNajmabadi Sep 19, 2022
b352c80
rename
CyrusNajmabadi Sep 19, 2022
06e4864
rename
CyrusNajmabadi Sep 19, 2022
d602909
rename
CyrusNajmabadi Sep 19, 2022
712185d
rename
CyrusNajmabadi Sep 19, 2022
b444f8a
rename
CyrusNajmabadi Sep 19, 2022
d11fa92
rename
CyrusNajmabadi Sep 19, 2022
c93ea1f
rename
CyrusNajmabadi Sep 19, 2022
90663e3
rename
CyrusNajmabadi Sep 19, 2022
335cf61
rename
CyrusNajmabadi Sep 19, 2022
6eba75a
rename
CyrusNajmabadi Sep 19, 2022
4023c0b
rename
CyrusNajmabadi Sep 19, 2022
39f7f59
rename
CyrusNajmabadi Sep 19, 2022
4233f89
rename
CyrusNajmabadi Sep 19, 2022
cdd109c
rename
CyrusNajmabadi Sep 19, 2022
6864dd5
rename
CyrusNajmabadi Sep 19, 2022
4010ce1
rename
CyrusNajmabadi Sep 19, 2022
0e01447
rename
CyrusNajmabadi Sep 19, 2022
a3e91f5
rename
CyrusNajmabadi Sep 19, 2022
fb0396b
rename
CyrusNajmabadi Sep 19, 2022
a8ea05c
rename
CyrusNajmabadi Sep 19, 2022
4f31fb1
rename
CyrusNajmabadi Sep 19, 2022
04a0250
rename
CyrusNajmabadi Sep 19, 2022
6251dd7
rename
CyrusNajmabadi Sep 19, 2022
e522a3c
rename
CyrusNajmabadi Sep 19, 2022
41f27db
rename
CyrusNajmabadi Sep 19, 2022
cfe1add
rename
CyrusNajmabadi Sep 19, 2022
70c4e38
rename
CyrusNajmabadi Sep 19, 2022
49f0eca
rename
CyrusNajmabadi Sep 19, 2022
42e801c
rename
CyrusNajmabadi Sep 19, 2022
8c78156
rename
CyrusNajmabadi Sep 19, 2022
bb943c2
rename
CyrusNajmabadi Sep 19, 2022
70913e5
rename
CyrusNajmabadi Sep 19, 2022
a6634c9
rename
CyrusNajmabadi Sep 19, 2022
b58a658
rename
CyrusNajmabadi Sep 19, 2022
beaa5f4
rename
CyrusNajmabadi Sep 19, 2022
a31c92f
rename
CyrusNajmabadi Sep 19, 2022
1483cef
rename
CyrusNajmabadi Sep 19, 2022
f5a0434
rename
CyrusNajmabadi Sep 19, 2022
1babf76
rename
CyrusNajmabadi Sep 19, 2022
96167f8
rename
CyrusNajmabadi Sep 19, 2022
020b571
rename
CyrusNajmabadi Sep 19, 2022
7ccc4d2
rename
CyrusNajmabadi Sep 19, 2022
53ab9fe
rename
CyrusNajmabadi Sep 19, 2022
e1253b6
rename
CyrusNajmabadi Sep 19, 2022
2152a1f
Reduce usage of Workspace in the unit testing solution crawler.
CyrusNajmabadi Sep 19, 2022
2f120fb
lint
CyrusNajmabadi Sep 19, 2022
7547224
Merge branch 'features/solutionEvents' into forkSolutionCrawler
CyrusNajmabadi Sep 19, 2022
ee87f95
Merge branch 'forkSolutionCrawler' into unitTestingRegistration
CyrusNajmabadi Sep 19, 2022
e8556a0
Move off of using the Workspace itself
CyrusNajmabadi Sep 19, 2022
d6f5895
Move off of using the Workspace itself
CyrusNajmabadi Sep 19, 2022
5be3e53
Move off of using the Workspace itself
CyrusNajmabadi Sep 19, 2022
f64a49a
Move off of using the Workspace itself
CyrusNajmabadi Sep 19, 2022
af36e82
Move off of using the Workspace itself
CyrusNajmabadi Sep 19, 2022
b68a3e7
Move off of using the Workspace itself
CyrusNajmabadi Sep 19, 2022
e0b5e8a
Move off of using solution
CyrusNajmabadi Sep 19, 2022
2fc71b4
Move off of using solution
CyrusNajmabadi Sep 19, 2022
e5d1e48
Merge pull request #64127 from CyrusNajmabadi/features/solutionEvents
CyrusNajmabadi Sep 20, 2022
82ca5f5
Rename namespace
CyrusNajmabadi Sep 20, 2022
85957d5
renames
CyrusNajmabadi Sep 20, 2022
6979a52
renames
CyrusNajmabadi Sep 20, 2022
d8adbc6
renames
CyrusNajmabadi Sep 20, 2022
809ccf5
renames
CyrusNajmabadi Sep 20, 2022
b838b94
Simplify
CyrusNajmabadi Sep 20, 2022
1f1dbdb
Simplify
CyrusNajmabadi Sep 20, 2022
53af1fa
Merge branch 'justWorkspaecEvents' into forkSolutionCrawler
CyrusNajmabadi Sep 20, 2022
f781b57
Merge branch 'forkSolutionCrawler' into unitTestingRegistration
CyrusNajmabadi Sep 20, 2022
08e4a37
Rename user facing string
CyrusNajmabadi Sep 20, 2022
fdd201b
Merge branch 'justWorkspaecEvents' into forkSolutionCrawler
CyrusNajmabadi Sep 20, 2022
9528e68
Merge branch 'forkSolutionCrawler' into unitTestingRegistration
CyrusNajmabadi Sep 20, 2022
83bac9f
fix
CyrusNajmabadi Sep 20, 2022
cbed0d1
Merge branch 'justWorkspaecEvents' into forkSolutionCrawler
CyrusNajmabadi Sep 20, 2022
c0af821
Merge branch 'forkSolutionCrawler' into unitTestingRegistration
CyrusNajmabadi Sep 20, 2022
8b7fd47
build
CyrusNajmabadi Sep 20, 2022
3f1f4da
Remove unneeded components
CyrusNajmabadi Sep 20, 2022
79abf9e
In progress
CyrusNajmabadi Sep 20, 2022
7e997bb
In progress
CyrusNajmabadi Sep 20, 2022
be289e7
Move off of workspace
CyrusNajmabadi Sep 20, 2022
accbf42
Add descriptor concept
CyrusNajmabadi Sep 20, 2022
be121e3
Add descriptor concept
CyrusNajmabadi Sep 20, 2022
d919cc3
Singleton descriptors
CyrusNajmabadi Sep 20, 2022
9c5f872
Merge pull request #64147 from CyrusNajmabadi/justWorkspaecEvents
CyrusNajmabadi Sep 20, 2022
b9593e9
Pass teh descriptor along
CyrusNajmabadi Sep 20, 2022
af9e4ca
Merge pull request #64149 from CyrusNajmabadi/forkSolutionCrawler
CyrusNajmabadi Sep 20, 2022
3fbaa25
Stream the events into the unit testing crawler
CyrusNajmabadi Sep 20, 2022
64f898e
Merge remote-tracking branch 'upstream/features/solutionEvents' into …
CyrusNajmabadi Sep 20, 2022
602aff1
Lint
CyrusNajmabadi Sep 20, 2022
49fd2a0
Remove workspace
CyrusNajmabadi Sep 20, 2022
afe0e45
use kind and services
CyrusNajmabadi Sep 20, 2022
634ba80
Revert
CyrusNajmabadi Sep 20, 2022
266791f
Simplify
CyrusNajmabadi Sep 20, 2022
ca073da
Add the new unit testing apis
CyrusNajmabadi Sep 20, 2022
f153377
Add the new unit testing apis
CyrusNajmabadi Sep 20, 2022
cfef25a
Entrypoint
CyrusNajmabadi Sep 20, 2022
fc8778e
make neste type
CyrusNajmabadi Sep 20, 2022
d688362
Merge pull request #64150 from CyrusNajmabadi/unitTestingRegistration
CyrusNajmabadi Sep 20, 2022
44585c2
Remove the ILegacyWorkspaceDescriptor concept
CyrusNajmabadi Sep 20, 2022
d8780b4
add lock for consistency
CyrusNajmabadi Sep 20, 2022
b7c44e6
Merge branch 'removeDescriptor' into newUnitTestingApis
CyrusNajmabadi Sep 20, 2022
63538c3
Remove
CyrusNajmabadi Sep 20, 2022
4547049
Remove
CyrusNajmabadi Sep 20, 2022
5284983
Merge branch 'removeDescriptor' into newUnitTestingApis
CyrusNajmabadi Sep 20, 2022
5f42ced
nrt
CyrusNajmabadi Sep 20, 2022
af089ce
Make sealed
CyrusNajmabadi Sep 21, 2022
9016b14
Merge pull request #64167 from dotnet/merges/main-to-features/solutio…
dotnet-bot Sep 21, 2022
292f8c6
Merge remote-tracking branch 'upstream/main' into newUnitTestingApis
CyrusNajmabadi Sep 21, 2022
3a9f2a2
Disable unused functionality
CyrusNajmabadi Sep 21, 2022
b87d6a5
Disable unused functionality
CyrusNajmabadi Sep 21, 2022
46b5344
Disable unused functionality
CyrusNajmabadi Sep 21, 2022
ae0d333
Disable unused functionality
CyrusNajmabadi Sep 21, 2022
1b8f7f1
Disable unused functionality
CyrusNajmabadi Sep 21, 2022
8949601
Disable unused functionality
CyrusNajmabadi Sep 21, 2022
6c0f7ce
Remove priority concept
CyrusNajmabadi Sep 21, 2022
54237ca
Merge pull request #64161 from CyrusNajmabadi/removeDescriptor
CyrusNajmabadi Sep 21, 2022
e60350e
Remove tracking of open/close events
CyrusNajmabadi Sep 21, 2022
9fe9015
Merge remote-tracking branch 'upstream/features/solutionEvents' into …
CyrusNajmabadi Sep 21, 2022
2d9c881
Merge pull request #64206 from dotnet/merges/main-to-features/solutio…
dotnet-bot Sep 22, 2022
12b3d83
Merge pull request #64235 from dotnet/merges/main-to-features/solutio…
dotnet-bot Sep 23, 2022
fced456
Merge pull request #64271 from dotnet/merges/main-to-features/solutio…
dotnet-bot Sep 25, 2022
6439873
Merge pull request #64301 from dotnet/merges/main-to-features/solutio…
dotnet-bot Sep 27, 2022
c8f2807
Merge remote-tracking branch 'upstream/features/solutionEvents' into …
CyrusNajmabadi Sep 27, 2022
723687b
Merge branch 'newUnitTestingApis' of https://github.com/CyrusNajmabad…
CyrusNajmabadi Sep 27, 2022
e68b3b3
Merge branch 'newUnitTestingApis' into diabledUnusedFunctionality
CyrusNajmabadi Sep 27, 2022
b2a0fdb
Merge branch 'diabledUnusedFunctionality' into openCloseFunctionality
CyrusNajmabadi Sep 27, 2022
3118bdc
NRT
CyrusNajmabadi Sep 27, 2022
7128364
Remove unused functiuonality
CyrusNajmabadi Sep 27, 2022
2cc4c64
Merge branch 'newUnitTestingApis' into diabledUnusedFunctionality
CyrusNajmabadi Sep 27, 2022
6578dc0
Disable unused functionality
CyrusNajmabadi Sep 27, 2022
90ce47b
Merge branch 'diabledUnusedFunctionality' into openCloseFunctionality
CyrusNajmabadi Sep 27, 2022
ff09ca2
remove open/close functionality
CyrusNajmabadi Sep 27, 2022
14d201d
Merge pull request #64164 from CyrusNajmabadi/newUnitTestingApis
CyrusNajmabadi Sep 27, 2022
524ac0c
Merge remote-tracking branch 'upstream/features/solutionEvents' into …
CyrusNajmabadi Sep 27, 2022
939e249
Disable unused functionality
CyrusNajmabadi Sep 27, 2022
1542b2f
Make synchronous
CyrusNajmabadi Sep 27, 2022
8b88033
Disable unused functionality
CyrusNajmabadi Sep 27, 2022
94238a4
Merge branch 'diabledUnusedFunctionality' into openCloseFunctionality
CyrusNajmabadi Sep 27, 2022
89840f1
proper pattern
CyrusNajmabadi Sep 28, 2022
bfe5bdc
Merge branch 'diabledUnusedFunctionality' into openCloseFunctionality
CyrusNajmabadi Sep 28, 2022
dbf0f86
Fix formatting
CyrusNajmabadi Sep 28, 2022
6dc2ec5
remove nested ifdefs
CyrusNajmabadi Sep 28, 2022
40ab1c9
Add distinct feature attribute for tracking unit testing solution cra…
CyrusNajmabadi Sep 28, 2022
6e189ab
Merge pull request #64330 from CyrusNajmabadi/diabledUnusedFunctionality
CyrusNajmabadi Sep 28, 2022
6b26230
Merge remote-tracking branch 'upstream/features/solutionEvents' into …
CyrusNajmabadi Sep 28, 2022
929d4d4
Inline
CyrusNajmabadi Sep 28, 2022
06bdbd3
Inline
CyrusNajmabadi Sep 28, 2022
d52bb31
Merge pull request #64343 from CyrusNajmabadi/featureAttribute
CyrusNajmabadi Sep 28, 2022
b4ce8aa
reorder
CyrusNajmabadi Sep 28, 2022
3e36f10
Remove unused reason
CyrusNajmabadi Sep 28, 2022
a024357
Remove unused reason
CyrusNajmabadi Sep 28, 2022
9084c20
Remove unused reason
CyrusNajmabadi Sep 28, 2022
c44b759
Remove unused reason
CyrusNajmabadi Sep 28, 2022
d76af57
Remove unused reason
CyrusNajmabadi Sep 28, 2022
568b095
Remove unused reason
CyrusNajmabadi Sep 28, 2022
2c4ad50
Merge pull request #64339 from CyrusNajmabadi/openCloseFunctionality
CyrusNajmabadi Sep 28, 2022
a4cc6dd
Merge pull request #64358 from dotnet/merges/main-to-features/solutio…
dotnet-bot Sep 29, 2022
9071c14
Merge remote-tracking branch 'upstream/features/solutionEvents' into …
CyrusNajmabadi Sep 29, 2022
b34e09c
remove code related to passing along method body
CyrusNajmabadi Sep 29, 2022
d2db219
ifdef properly
CyrusNajmabadi Sep 29, 2022
d9f1626
lint
CyrusNajmabadi Sep 29, 2022
b389bad
Merge remote-tracking branch 'upstream/main' into features/solutionEv…
CyrusNajmabadi Sep 29, 2022
c53c9bf
Wait until an analyzer is registered before streaming workspace event…
CyrusNajmabadi Sep 29, 2022
a27dc9d
Merge pull request #64372 from CyrusNajmabadi/features/solutionEvents
CyrusNajmabadi Sep 29, 2022
c9db38c
Merge pull request #64367 from CyrusNajmabadi/removeReasons
CyrusNajmabadi Sep 29, 2022
47e37c4
Merge remote-tracking branch 'upstream/features/solutionEvents' into …
CyrusNajmabadi Sep 30, 2022
3ac7d35
Update src/Workspaces/Remote/ServiceHub/Services/LegacySolutionEvents…
CyrusNajmabadi Sep 30, 2022
7bbb85e
Update src/Workspaces/Remote/ServiceHub/Services/LegacySolutionEvents…
CyrusNajmabadi Sep 30, 2022
72464d8
Merge pull request #64386 from dotnet/merges/main-to-features/solutio…
dotnet-bot Sep 30, 2022
b372de3
Add comment
CyrusNajmabadi Sep 30, 2022
e98afb1
Update src/EditorFeatures/Core/SolutionEvents/HostLegacySolutionEvent…
CyrusNajmabadi Sep 30, 2022
428c1de
Merge pull request #64376 from CyrusNajmabadi/waitForReady
CyrusNajmabadi Sep 30, 2022
8e56089
Merge pull request #64417 from dotnet/merges/main-to-features/solutio…
dotnet-bot Oct 1, 2022
a5bc62c
Merge pull request #64429 from dotnet/merges/main-to-features/solutio…
dotnet-bot Oct 2, 2022
ef7d1cf
Merge pull request #64434 from dotnet/merges/main-to-features/solutio…
dotnet-bot Oct 3, 2022
93753ed
Update to use new internal API
CyrusNajmabadi Oct 3, 2022
af24e70
Merge pull request #64449 from CyrusNajmabadi/mergeFixes
CyrusNajmabadi Oct 3, 2022
cd618ef
Merge pull request #64458 from dotnet/merges/main-to-features/solutio…
dotnet-bot Oct 4, 2022
493f410
Merge pull request #64493 from dotnet/merges/main-to-features/solutio…
dotnet-bot Oct 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/targets/Services.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.CodeLensReferences" ClassName="Microsoft.CodeAnalysis.Remote.RemoteCodeLensReferencesService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.DesignerAttributeDiscovery" ClassName="Microsoft.CodeAnalysis.Remote.RemoteDesignerAttributeDiscoveryService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.ProjectTelemetry" ClassName="Microsoft.CodeAnalysis.Remote.RemoteProjectTelemetryService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.LegacySolutionEventsAggregation" ClassName="Microsoft.CodeAnalysis.Remote.RemoteLegacySolutionEventsAggregationService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.SymbolSearchUpdate" ClassName="Microsoft.CodeAnalysis.Remote.RemoteSymbolSearchUpdateService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.TaskList" ClassName="Microsoft.CodeAnalysis.Remote.RemoteTaskListService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.LanguageServices.EditAndContinue" ClassName="Microsoft.CodeAnalysis.EditAndContinue.RemoteEditAndContinueService+Factory" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Remote;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.SolutionCrawler;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.LegacySolutionEvents
{
[ExportEventListener(WellKnownEventListeners.Workspace, WorkspaceKind.Host), Shared]
internal sealed partial class HostLegacySolutionEventsWorkspaceEventListener : IEventListener<object>
{
private readonly IGlobalOptionService _globalOptions;
private readonly IThreadingContext _threadingContext;
private readonly AsyncBatchingWorkQueue<WorkspaceChangeEventArgs> _eventQueue;

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public HostLegacySolutionEventsWorkspaceEventListener(
IGlobalOptionService globalOptions,
IThreadingContext threadingContext,
IAsynchronousOperationListenerProvider listenerProvider)
{
_globalOptions = globalOptions;
_threadingContext = threadingContext;
_eventQueue = new AsyncBatchingWorkQueue<WorkspaceChangeEventArgs>(
DelayTimeSpan.Short,
ProcessWorkspaceChangeEventsAsync,
listenerProvider.GetListener(FeatureAttribute.SolutionCrawlerUnitTesting),
_threadingContext.DisposalToken);
}

public void StartListening(Workspace workspace, object? serviceOpt)
{
if (_globalOptions.GetOption(SolutionCrawlerRegistrationService.EnableSolutionCrawler))
{
workspace.WorkspaceChanged += OnWorkspaceChanged;
_threadingContext.DisposalToken.Register(() =>
{
workspace.WorkspaceChanged -= OnWorkspaceChanged;
});
}
}

private void OnWorkspaceChanged(object? sender, WorkspaceChangeEventArgs e)
=> _eventQueue.AddWork(e);

private async ValueTask ProcessWorkspaceChangeEventsAsync(ImmutableSegmentedList<WorkspaceChangeEventArgs> events, CancellationToken cancellationToken)
{
if (events.IsEmpty)
return;

var workspace = events[0].OldSolution.Workspace;
Contract.ThrowIfTrue(events.Any(e => e.OldSolution.Workspace != workspace || e.NewSolution.Workspace != workspace));

var client = await RemoteHostClient.TryGetClientAsync(workspace, cancellationToken).ConfigureAwait(false);

if (client is null)
{
var aggregationService = workspace.Services.GetRequiredService<ILegacySolutionEventsAggregationService>();
var shouldReport = aggregationService.ShouldReportChanges(workspace.Services.SolutionServices);
if (!shouldReport)
return;

foreach (var args in events)
await aggregationService.OnWorkspaceChangedAsync(args, cancellationToken).ConfigureAwait(false);
}
else
{
// Notifying OOP of workspace events can be expensive (there may be a lot of them, and they involve
// syncing over entire solution snapshots). As such, do not bother to do this if the remote side says
// that it's not interested in the events. This will happen, for example, when the unittesting
// Test-Explorer window has not been shown yet, and so the unit testing system will not have registered
// an incremental analyzer with us.
var shouldReport = await client.TryInvokeAsync<IRemoteLegacySolutionEventsAggregationService, bool>(
(service, cancellationToken) => service.ShouldReportChangesAsync(cancellationToken),
cancellationToken).ConfigureAwait(false);
if (!shouldReport.HasValue || !shouldReport.Value)
return;

foreach (var args in events)
{
await client.TryInvokeAsync<IRemoteLegacySolutionEventsAggregationService>(
args.OldSolution, args.NewSolution,
(service, oldSolutionChecksum, newSolutionChecksum, cancellationToken) =>
service.OnWorkspaceChangedAsync(oldSolutionChecksum, newSolutionChecksum, args.Kind, args.ProjectId, args.DocumentId, cancellationToken),
cancellationToken).ConfigureAwait(false);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.SolutionCrawler;

namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal interface INewUnitTestingIncrementalAnalyzerImplementation
{
#if false // Not used in unit testing crawling
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false

Why keep this?

// Task NewSolutionSnapshotAsync(Solution solution, CancellationToken cancellationToken);
// Task DocumentOpenAsync(Document document, CancellationToken cancellationToken);
// Task DocumentCloseAsync(Document document, CancellationToken cancellationToken);
// Task DocumentResetAsync(Document document, CancellationToken cancellationToken);
// void RemoveProject(ProjectId projectId);

// [Obsolete]
// bool NeedsReanalysisOnOptionChanged(object sender, UnitTestingOptionChangedEventArgsWrapper e);

Task AnalyzeSyntaxAsync(Document document, UnitTestingInvocationReasons reasons, CancellationToken cancellationToken);
#endif

Task AnalyzeDocumentAsync(
Document document,
#if false // Not used in unit testing crawling
SyntaxNode bodyOpt,
#endif
UnitTestingInvocationReasons reasons,
CancellationToken cancellationToken);

Task AnalyzeProjectAsync(
Project project,
#if false // Not used in unit testing crawling
bool semanticsChanged,
#endif
UnitTestingInvocationReasons reasons,
CancellationToken cancellationToken);

void RemoveDocument(DocumentId documentId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api
{
internal interface INewUnitTestingIncrementalAnalyzerProviderImplementation
{
INewUnitTestingIncrementalAnalyzerImplementation CreateIncrementalAnalyzer();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api;
using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.SolutionCrawler;
using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api;

internal sealed partial class NewUnitTestingIncrementalAnalyzerProvider
{
private sealed class NewUnitTestingIncrementalAnalyzer : IUnitTestingIncrementalAnalyzer
{
private readonly INewUnitTestingIncrementalAnalyzerImplementation _implementation;

public NewUnitTestingIncrementalAnalyzer(INewUnitTestingIncrementalAnalyzerImplementation implementation)
=> _implementation = implementation;

public Task AnalyzeDocumentAsync(
Document document,
#if false // Not used in unit testing crawling
SyntaxNode bodyOpt,
#endif
UnitTestingInvocationReasons reasons,
CancellationToken cancellationToken)
{
return _implementation.AnalyzeDocumentAsync(
document,
#if false // Not used in unit testing crawling
bodyOpt,
#endif
reasons,
cancellationToken);
}

public Task AnalyzeProjectAsync(
Project project,
#if false // Not used in unit testing crawling
bool semanticsChanged,
#endif
UnitTestingInvocationReasons reasons,
CancellationToken cancellationToken)
{
return _implementation.AnalyzeProjectAsync(
project,
#if false // Not used in unit testing crawling
semanticsChanged,
#endif
reasons,
cancellationToken);
}

#if false // Not used in unit testing crawling
public Task AnalyzeSyntaxAsync(Document document, UnitTestingInvocationReasons reasons, CancellationToken cancellationToken)
=> Task.CompletedTask;

public Task DocumentCloseAsync(Document document, CancellationToken cancellationToken)
=> Task.CompletedTask;

public Task DocumentOpenAsync(Document document, CancellationToken cancellationToken)
=> Task.CompletedTask;

public Task DocumentResetAsync(Document document, CancellationToken cancellationToken)
=> Task.CompletedTask;

public Task ActiveDocumentSwitchedAsync(TextDocument document, CancellationToken cancellationToken)
=> Task.CompletedTask;

public Task NewSolutionSnapshotAsync(Solution solution, CancellationToken cancellationToken)
=> Task.CompletedTask;
#endif

public Task RemoveDocumentAsync(DocumentId documentId, CancellationToken cancellationToken)
{
_implementation.RemoveDocument(documentId);
return Task.CompletedTask;
}

#if false // Not used in unit testing crawling
public Task RemoveProjectAsync(ProjectId projectId, CancellationToken cancellationToken)
=> Task.CompletedTask;

public Task NonSourceDocumentOpenAsync(TextDocument textDocument, CancellationToken cancellationToken)
=> Task.CompletedTask;

public Task NonSourceDocumentCloseAsync(TextDocument textDocument, CancellationToken cancellationToken)
=> Task.CompletedTask;

public Task NonSourceDocumentResetAsync(TextDocument textDocument, CancellationToken cancellationToken)
=> Task.CompletedTask;

public Task AnalyzeNonSourceDocumentAsync(TextDocument textDocument, UnitTestingInvocationReasons reasons, CancellationToken cancellationToken)
=> Task.CompletedTask;

public void LogAnalyzerCountSummary()
{
}

/// <summary>
/// Order all incremental analyzers below DiagnosticIncrementalAnalyzer
/// </summary>
public int Priority => 1;

// Unit testing incremental analyzer only supports full solution analysis scope.
// In future, we should add a separate option to allow users to configure background analysis scope for unit testing.
public static BackgroundAnalysisScope GetBackgroundAnalysisScope(OptionSet _) => BackgroundAnalysisScope.FullSolution;

public void Shutdown()
{
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.SolutionCrawler;
using Microsoft.CodeAnalysis.Host;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.Api;

internal sealed partial class NewUnitTestingIncrementalAnalyzerProvider : IUnitTestingIncrementalAnalyzerProvider
{
private readonly string? _workspaceKind;
private readonly SolutionServices _services;
private readonly INewUnitTestingIncrementalAnalyzerProviderImplementation _incrementalAnalyzerProvider;

private IUnitTestingIncrementalAnalyzer? _lazyAnalyzer;

private NewUnitTestingIncrementalAnalyzerProvider(
string? workspaceKind,
SolutionServices services,
INewUnitTestingIncrementalAnalyzerProviderImplementation incrementalAnalyzerProvider)
{
_workspaceKind = workspaceKind;
_services = services;
_incrementalAnalyzerProvider = incrementalAnalyzerProvider;
}

// NOTE: We're currently expecting the analyzer to be singleton, so that
// analyzers returned when calling this method twice would pass a reference equality check.
// One instance should be created by SolutionCrawler, another one by us, when calling the
// UnitTestingSolutionCrawlerServiceAccessor.Reanalyze method.
public IUnitTestingIncrementalAnalyzer CreateIncrementalAnalyzer()
=> _lazyAnalyzer ??= new NewUnitTestingIncrementalAnalyzer(_incrementalAnalyzerProvider.CreateIncrementalAnalyzer());

public void Reanalyze()
{
var solutionCrawlerService = _services.GetService<IUnitTestingSolutionCrawlerService>();
solutionCrawlerService?.Reanalyze(
_workspaceKind, _services, this.CreateIncrementalAnalyzer(), projectIds: null, documentIds: null, highPriority: false);
}

public static NewUnitTestingIncrementalAnalyzerProvider? TryRegister(string? workspaceKind, SolutionServices services, string analyzerName, INewUnitTestingIncrementalAnalyzerProviderImplementation provider)
{
Contract.ThrowIfNull(workspaceKind);
var solutionCrawlerRegistrationService = services.GetService<IUnitTestingSolutionCrawlerRegistrationService>();
if (solutionCrawlerRegistrationService == null)
{
return null;
}

var analyzerProvider = new NewUnitTestingIncrementalAnalyzerProvider(workspaceKind, services, provider);

var metadata = new UnitTestingIncrementalAnalyzerProviderMetadata(
analyzerName,
#if false // Not used in unit testing crawling
highPriorityForActiveFile: false,
#endif
new[] { workspaceKind });

solutionCrawlerRegistrationService.AddAnalyzerProvider(analyzerProvider, metadata);
return analyzerProvider;
}
}
Loading