Skip to content

Commit

Permalink
Work around incorrect implementation of WithMultiplexingStream
Browse files Browse the repository at this point in the history
This method was corrected for 16.8 Preview 3.
  • Loading branch information
sharwell committed Sep 30, 2020
1 parent 8ca0f59 commit 4123b1c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Workspaces/Remote/Core/ServiceDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using System;
using System.IO.Pipelines;
using System.Reflection;
using MessagePack;
using MessagePack.Resolvers;
using Microsoft.ServiceHub.Framework;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4123b1c

Please sign in to comment.