From c263bfd50b55f59e24f037df9f121d4f19e3e430 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 23 Apr 2017 14:59:49 -0500 Subject: [PATCH] Update signature of TryCreateServiceSessionAsync so an optional argument is clear --- .../TestUtilities/Remote/InProcRemostHostClient.cs | 2 +- src/VisualStudio/Core/Next/Remote/JsonRpcSession.cs | 4 ++-- .../Core/Next/Remote/ServiceHubRemoteHostClient.cs | 5 +++-- src/Workspaces/Core/Portable/Remote/RemoteHostClient.cs | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/EditorFeatures/TestUtilities/Remote/InProcRemostHostClient.cs b/src/EditorFeatures/TestUtilities/Remote/InProcRemostHostClient.cs index 0ef9f9a7133..6dbb9806071 100644 --- a/src/EditorFeatures/TestUtilities/Remote/InProcRemostHostClient.cs +++ b/src/EditorFeatures/TestUtilities/Remote/InProcRemostHostClient.cs @@ -59,7 +59,7 @@ public static async Task CreateAsync(Workspace workspace, bool public AssetStorage AssetStorage => _inprocServices.AssetStorage; - protected override async Task TryCreateServiceSessionAsync(string serviceName, Func> getSnapshotAsync, object callbackTarget, CancellationToken cancellationToken) + protected override async Task TryCreateServiceSessionAsync(string serviceName, Optional>> getSnapshotAsync, object callbackTarget, CancellationToken cancellationToken) { // get stream from service hub to communicate snapshot/asset related information // this is the back channel the system uses to move data between VS and remote host diff --git a/src/VisualStudio/Core/Next/Remote/JsonRpcSession.cs b/src/VisualStudio/Core/Next/Remote/JsonRpcSession.cs index 0e08a28f8ce..a970925cdd7 100644 --- a/src/VisualStudio/Core/Next/Remote/JsonRpcSession.cs +++ b/src/VisualStudio/Core/Next/Remote/JsonRpcSession.cs @@ -31,13 +31,13 @@ internal class JsonRpcSession : RemoteHostClient.Session private readonly CancellationTokenRegistration _cancellationRegistration; public static async Task CreateAsync( - Func> getSnapshotAsync, + Optional>> getSnapshotAsync, object callbackTarget, Stream serviceStream, Stream snapshotStreamOpt, CancellationToken cancellationToken) { - var snapshot = getSnapshotAsync == null ? null : await getSnapshotAsync(cancellationToken).ConfigureAwait(false); + var snapshot = getSnapshotAsync.Value == null ? null : await getSnapshotAsync.Value(cancellationToken).ConfigureAwait(false); JsonRpcSession session; try diff --git a/src/VisualStudio/Core/Next/Remote/ServiceHubRemoteHostClient.cs b/src/VisualStudio/Core/Next/Remote/ServiceHubRemoteHostClient.cs index d9690cf4c5c..930f6b5e3e5 100644 --- a/src/VisualStudio/Core/Next/Remote/ServiceHubRemoteHostClient.cs +++ b/src/VisualStudio/Core/Next/Remote/ServiceHubRemoteHostClient.cs @@ -5,6 +5,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Execution; @@ -114,11 +115,11 @@ private static async Task RegisterWorkspaceHostAsync(Workspace workspace, Remote _rpc.StartListening(); } - protected override async Task TryCreateServiceSessionAsync(string serviceName, Func> getSnapshotAsync, object callbackTarget, CancellationToken cancellationToken) + protected override async Task TryCreateServiceSessionAsync(string serviceName, Optional>> getSnapshotAsync, object callbackTarget, CancellationToken cancellationToken) { // get stream from service hub to communicate snapshot/asset related information // this is the back channel the system uses to move data between VS and remote host for solution related information - var snapshotStream = getSnapshotAsync == null ? null : await RequestServiceAsync(_hubClient, WellKnownServiceHubServices.SnapshotService, _hostGroup, _timeout, cancellationToken).ConfigureAwait(false); + var snapshotStream = getSnapshotAsync.Value != null ? null : await RequestServiceAsync(_hubClient, WellKnownServiceHubServices.SnapshotService, _hostGroup, _timeout, cancellationToken).ConfigureAwait(false); // get stream from service hub to communicate service specific information // this is what consumer actually use to communicate information diff --git a/src/Workspaces/Core/Portable/Remote/RemoteHostClient.cs b/src/Workspaces/Core/Portable/Remote/RemoteHostClient.cs index 2879be6e70c..cd5b36d1378 100644 --- a/src/Workspaces/Core/Portable/Remote/RemoteHostClient.cs +++ b/src/Workspaces/Core/Portable/Remote/RemoteHostClient.cs @@ -77,7 +77,7 @@ public async Task TryCreateServiceSessionAsync(string serviceName, Solu protected abstract void OnDisconnected(); - protected abstract Task TryCreateServiceSessionAsync(string serviceName, Func> getSnapshotAsync, object callbackTarget, CancellationToken cancellationToken); + protected abstract Task TryCreateServiceSessionAsync(string serviceName, Optional>> getSnapshotAsync, object callbackTarget, CancellationToken cancellationToken); internal void Shutdown() { @@ -175,7 +175,7 @@ public class NoOpClient : RemoteHostClient } protected override Task TryCreateServiceSessionAsync( - string serviceName, Func> getSnapshotAsync, object callbackTarget, CancellationToken cancellationToken) + string serviceName, Optional>> getSnapshotAsync, object callbackTarget, CancellationToken cancellationToken) { return SpecializedTasks.Default(); } -- GitLab