Skip to content

Commit 4123b1c

Browse files
committed
Work around incorrect implementation of WithMultiplexingStream
This method was corrected for 16.8 Preview 3.
1 parent 8ca0f59 commit 4123b1c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Workspaces/Remote/Core/ServiceDescriptor.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
using System;
88
using System.IO.Pipelines;
9+
using System.Reflection;
910
using MessagePack;
1011
using MessagePack.Resolvers;
1112
using Microsoft.ServiceHub.Framework;
@@ -78,6 +79,26 @@ protected override JsonRpcConnection CreateConnection(JsonRpc jsonRpc)
7879
return connection;
7980
}
8081

82+
public override ServiceRpcDescriptor WithMultiplexingStream(MultiplexingStream? multiplexingStream)
83+
{
84+
var baseResult = base.WithMultiplexingStream(multiplexingStream);
85+
if (baseResult is ServiceDescriptor)
86+
return baseResult;
87+
88+
// work around incorrect implementation in 16.8 Preview 2
89+
if (MultiplexingStream == multiplexingStream)
90+
return this;
91+
92+
var result = (ServiceDescriptor)Clone();
93+
typeof(ServiceRpcDescriptor).GetProperty(nameof(MultiplexingStream))!.SetValue(result, multiplexingStream);
94+
if (result.MultiplexingStreamOptions is null)
95+
return result;
96+
97+
result = (ServiceDescriptor)result.Clone();
98+
typeof(ServiceJsonRpcDescriptor).GetProperty(nameof(MultiplexingStreamOptions))!.SetValue(result, value: null);
99+
return result;
100+
}
101+
81102
internal static class TestAccessor
82103
{
83104
public static MessagePackSerializerOptions Options => s_options;

0 commit comments

Comments
 (0)