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

Merge latest Library.Template #817

Merged
merged 18 commits into from
Dec 24, 2024
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
18 changes: 10 additions & 8 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<PackageVersion Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="$(VSThreadingVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Threading" Version="$(VSThreadingVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Validation" Version="17.8.8" />
Expand All @@ -27,15 +26,18 @@
<PackageVersion Include="System.IO.Pipes" Version="4.3.0" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="xunit.abstractions" Version="2.0.3" />
<PackageVersion Include="xunit.combinatorial" Version="1.6.24" />
<PackageVersion Include="xunit.extensibility.core" Version="2.9.2" />
<PackageVersion Include="xunit.runner.console" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="xunit.skippablefact" Version="1.5.23" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.v3.extensibility.core" Version="1.0.0" />
<PackageVersion Include="xunit.combinatorial" Version="2.0.5-alpha" />
</ItemGroup>
<ItemGroup Label="Library.Template">
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />
<PackageVersion Include="xunit.v3" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<!-- Put repo-specific GlobalPackageReference items in this group. -->
</ItemGroup>
<ItemGroup Label="Library.Template">
<GlobalPackageReference Include="CSharpIsNullAnalyzer" Version="0.1.593" />
<GlobalPackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />
<!-- The condition works around https://github.com/dotnet/sdk/issues/44951 -->
Expand Down
1 change: 1 addition & 0 deletions docfx/docs/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Features
href: features.md
- name: Getting Started
Expand Down
1 change: 1 addition & 0 deletions docfx/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
items:
- name: Docs
href: docs/
- name: API
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "9.0.100",
"version": "9.0.101",
"rollForward": "patch",
"allowPrerelease": false
}
Expand Down
3 changes: 3 additions & 0 deletions test/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ dotnet_diagnostic.VSTHRD003.severity = silent

# SA1611: Element parameters should be documented
dotnet_diagnostic.SA1611.severity = silent

# xUnit1051: Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken
dotnet_diagnostic.xUnit1051.severity = suggestion
3 changes: 1 addition & 2 deletions test/IsolatedTestHost/IsolatedTestHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit.abstractions" />
<PackageReference Include="xunit.extensibility.core" />
<PackageReference Include="xunit.v3.extensibility.core" ExcludeAssets="build" />
</ItemGroup>

</Project>
14 changes: 13 additions & 1 deletion test/IsolatedTestHost/TestOutputHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@
namespace IsolatedTestHost
{
using System;
using Xunit.Abstractions;
using Xunit;

internal class TestOutputHelper : ITestOutputHelper
{
public string Output => throw new NotImplementedException();

public void Write(string message)
{
Console.Write(message);
}

public void Write(string format, params object[] args)
{
Console.Write(format, args);
}

public void WriteLine(string message)
{
Console.WriteLine(message);
Expand Down
1 change: 0 additions & 1 deletion test/Nerdbank.Streams.Tests/BufferTextWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Threading.Tasks;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;

public class BufferTextWriterTests : TestBase
{
Expand Down
1 change: 0 additions & 1 deletion test/Nerdbank.Streams.Tests/BufferWriterStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Microsoft;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;

public class BufferWriterStreamTests : TestBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using NSubstitute;
using NSubstitute.ReceivedExtensions;
using Xunit;
using Xunit.Abstractions;

public class FullDuplexStreamCombineTests : TestBase
{
Expand Down
1 change: 0 additions & 1 deletion test/Nerdbank.Streams.Tests/FullDuplexStreamPairTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Microsoft.VisualStudio.Threading;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;

public class FullDuplexStreamPairTests : TestBase
{
Expand Down
1 change: 0 additions & 1 deletion test/Nerdbank.Streams.Tests/HalfDuplexStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Microsoft.VisualStudio.Threading;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;

#pragma warning disable CS0618 // Type or member is obsolete

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright (c) Andrew Arnott. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.IO;
using System.IO.Pipelines;
using Xunit.Abstractions;
using Xunit;

public class IOPipelinesStreamPipeReaderTests : StreamPipeReaderTestBase
{
Expand Down
1 change: 0 additions & 1 deletion test/Nerdbank.Streams.Tests/MonitoringStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Nerdbank.Streams;
using NSubstitute;
using Xunit;
using Xunit.Abstractions;

public class MonitoringStreamTests : TestBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;

public class MultiplexingProtocolExceptionTests : TestBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Nerdbank.Streams;
using NSubstitute;
using Xunit;
using Xunit.Abstractions;

public class MultiplexingStreamBasicTests : TestBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.IO.Pipelines;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;

public class MultiplexingStreamChannelOptionsTests : TestBase
{
Expand Down
16 changes: 8 additions & 8 deletions test/Nerdbank.Streams.Tests/MultiplexingStreamPerfTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Nerdbank.Streams;
using StreamJsonRpc;
using Xunit;
using Xunit.Abstractions;

public class MultiplexingStreamPerfTests : TestBase, IAsyncLifetime
{
Expand All @@ -32,27 +31,28 @@ public MultiplexingStreamPerfTests(ITestOutputHelper logger)
this.clientPipe = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut, PipeOptions.Asynchronous);
}

public async Task InitializeAsync()
public async ValueTask InitializeAsync()
{
Task connectTask = this.serverPipe.WaitForConnectionAsync(this.TimeoutToken);
await this.clientPipe.ConnectAsync(this.TimeoutToken);
await connectTask;
}

public Task DisposeAsync()
public ValueTask DisposeAsync()
{
this.serverPipe.Dispose();
this.clientPipe.Dispose();
return Task.CompletedTask;
this.Dispose();
return default;
}

[SkippableFact]
[Fact]
public Task JsonRpcPerf_Pipe() => this.JsonRpcPerf(useChannel: false);

[SkippableFact]
[Fact]
public Task JsonRpcPerf_Channel() => this.JsonRpcPerf(useChannel: true);

[SkippableFact]
[Fact]
public async Task SendLargePayloadOnOneStream()
{
if (await this.ExecuteInIsolationAsync())
Expand Down Expand Up @@ -103,7 +103,7 @@ await Task.WhenAll(
}
}

[SkippableFact]
[Fact]
public async Task SendLargePayloadOnManyChannels()
{
if (await this.ExecuteInIsolationAsync())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Microsoft.VisualStudio.Threading;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;

public class MultiplexingStreamSeededChannelTests : TestBase, IAsyncLifetime
{
Expand Down Expand Up @@ -61,12 +60,12 @@ public MultiplexingStreamSeededChannelTests(ITestOutputHelper logger)
this.mx2 = MultiplexingStream.Create(this.transport2, new MultiplexingStream.Options(this.options) { TraceSource = mx2TraceSource, DefaultChannelTraceSourceFactoryWithQualifier = mx2TraceSourceFactory });
}

public Task InitializeAsync()
public ValueTask InitializeAsync()
{
return Task.CompletedTask;
return default;
}

public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{
await (this.mx1?.DisposeAsync() ?? default);
await (this.mx2?.DisposeAsync() ?? default);
Expand All @@ -75,6 +74,8 @@ public async Task DisposeAsync()

this.mx1?.TraceSource.Listeners.OfType<XunitTraceListener>().SingleOrDefault()?.Dispose();
this.mx2?.TraceSource.Listeners.OfType<XunitTraceListener>().SingleOrDefault()?.Dispose();

this.Dispose();
}

[Fact]
Expand Down
15 changes: 8 additions & 7 deletions test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Microsoft.VisualStudio.Threading;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;

#pragma warning disable SA1401 // Fields should be private
#pragma warning disable SA1414 // Tuple types in signatures should have element names
Expand All @@ -36,12 +35,12 @@ public MultiplexingStreamTests(ITestOutputHelper logger)

protected virtual int ProtocolMajorVersion { get; } = 1;

public async Task InitializeAsync()
public async ValueTask InitializeAsync()
{
await this.ReinitializeMxStreamsAsync(new MultiplexingStream.Options());
}

public async Task DisposeAsync()
public async ValueTask DisposeAsync()
{
await (this.mx1?.DisposeAsync() ?? default);
await (this.mx2?.DisposeAsync() ?? default);
Expand All @@ -50,6 +49,8 @@ public async Task DisposeAsync()

this.mx1?.TraceSource.Listeners.OfType<XunitTraceListener>().SingleOrDefault()?.Dispose();
this.mx2?.TraceSource.Listeners.OfType<XunitTraceListener>().SingleOrDefault()?.Dispose();

this.Dispose();
}

[Fact, Obsolete]
Expand Down Expand Up @@ -751,7 +752,7 @@ public async Task PartialFrameSentWithoutExplicitFlush()
await ReadAtLeastAsync(s2, new ArraySegment<byte>(recvBuffer), recvBuffer.Length, this.TimeoutToken);
}

[SkippableTheory]
[Theory]
[InlineData(true)]
[InlineData(false)]
public async Task CancelChannelOfferBeforeAcceptance(bool cancelFirst)
Expand All @@ -771,20 +772,20 @@ public async Task CancelChannelOfferBeforeAcceptance(bool cancelFirst)
await Task.Delay(250);
}

MultiplexingStream.Channel? acceptedChannel = await this.mx2.AcceptChannelAsync(string.Empty, ExpectedTimeoutToken).ConfigureAwait(false);
MultiplexingStream.Channel? acceptedChannel = await this.mx2.AcceptChannelAsync(string.Empty, ExpectedTimeoutToken);
acceptedStream = acceptedChannel.AsStream();

// In this case, we accepted the channel before receiving the cancellation notice. The channel should be terminated by the remote side very soon.
int bytesRead = await acceptedStream.ReadAsync(new byte[1], 0, 1, this.TimeoutToken).WithCancellation(this.TimeoutToken);
Assert.Equal(0, bytesRead); // confirm that the stream was closed.
this.Logger.WriteLine("Verified the channel terminated condition.");
Skip.If(cancelFirst);
Assert.SkipWhen(cancelFirst, "Skipped");
}
catch (OperationCanceledException) when (acceptedStream == null)
{
// In this case, the channel offer was canceled before we accepted it.
this.Logger.WriteLine("Verified the channel offer was canceled before acceptance condition.");
Skip.IfNot(cancelFirst);
Assert.SkipUnless(cancelFirst, "Skipped");
}
}

Expand Down
1 change: 0 additions & 1 deletion test/Nerdbank.Streams.Tests/MultiplexingStreamV2Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.VisualStudio.Threading;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;

public class MultiplexingStreamV2Tests : MultiplexingStreamTests
{
Expand Down
1 change: 0 additions & 1 deletion test/Nerdbank.Streams.Tests/MultiplexingStreamV3Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.VisualStudio.Threading;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;

public class MultiplexingStreamV3Tests : MultiplexingStreamV2Tests
{
Expand Down
5 changes: 2 additions & 3 deletions test/Nerdbank.Streams.Tests/Nerdbank.Streams.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('Windows'))">$(TargetFrameworks);net472</TargetFrameworks>
<OutputType>Exe</OutputType>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RootNamespace />

Expand Down Expand Up @@ -32,11 +33,9 @@
<PackageReference Include="PInvoke.Kernel32" />
<PackageReference Include="StreamJsonRpc" />
<PackageReference Include="System.IO.Pipes" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.combinatorial" />
<PackageReference Include="xunit.runner.console" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="xunit.skippablefact" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IsolatedTestHost\IsolatedTestHost.csproj">
Expand Down
9 changes: 6 additions & 3 deletions test/Nerdbank.Streams.Tests/NestedPipeReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Threading.Tasks;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;

public class NestedPipeReaderTests : TestBase, IAsyncLifetime
{
Expand All @@ -20,9 +19,13 @@ public NestedPipeReaderTests(ITestOutputHelper logger)
{
}

public Task DisposeAsync() => Task.CompletedTask;
public ValueTask DisposeAsync()
{
this.Dispose();
return default;
}

public async Task InitializeAsync()
public async ValueTask InitializeAsync()
{
await this.pipe.Writer.WriteAsync(OriginalBuffer, this.TimeoutToken);
}
Expand Down
1 change: 0 additions & 1 deletion test/Nerdbank.Streams.Tests/NestedStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Nerdbank.Streams;
using NSubstitute;
using Xunit;
using Xunit.Abstractions;

public class NestedStreamTests : TestBase
{
Expand Down
Loading
Loading