Skip to content

Commit 2b744b4

Browse files
authored
Merge pull request #174 from AArnott/msgpack
Use MessagePack for mxstream v2 protocol
2 parents 5e3aad0 + ec79a57 commit 2b744b4

26 files changed

+1028
-551
lines changed

.gitmodules

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[submodule "MessagePack"]
2+
path = ext/MessagePack
3+
url = https://github.com/AArnott/MessagePack-CSharp.git
4+
branch = nerdbank.streams
5+
shallow = true

azure-pipelines/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ jobs:
77
steps:
88
- checkout: self
99
clean: true
10+
submodules: true
1011
- template: install-dependencies.yml
1112

1213
- powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud -p src'
@@ -22,6 +23,7 @@ jobs:
2223
steps:
2324
- checkout: self
2425
clean: true
26+
submodules: true
2527
- template: install-dependencies.yml
2628
- template: dotnet.yml
2729
- template: node.yml
@@ -33,6 +35,7 @@ jobs:
3335
steps:
3436
- checkout: self
3537
clean: true
38+
submodules: true
3639
- template: install-dependencies.yml
3740
- template: dotnet.yml
3841
- template: node.yml

ext/.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# For imported git submodules, don't apply style analyzers
2+
3+
[*.{cs,csx,vb,vbx,h,cpp,idl}]
4+
dotnet_analyzer_diagnostic.severity = none

ext/MessagePack

Submodule MessagePack added at a3e2a28

global.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"sdk": {
3-
"version": "3.1.100"
3+
"version": "3.1.201",
4+
"rollForward": "patch",
5+
"allowPrerelease": false
46
}
57
}

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
2424
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
2525
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.50" PrivateAssets="all" />
26-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
26+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164" PrivateAssets="all" />
2727
</ItemGroup>
2828

2929
<ItemGroup>

src/Nerdbank.Streams.Interop.Tests/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private static async Task Main(string[] args)
4040
await program.RunAsync();
4141
}
4242

43-
private static (StreamReader, StreamWriter) CreateStreamIO(MultiplexingStream.Channel channel)
43+
private static (StreamReader Reader, StreamWriter Writer) CreateStreamIO(MultiplexingStream.Channel channel)
4444
{
4545
var encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);
4646
var reader = new StreamReader(channel.Input.AsStream(), encoding);

src/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Xunit.Abstractions;
1919

2020
#pragma warning disable SA1401 // Fields should be private
21+
#pragma warning disable SA1414 // Tuple types in signatures should have element names
2122

2223
public class MultiplexingStreamTests : TestBase, IAsyncLifetime
2324
{
@@ -60,17 +61,15 @@ public async Task InitializeAsync()
6061
this.mx2 = await mx2;
6162
}
6263

63-
public Task DisposeAsync()
64+
public async Task DisposeAsync()
6465
{
65-
this.mx1?.Dispose();
66-
this.mx2?.Dispose();
66+
await (this.mx1?.DisposeAsync() ?? default);
67+
await (this.mx2?.DisposeAsync() ?? default);
6768
AssertNoFault(this.mx1);
6869
AssertNoFault(this.mx2);
6970

7071
this.mx1?.TraceSource.Listeners.OfType<XunitTraceListener>().SingleOrDefault()?.Dispose();
7172
this.mx2?.TraceSource.Listeners.OfType<XunitTraceListener>().SingleOrDefault()?.Dispose();
72-
73-
return Task.CompletedTask;
7473
}
7574

7675
[Fact]
@@ -180,24 +179,24 @@ public async Task Dispose_CancelsOutstandingOperations()
180179
{
181180
Task offer = this.mx1.OfferChannelAsync("offer");
182181
Task accept = this.mx1.AcceptChannelAsync("accept");
183-
this.mx1.Dispose();
182+
await this.mx1.DisposeAsync();
184183
await Assert.ThrowsAnyAsync<OperationCanceledException>(() => Task.WhenAll(offer, accept)).WithCancellation(this.TimeoutToken);
185184
Assert.True(offer.IsCanceled);
186185
Assert.True(accept.IsCanceled);
187186
}
188187

189188
[Fact]
190-
public void Disposal_DisposesTransportStream()
189+
public async Task Disposal_DisposesTransportStream()
191190
{
192-
this.mx1.Dispose();
191+
await this.mx1.DisposeAsync();
193192
Assert.Throws<ObjectDisposedException>(() => this.transport1.Position);
194193
}
195194

196195
[Fact]
197196
public async Task Dispose_DisposesChannels()
198197
{
199198
var (channel1, channel2) = await this.EstablishChannelsAsync("A");
200-
this.mx1.Dispose();
199+
await this.mx1.DisposeAsync();
201200
Assert.True(channel1.IsDisposed);
202201
await channel1.Completion.WithCancellation(this.TimeoutToken);
203202
#pragma warning disable CS0618 // Type or member is obsolete
@@ -209,21 +208,21 @@ public async Task Dispose_DisposesChannels()
209208
[Fact]
210209
public async Task CreateChannelAsync_ThrowsAfterDisposal()
211210
{
212-
this.mx1.Dispose();
211+
await this.mx1.DisposeAsync();
213212
await Assert.ThrowsAsync<ObjectDisposedException>(() => this.mx1.OfferChannelAsync(string.Empty, this.TimeoutToken)).WithCancellation(this.TimeoutToken);
214213
}
215214

216215
[Fact]
217216
public async Task AcceptChannelAsync_ThrowsAfterDisposal()
218217
{
219-
this.mx1.Dispose();
218+
await this.mx1.DisposeAsync();
220219
await Assert.ThrowsAsync<ObjectDisposedException>(() => this.mx1.AcceptChannelAsync(string.Empty, this.TimeoutToken)).WithCancellation(this.TimeoutToken);
221220
}
222221

223222
[Fact]
224-
public void Completion_CompletedAfterDisposal()
223+
public async Task Completion_CompletedAfterDisposal()
225224
{
226-
this.mx1.Dispose();
225+
await this.mx1.DisposeAsync();
227226
Assert.Equal(TaskStatus.RanToCompletion, this.mx1.Completion.Status);
228227
}
229228

src/Nerdbank.Streams.Tests/WebSocketStreamTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
using Xunit;
2222
using Xunit.Abstractions;
2323

24+
#pragma warning disable SA1414 // Tuple types in signatures should have element names
25+
2426
public partial class WebSocketStreamTests : TestBase
2527
{
2628
private static readonly byte[] CloseRequestMessage = new byte[] { 0x1, 0x0, 0x1 };

src/Nerdbank.Streams/.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This file should not be required, but it works around https://github.com/dotnet/roslyn/issues/42762
2+
3+
[../../ext/**/*.cs]
4+
dotnet_analyzer_diagnostic.severity = none

0 commit comments

Comments
 (0)