提交 4625654d 编写于 作者: T Tomas Matousek

Make callbackTarget required parameter.

上级 fa4ada32
......@@ -28,7 +28,7 @@ internal static partial class SymbolSearchUpdateEngineFactory
if (client != null)
{
var callbackObject = new CallbackObject(logService, progressService);
var session = await client.TryCreateKeepAliveSessionAsync(WellKnownServiceHubServices.RemoteSymbolSearchUpdateEngine, cancellationToken, callbackObject).ConfigureAwait(false);
var session = await client.TryCreateKeepAliveSessionAsync(WellKnownServiceHubServices.RemoteSymbolSearchUpdateEngine, callbackObject, cancellationToken).ConfigureAwait(false);
if (session != null)
{
return new RemoteUpdateEngine(workspace, session);
......
......@@ -145,6 +145,7 @@ private async Task SynchronizeGlobalAssetToRemoteHostIfNeededAsync(Workspace wor
nameof(IRemoteHostService.SynchronizeGlobalAssetsAsync),
workspace.CurrentSolution,
new[] { (object)checksums },
callbackTarget: null,
CancellationToken.None).ConfigureAwait(false);
}
......
......@@ -71,8 +71,8 @@ internal abstract partial class AbstractAddImportFeatureService<TSimpleNameSynta
searchReferenceAssemblies,
packageSources
},
cancellationToken,
callbackTarget).ConfigureAwait(false);
callbackTarget,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
{
......
......@@ -50,6 +50,7 @@ async Task<(ImmutableArray<SerializableImportCompletionItem>, StatisticCounter)>
nameof(IRemoteExtensionMethodImportCompletionService.GetUnimportedExtensionMethodsAsync),
project.Solution,
new object[] { document.Id, position, SymbolKey.CreateString(receiverTypeSymbol), namespaceInScope.ToArray(), forceIndexCreation },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......
......@@ -46,6 +46,7 @@ public async Task<DesignerAttributeResult> ScanDesignerAttributesAsync(Document
nameof(IRemoteDesignerAttributeService.ScanDesignerAttributesAsync),
document.Project.Solution,
new[] { document.Id },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......
......@@ -110,6 +110,7 @@ private async Task FireAndForgetReportAnalyzerPerformanceAsync(Project project,
// +1 for project itself
project.DocumentIds.Count + 1
},
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
}
catch (Exception ex) when (FatalError.ReportWithoutCrashUnlessCanceled(ex))
......@@ -139,7 +140,7 @@ private async Task FireAndForgetReportAnalyzerPerformanceAsync(Project project,
forcedAnalysis, analyzerDriver.AnalysisOptions.ReportSuppressedDiagnostics, analyzerDriver.AnalysisOptions.LogAnalyzerExecutionTime,
project.Id, optionAsset.Checksum, analyzerMap.Keys.ToArray());
using var session = await client.TryCreateSessionAsync(WellKnownServiceHubServices.CodeAnalysisService, solution, cancellationToken).ConfigureAwait(false);
using var session = await client.TryCreateSessionAsync(WellKnownServiceHubServices.CodeAnalysisService, solution, callbackTarget: null, cancellationToken).ConfigureAwait(false);
if (session == null)
{
// session is not available
......
......@@ -540,6 +540,7 @@ private async Task ReportAnalyzerPerformanceAsync(Document document, Compilation
WellKnownServiceHubServices.CodeAnalysisService,
nameof(IRemoteDiagnosticAnalyzerService.ReportAnalyzerPerformance),
new object[] { pooledObject.Object.ToAnalyzerPerformanceInfo(AnalyzerService), /* unit count */ 1 },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
}
catch (Exception ex) when (FatalError.ReportWithoutCrashUnlessCanceled(ex))
......
......@@ -40,6 +40,7 @@ internal abstract partial class AbstractDocumentHighlightsService : IDocumentHig
position,
documentsToSearch.Select(d => d.Id).ToArray()
},
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......
......@@ -41,6 +41,7 @@ internal abstract partial class AbstractNavigateToSearchService : INavigateToSea
nameof(IRemoteNavigateToSearchService.SearchDocumentAsync),
solution,
new object[] { document.Id, searchPattern, kinds.ToArray() },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......@@ -66,6 +67,7 @@ internal abstract partial class AbstractNavigateToSearchService : INavigateToSea
nameof(IRemoteNavigateToSearchService.SearchProjectAsync),
solution,
new object[] { project.Id, priorityDocuments.Select(d => d.Id).ToArray(), searchPattern, kinds.ToArray() },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......
......@@ -51,7 +51,9 @@ public async Task<IList<TodoComment>> GetTodoCommentsAsync(Document document, IL
WellKnownServiceHubServices.CodeAnalysisService,
nameof(IRemoteTodoCommentService.GetTodoCommentsAsync),
document.Project.Solution,
new object[] { document.Id, commentDescriptors }, cancellationToken).ConfigureAwait(false);
new object[] { document.Id, commentDescriptors },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
{
......
......@@ -42,6 +42,7 @@ public RemoteCodeLensReferencesService()
nameof(IRemoteCodeLensReferencesService.GetReferenceCountAsync),
solution,
new object[] { documentId, syntaxNode.Span, maxSearchResults },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......@@ -88,6 +89,7 @@ public RemoteCodeLensReferencesService()
nameof(IRemoteCodeLensReferencesService.FindReferenceMethodsAsync),
solution,
new object[] { documentId, syntaxNode.Span },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......@@ -118,6 +120,7 @@ public RemoteCodeLensReferencesService()
nameof(IRemoteCodeLensReferencesService.GetFullyQualifiedName),
solution,
new object[] { documentId, syntaxNode.Span },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......@@ -251,6 +254,7 @@ private static string GetLineTextOrEmpty(TextLineCollection lines, int index)
nameof(IRemoteCodeLensReferencesService.FindReferenceLocationsAsync),
solution,
new object[] { documentId, syntaxNode.Span },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......
......@@ -210,6 +210,7 @@ private async Task<RemoteHostClient> EnableAsync(CancellationToken cancellationT
nameof(IRemoteHostService.SynchronizeGlobalAssetsAsync),
_workspace.CurrentSolution,
new[] { (object)checksums },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (success)
......
......@@ -184,8 +184,11 @@ private void PushTextChanges(Document oldDocument, Document newDocument)
var state = await oldDocument.State.GetStateChecksumsAsync(CancellationToken).ConfigureAwait(false);
_ = await client.TryRunRemoteAsync(
WellKnownRemoteHostServices.RemoteHostService, nameof(IRemoteHostService.SynchronizeTextAsync),
new object[] { oldDocument.Id, state.Text, textChanges }, CancellationToken).ConfigureAwait(false);
WellKnownRemoteHostServices.RemoteHostService,
nameof(IRemoteHostService.SynchronizeTextAsync),
new object[] { oldDocument.Id, state.Text, textChanges },
callbackTarget: null,
CancellationToken).ConfigureAwait(false);
}, CancellationToken).CompletesAsyncOperation(token);
}
......
......@@ -40,7 +40,7 @@ private enum GlobalNotificationState
/// stop prior to hearing about the relevant start).
/// </summary>
private readonly object _globalNotificationsGate = new object();
private readonly Task<GlobalNotificationState> _globalNotificationsTask = Task.FromResult(GlobalNotificationState.NotStarted);
private Task<GlobalNotificationState> _globalNotificationsTask = Task.FromResult(GlobalNotificationState.NotStarted);
public static async Task<ServiceHubRemoteHostClient?> CreateAsync(Workspace workspace, CancellationToken cancellationToken)
{
......
......@@ -157,7 +157,7 @@ public async Task TestSessionWithNoSolution()
var mock = new MockLogAndProgressService();
var client = await service.TryGetRemoteHostClientAsync(CancellationToken.None);
var session = await client.TryCreateKeepAliveSessionAsync(WellKnownServiceHubServices.RemoteSymbolSearchUpdateEngine, CancellationToken.None, mock);
var session = await client.TryCreateKeepAliveSessionAsync(WellKnownServiceHubServices.RemoteSymbolSearchUpdateEngine, callbackTarget: mock, CancellationToken.None);
var result = await session.TryInvokeAsync(nameof(IRemoteSymbolSearchUpdateEngine.UpdateContinuouslyAsync), new object[] { "emptySource", Path.GetTempPath() }, CancellationToken.None);
Assert.True(result);
......@@ -185,7 +185,7 @@ public async Task TestSessionClosed()
});
// create session that stay alive until client alive (ex, SymbolSearchUpdateEngine)
var session = await client.TryCreateKeepAliveSessionAsync("Test", CancellationToken.None);
var session = await client.TryCreateKeepAliveSessionAsync("Test", callbackTarget: null, CancellationToken.None);
// mimic unfortunate call that happens to be in the middle of communication.
var task = session.TryInvokeAsync("TestMethodAsync", arguments: null, CancellationToken.None);
......
......@@ -120,6 +120,7 @@ private async Task UpdatePrimaryWorkspace(InProcRemoteHostClient client, Solutio
nameof(IRemoteHostService.SynchronizePrimaryWorkspaceAsync),
solution,
new object[] { await solution.State.GetChecksumAsync(CancellationToken.None), _solutionVersion++ },
callbackTarget: null,
CancellationToken.None));
}
......
......@@ -106,6 +106,7 @@ public async Task TestRemoteHostTextSynchronize()
WellKnownRemoteHostServices.RemoteHostService,
nameof(IRemoteHostService.SynchronizeTextAsync),
new object[] { oldDocument.Id, oldState.Text, newText.GetTextChanges(oldText) },
callbackTarget: null,
CancellationToken.None);
// apply change to solution
......@@ -134,6 +135,7 @@ public async Task TestTodoComments()
nameof(IRemoteTodoCommentService.GetTodoCommentsAsync),
solution,
new object[] { solution.Projects.First().DocumentIds.First(), ImmutableArray.Create(new TodoCommentDescriptor("TODO", 0)) },
callbackTarget: null,
CancellationToken.None);
Assert.Equal(1, comments.Value.Count);
......@@ -157,6 +159,7 @@ class Test { }";
nameof(IRemoteDesignerAttributeService.ScanDesignerAttributesAsync),
solution,
new[] { solution.Projects.First().DocumentIds.First() },
callbackTarget: null,
CancellationToken.None);
Assert.Equal("Form", result.Value.DesignerAttributeArgument);
......@@ -177,6 +180,7 @@ public async Task TestRemoteHostSynchronizeGlobalAssets()
nameof(IRemoteHostService.SynchronizeGlobalAssetsAsync),
workspace.CurrentSolution,
new object[] { new Checksum[0] { } },
callbackTarget: null,
CancellationToken.None));
var storage = client.AssetStorage;
......@@ -377,6 +381,7 @@ private async Task UpdatePrimaryWorkspace(InProcRemoteHostClient client, Solutio
nameof(IRemoteHostService.SynchronizePrimaryWorkspaceAsync),
solution,
new object[] { await solution.State.GetChecksumAsync(CancellationToken.None), _solutionVersion++ },
callbackTarget: null,
CancellationToken.None));
}
......
......@@ -179,6 +179,7 @@ void Method()
nameof(IRemoteHostService.SynchronizeGlobalAssetsAsync),
workspace.CurrentSolution,
new[] { new Checksum[] { asset.Checksum } },
callbackTarget: null,
CancellationToken.None));
// set option
......@@ -234,6 +235,7 @@ void Method()
nameof(IRemoteHostService.SynchronizeGlobalAssetsAsync),
workspace.CurrentSolution,
new[] { new Checksum[] { asset.Checksum } },
callbackTarget: null,
CancellationToken.None));
// run analysis
......
......@@ -29,7 +29,7 @@ public async Task<Session> CreateSessionAsync(Solution solution, object callback
return null;
}
var innerSession = await _client.TryCreateSessionAsync(_serviceName, solution, cancellationToken, callbackTarget).ConfigureAwait(false);
var innerSession = await _client.TryCreateSessionAsync(_serviceName, solution, callbackTarget, cancellationToken).ConfigureAwait(false);
if (innerSession == null)
{
return null;
......
......@@ -71,6 +71,7 @@ public static void SetLoggers(IGlobalOptionService optionService, IThreadingCont
WellKnownRemoteHostServices.RemoteHostService,
nameof(IRemoteHostService.SetLoggingFunctionIds),
new object[] { loggerTypes, functionIds },
callbackTarget: null,
CancellationToken.None));
}
......
......@@ -16,13 +16,13 @@ internal UnitTestingRemoteHostClientWrapper(RemoteHostClient underlyingObject)
public async Task<UnitTestingKeepAliveSessionWrapper> TryCreateUnitTestingKeepAliveSessionWrapperAsync(string serviceName, CancellationToken cancellationToken)
{
var keepAliveSession = await UnderlyingObject.TryCreateKeepAliveSessionAsync(serviceName, cancellationToken).ConfigureAwait(false);
var keepAliveSession = await UnderlyingObject.TryCreateKeepAliveSessionAsync(serviceName, callbackTarget: null, cancellationToken).ConfigureAwait(false);
return new UnitTestingKeepAliveSessionWrapper(keepAliveSession);
}
public async Task<UnitTestingSessionWithSolutionWrapper> TryCreateUnitingSessionWithSolutionWrapperAsync(string serviceName, Solution solution, CancellationToken cancellationToken)
{
var session = await UnderlyingObject.TryCreateSessionAsync(serviceName, solution, cancellationToken).ConfigureAwait(false);
var session = await UnderlyingObject.TryCreateSessionAsync(serviceName, solution, callbackTarget: null, cancellationToken).ConfigureAwait(false);
return new UnitTestingSessionWithSolutionWrapper(session);
}
......
......@@ -44,6 +44,7 @@ internal static partial class DeclarationFinder
nameof(IRemoteSymbolFinder.FindAllDeclarationsWithNormalQueryAsync),
solution,
new object[] { project.Id, query.Name, query.Kind, criteria },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......
......@@ -47,6 +47,7 @@ internal static partial class DeclarationFinder
nameof(IRemoteSymbolFinder.FindSolutionSourceDeclarationsWithNormalQueryAsync),
solution,
new object[] { name, ignoreCase, criteria },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......@@ -85,6 +86,7 @@ internal static partial class DeclarationFinder
nameof(IRemoteSymbolFinder.FindProjectSourceDeclarationsWithNormalQueryAsync),
project.Solution,
new object[] { project.Id, name, ignoreCase, criteria },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......@@ -119,6 +121,7 @@ internal static partial class DeclarationFinder
nameof(IRemoteSymbolFinder.FindSolutionSourceDeclarationsWithPatternAsync),
solution,
new object[] { pattern, criteria },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......@@ -152,6 +155,7 @@ internal static partial class DeclarationFinder
nameof(IRemoteSymbolFinder.FindProjectSourceDeclarationsWithPatternAsync),
project.Solution,
new object[] { project.Id, pattern, criteria },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
if (result.HasValue)
......
......@@ -32,8 +32,8 @@ public static partial class SymbolFinder
nameof(IRemoteSymbolFinder.FindLiteralReferencesAsync),
solution,
new object[] { value, typeCode },
cancellationToken,
serverCallback).ConfigureAwait(false);
serverCallback,
cancellationToken).ConfigureAwait(false);
if (success)
{
......
......@@ -49,8 +49,8 @@ public static partial class SymbolFinder
documents?.Select(d => d.Id).ToArray(),
SerializableFindReferencesSearchOptions.Dehydrate(options),
},
cancellationToken,
serverCallback).ConfigureAwait(false);
serverCallback,
cancellationToken).ConfigureAwait(false);
if (success)
{
......
......@@ -102,7 +102,7 @@ public static string CreateClientId(string prefix)
/// <summary>
/// Creates <see cref="SessionWithSolution"/> for the <paramref name="serviceName"/> if possible, otherwise returns <see langword="null"/>.
/// </summary>
public async Task<SessionWithSolution?> TryCreateSessionAsync(string serviceName, Solution solution, CancellationToken cancellationToken, object? callbackTarget = null)
public async Task<SessionWithSolution?> TryCreateSessionAsync(string serviceName, Solution solution, object? callbackTarget, CancellationToken cancellationToken)
{
var connection = await TryCreateConnectionAsync(serviceName, callbackTarget, cancellationToken).ConfigureAwait(false);
if (connection == null)
......@@ -116,7 +116,7 @@ public static string CreateClientId(string prefix)
/// <summary>
/// Creates <see cref="KeepAliveSession"/> for the <paramref name="serviceName"/>, otherwise returns <see langword="null"/>.
/// </summary>
public async Task<KeepAliveSession?> TryCreateKeepAliveSessionAsync(string serviceName, CancellationToken cancellationToken, object? callbackTarget = null)
public async Task<KeepAliveSession?> TryCreateKeepAliveSessionAsync(string serviceName, object? callbackTarget, CancellationToken cancellationToken)
{
var connection = await TryCreateConnectionAsync(serviceName, callbackTarget, cancellationToken).ConfigureAwait(false);
if (connection == null)
......@@ -128,9 +128,9 @@ public static string CreateClientId(string prefix)
}
public async Task<bool> TryRunRemoteAsync(string serviceName, string targetName, Solution solution,
IReadOnlyList<object> arguments, CancellationToken cancellationToken, object? callbackTarget = null)
IReadOnlyList<object> arguments, object? callbackTarget, CancellationToken cancellationToken)
{
using var session = await TryCreateSessionAsync(serviceName, solution, cancellationToken, callbackTarget).ConfigureAwait(false);
using var session = await TryCreateSessionAsync(serviceName, solution, callbackTarget, cancellationToken).ConfigureAwait(false);
if (session == null)
{
return false;
......@@ -140,7 +140,7 @@ public static string CreateClientId(string prefix)
return true;
}
public async Task<bool> TryRunRemoteAsync(string serviceName, string targetName, IReadOnlyList<object> arguments, CancellationToken cancellationToken, object? callbackTarget = null)
public async Task<bool> TryRunRemoteAsync(string serviceName, string targetName, IReadOnlyList<object> arguments, object? callbackTarget, CancellationToken cancellationToken)
{
using var connection = await TryCreateConnectionAsync(serviceName, callbackTarget, cancellationToken).ConfigureAwait(false);
if (connection == null)
......@@ -152,9 +152,9 @@ public async Task<bool> TryRunRemoteAsync(string serviceName, string targetName,
return true;
}
public async Task<Optional<T>> TryRunRemoteAsync<T>(string serviceName, string targetName, Solution solution, IReadOnlyList<object> arguments, CancellationToken cancellationToken, object? callbackTarget = null)
public async Task<Optional<T>> TryRunRemoteAsync<T>(string serviceName, string targetName, Solution solution, IReadOnlyList<object> arguments, object? callbackTarget, CancellationToken cancellationToken)
{
using var session = await TryCreateSessionAsync(serviceName, solution, cancellationToken, callbackTarget).ConfigureAwait(false);
using var session = await TryCreateSessionAsync(serviceName, solution, callbackTarget, cancellationToken).ConfigureAwait(false);
if (session == null)
{
return default;
......
......@@ -36,6 +36,7 @@ public static async Task SynchronizePrimaryWorkspaceAsync(this Workspace workspa
nameof(IRemoteHostService.SynchronizePrimaryWorkspaceAsync),
solution,
new object[] { checksum, solution.WorkspaceVersion },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册