Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Nerdbank.Streams from 2.5.76 to 2.6.77 in /src #559

Merged
merged 2 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/StreamJsonRpc.Tests/DuplexPipeMarshalingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ public async Task InitializeAsync()
new MultiplexingStream.Options
{
TraceSource = mxServerTraceSource,
DefaultChannelTraceSourceFactory = (id, name) => new TraceSource("MX Server channel " + id, SourceLevels.Verbose) { Listeners = { new XunitTraceListener(this.Logger) } },
DefaultChannelTraceSourceFactoryWithQualifier = (id, name) => new TraceSource("MX Server channel " + id, SourceLevels.Verbose) { Listeners = { new XunitTraceListener(this.Logger) } },
},
this.TimeoutToken),
MultiplexingStream.CreateAsync(
streams.Item2,
new MultiplexingStream.Options
{
TraceSource = mxClientTraceSource,
DefaultChannelTraceSourceFactory = (id, name) => new TraceSource("MX Client channel " + id, SourceLevels.Verbose) { Listeners = { new XunitTraceListener(this.Logger) } },
DefaultChannelTraceSourceFactoryWithQualifier = (id, name) => new TraceSource("MX Client channel " + id, SourceLevels.Verbose) { Listeners = { new XunitTraceListener(this.Logger) } },
},
this.TimeoutToken));
this.serverMx = mxStreams[0];
Expand Down Expand Up @@ -429,7 +429,7 @@ await clientHandler.WriteAsync(
{
RequestId = new RequestId(1),
Method = nameof(ServerWithOverloads.OverloadedMethod),
ArgumentsList = new object[] { false, oobChannel.Id, new object() },
ArgumentsList = new object[] { false, oobChannel.QualifiedId.Id, new object() },
},
this.TimeoutToken);
await clientRpcChannel.Output.FlushAsync(this.TimeoutToken);
Expand Down Expand Up @@ -563,10 +563,10 @@ public async Task NotifyWithPipe_IsRejectedAtClient()
[Fact]
public async Task InvokeWithPipe_ServerMethodDoesNotExist_ChannelOfferCanceled()
{
int? channelIdOffered = null;
ulong? channelIdOffered = null;
this.serverMx.ChannelOffered += (s, e) =>
{
channelIdOffered = e.Id;
channelIdOffered = e.QualifiedId.Id;
};
(IDuplexPipe, IDuplexPipe) duplexPipes = FullDuplexStream.CreatePipePair();
await Assert.ThrowsAsync<RemoteMethodNotFoundException>(() => this.clientRpc.InvokeWithCancellationAsync("does not exist", new object[] { duplexPipes.Item2 }, this.TimeoutToken));
Expand Down
5 changes: 3 additions & 2 deletions src/StreamJsonRpc.Tests/HeaderDelimitedMessageHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Buffers;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipelines;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -27,7 +28,7 @@ public HeaderDelimitedMessageHandlerTests(ITestOutputHelper logger)
: base(logger)
{
// Use strict pipe writer so we get deterministic writes for consistent testing.
this.handler = new HeaderDelimitedMessageHandler(this.sendingStream.UseStrictPipeWriter(), this.receivingStream.UseStrictPipeReader(), new JsonMessageFormatter());
this.handler = new HeaderDelimitedMessageHandler(PipeWriter.Create(this.sendingStream), PipeReader.Create(this.receivingStream), new JsonMessageFormatter());
}

[Fact]
Expand All @@ -44,7 +45,7 @@ public async Task SubType_ForcesHeader()
[Fact]
public void EncodingThrowsForNonTextFormatters()
{
this.handler = new HeaderDelimitedMessageHandler(this.sendingStream.UseStrictPipeWriter(), this.receivingStream.UseStrictPipeReader(), new MockFormatter());
this.handler = new HeaderDelimitedMessageHandler(PipeWriter.Create(this.sendingStream), PipeReader.Create(this.receivingStream), new MockFormatter());
Assert.Throws<NotSupportedException>(() => this.handler.Encoding);
Assert.Throws<NotSupportedException>(() => this.handler.Encoding = Encoding.UTF8);
}
Expand Down
16 changes: 8 additions & 8 deletions src/StreamJsonRpc/JsonMessageFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,13 +1108,13 @@ public DuplexPipeConverter(JsonMessageFormatter jsonMessageFormatter)

public override IDuplexPipe? ReadJson(JsonReader reader, Type objectType, IDuplexPipe? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
int? tokenId = JToken.Load(reader).Value<int?>();
ulong? tokenId = JToken.Load(reader).Value<ulong?>();
return this.jsonMessageFormatter.duplexPipeTracker!.GetPipe(tokenId);
}

public override void WriteJson(JsonWriter writer, IDuplexPipe? value, JsonSerializer serializer)
{
var token = this.jsonMessageFormatter.duplexPipeTracker!.GetToken(value);
ulong? token = this.jsonMessageFormatter.duplexPipeTracker!.GetULongToken(value);
writer.WriteValue(token);
}
}
Expand All @@ -1130,13 +1130,13 @@ public PipeReaderConverter(JsonMessageFormatter jsonMessageFormatter)

public override PipeReader? ReadJson(JsonReader reader, Type objectType, PipeReader? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
int? tokenId = JToken.Load(reader).Value<int?>();
ulong? tokenId = JToken.Load(reader).Value<ulong?>();
return this.jsonMessageFormatter.DuplexPipeTracker.GetPipeReader(tokenId);
}

public override void WriteJson(JsonWriter writer, PipeReader? value, JsonSerializer serializer)
{
var token = this.jsonMessageFormatter.DuplexPipeTracker.GetToken(value);
ulong? token = this.jsonMessageFormatter.DuplexPipeTracker.GetULongToken(value);
writer.WriteValue(token);
}
}
Expand All @@ -1152,13 +1152,13 @@ public PipeWriterConverter(JsonMessageFormatter jsonMessageFormatter)

public override PipeWriter? ReadJson(JsonReader reader, Type objectType, PipeWriter? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
int? tokenId = JToken.Load(reader).Value<int?>();
ulong? tokenId = JToken.Load(reader).Value<ulong?>();
return this.jsonMessageFormatter.DuplexPipeTracker.GetPipeWriter(tokenId);
}

public override void WriteJson(JsonWriter writer, PipeWriter? value, JsonSerializer serializer)
{
var token = this.jsonMessageFormatter.DuplexPipeTracker.GetToken(value);
ulong? token = this.jsonMessageFormatter.DuplexPipeTracker.GetULongToken(value);
writer.WriteValue(token);
}
}
Expand All @@ -1174,13 +1174,13 @@ public StreamConverter(JsonMessageFormatter jsonMessageFormatter)

public override Stream? ReadJson(JsonReader reader, Type objectType, Stream? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
int? tokenId = JToken.Load(reader).Value<int?>();
ulong? tokenId = JToken.Load(reader).Value<ulong?>();
return this.jsonMessageFormatter.DuplexPipeTracker.GetPipe(tokenId)?.AsStream();
}

public override void WriteJson(JsonWriter writer, Stream? value, JsonSerializer serializer)
{
var token = this.jsonMessageFormatter.DuplexPipeTracker.GetToken(value?.UsePipe());
ulong? token = this.jsonMessageFormatter.DuplexPipeTracker.GetULongToken(value?.UsePipe());
writer.WriteValue(token);
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/StreamJsonRpc/MessagePackFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -990,12 +990,12 @@ public DuplexPipeFormatter(MessagePackFormatter formatter)
return null;
}

return (T)this.formatter.DuplexPipeTracker.GetPipe(reader.ReadInt32());
return (T)this.formatter.DuplexPipeTracker.GetPipe(reader.ReadUInt64());
}

public void Serialize(ref MessagePackWriter writer, T? value, MessagePackSerializerOptions options)
{
if (this.formatter.DuplexPipeTracker.GetToken(value) is { } token)
if (this.formatter.DuplexPipeTracker.GetULongToken(value) is { } token)
{
writer.Write(token);
}
Expand Down Expand Up @@ -1023,12 +1023,12 @@ public PipeReaderFormatter(MessagePackFormatter formatter)
return null;
}

return (T)this.formatter.DuplexPipeTracker.GetPipeReader(reader.ReadInt32());
return (T)this.formatter.DuplexPipeTracker.GetPipeReader(reader.ReadUInt64());
}

public void Serialize(ref MessagePackWriter writer, T? value, MessagePackSerializerOptions options)
{
if (this.formatter.DuplexPipeTracker.GetToken(value) is { } token)
if (this.formatter.DuplexPipeTracker.GetULongToken(value) is { } token)
{
writer.Write(token);
}
Expand Down Expand Up @@ -1056,12 +1056,12 @@ public PipeWriterFormatter(MessagePackFormatter formatter)
return null;
}

return (T)this.formatter.DuplexPipeTracker.GetPipeWriter(reader.ReadInt32());
return (T)this.formatter.DuplexPipeTracker.GetPipeWriter(reader.ReadUInt64());
}

public void Serialize(ref MessagePackWriter writer, T? value, MessagePackSerializerOptions options)
{
if (this.formatter.DuplexPipeTracker.GetToken(value) is { } token)
if (this.formatter.DuplexPipeTracker.GetULongToken(value) is { } token)
{
writer.Write(token);
}
Expand Down Expand Up @@ -1089,12 +1089,12 @@ public StreamFormatter(MessagePackFormatter formatter)
return null;
}

return (T)this.formatter.DuplexPipeTracker.GetPipe(reader.ReadInt32()).AsStream();
return (T)this.formatter.DuplexPipeTracker.GetPipe(reader.ReadUInt64()).AsStream();
}

public void Serialize(ref MessagePackWriter writer, T? value, MessagePackSerializerOptions options)
{
if (this.formatter.DuplexPipeTracker.GetToken(value?.UsePipe()) is { } token)
if (this.formatter.DuplexPipeTracker.GetULongToken(value?.UsePipe()) is { } token)
{
writer.Write(token);
}
Expand Down
4 changes: 1 addition & 3 deletions src/StreamJsonRpc/PipeMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ public PipeMessageHandler(PipeWriter? writer, PipeReader? reader, IJsonRpcMessag
public PipeMessageHandler(Stream? writer, Stream? reader, IJsonRpcMessageFormatter formatter)
: base(formatter)
{
// We use Strict reader to avoid max buffer size issues in Pipe (https://github.com/dotnet/corefx/issues/30689)
// since it's just stream semantics.
this.Reader = reader?.UseStrictPipeReader();
this.Reader = reader is object ? PipeReader.Create(reader) : null;
this.Writer = writer?.UsePipeWriter();

// After we've completed writing, only dispose the underlying write stream when we've flushed everything.
Expand Down
Loading