-
Couldn't load subscription status.
- Fork 4.2k
Add waitForAsyncOperations LSP request #79669
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
Merged
RikkiGibson
merged 10 commits into
dotnet:main
from
RikkiGibson:lsps-design-time-build-notifications
Aug 8, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d29f515
Add async operation listener to allow integration tests to wait for s…
dibarbet 3370fb8
cleanup listeners
dibarbet bb07693
Merge remote-tracking branch 'upstream/main' into integration_tests_a…
dibarbet 4f398d6
Add messages for when design time builds begin and complete
RikkiGibson 0fc8c9c
Merge remote-tracking branch 'upstream/main' into lsps-design-time-bu…
RikkiGibson 80a5395
include project paths in notification
RikkiGibson e6b1b63
Merge remote-tracking branch 'upstream/main' into lsps-design-time-bu…
RikkiGibson 7860af6
Merge remote-tracking branch 'dibarbet/integration_tests_async_op' in…
RikkiGibson e2c3cf0
fix record attributes
RikkiGibson 259187d
revert unnecessary changes
RikkiGibson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/LanguageServer/Protocol/Handler/Testing/WaitForAsyncOperationsHandler.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // 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.Text.Json.Serialization; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.CodeAnalysis.Host.Mef; | ||
| using Microsoft.CodeAnalysis.Shared.TestHooks; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.LanguageServer.Handler.TestHooks; | ||
|
|
||
| /// <summary> | ||
| /// Implements an LSP request handler to allow the integration tests on the client side to wait for certain server side operations to complete. | ||
| /// This is useful in a few cases where the client makes requests to the server but does not wait for the processing to complete, for example | ||
| /// 1. Loading projects | ||
| /// 2. Reacting to LSP notifications (which are fire and forget) | ||
| /// | ||
| /// This should generally only be used as a last resort when it is impossible for the client to wait specifically for a result it asked for. | ||
| /// </summary> | ||
| [ExportCSharpVisualBasicStatelessLspService(typeof(WaitForAsyncOperationsHandler)), Shared] | ||
| [Method(MethodName)] | ||
| internal class WaitForAsyncOperationsHandler : ILspServiceRequestHandler<WaitForAsyncOperationsParams, WaitForAsyncOperationsResponse> | ||
| { | ||
| internal const string MethodName = "workspace/waitForAsyncOperations"; | ||
|
|
||
| private readonly AsynchronousOperationListenerProvider _provider; | ||
|
|
||
| [ImportingConstructor] | ||
| [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
| public WaitForAsyncOperationsHandler(AsynchronousOperationListenerProvider listenerProvider) | ||
| { | ||
| _provider = listenerProvider; | ||
| } | ||
|
|
||
| public bool MutatesSolutionState => false; | ||
|
|
||
| public bool RequiresLSPSolution => true; | ||
|
|
||
| public async Task<WaitForAsyncOperationsResponse> HandleRequestAsync(WaitForAsyncOperationsParams request, RequestContext context, CancellationToken _) | ||
| { | ||
| context.TraceInformation($"Waiting for {string.Join(", ", request.Operations)} to complete"); | ||
| await _provider.WaitAllAsync(context.Solution!.Workspace, request.Operations).ConfigureAwait(false); | ||
| return new WaitForAsyncOperationsResponse(); | ||
| } | ||
| } | ||
|
|
||
| internal record WaitForAsyncOperationsParams([property: JsonPropertyName("operations")] string[] Operations); | ||
|
|
||
| internal record WaitForAsyncOperationsResponse(); | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use primary constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will allow the next round of IDE auto-fixers to address this. Thanks