From 4123b1c06ee17b42644931995ab00b15907cd8c6 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 23 Sep 2020 18:08:10 -0700 Subject: [PATCH] Work around incorrect implementation of WithMultiplexingStream This method was corrected for 16.8 Preview 3. --- .../Remote/Core/ServiceDescriptor.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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;