diff --git a/src/Workspaces/Remote/Core/ServiceDescriptor.cs b/src/Workspaces/Remote/Core/ServiceDescriptor.cs index a53014d0b0416..ef53f79207872 100644 --- a/src/Workspaces/Remote/Core/ServiceDescriptor.cs +++ b/src/Workspaces/Remote/Core/ServiceDescriptor.cs @@ -6,6 +6,7 @@ using System; using System.IO.Pipelines; +using System.Reflection; using MessagePack; using MessagePack.Resolvers; using Microsoft.ServiceHub.Framework; @@ -78,6 +79,26 @@ protected override JsonRpcConnection CreateConnection(JsonRpc jsonRpc) return connection; } + public override ServiceRpcDescriptor WithMultiplexingStream(MultiplexingStream? multiplexingStream) + { + var baseResult = base.WithMultiplexingStream(multiplexingStream); + if (baseResult is ServiceDescriptor) + return baseResult; + + // work around incorrect implementation in 16.8 Preview 2 + if (MultiplexingStream == multiplexingStream) + return this; + + var result = (ServiceDescriptor)Clone(); + typeof(ServiceRpcDescriptor).GetProperty(nameof(MultiplexingStream))!.SetValue(result, multiplexingStream); + if (result.MultiplexingStreamOptions is null) + return result; + + result = (ServiceDescriptor)result.Clone(); + typeof(ServiceJsonRpcDescriptor).GetProperty(nameof(MultiplexingStreamOptions))!.SetValue(result, value: null); + return result; + } + internal static class TestAccessor { public static MessagePackSerializerOptions Options => s_options;