Skip to content

Commit

Permalink
Fix timeout token registration disposal
Browse files Browse the repository at this point in the history
This prevents a bunch of InvalidOperationExceptions from being thrown when a timeout is logged without an active test.
  • Loading branch information
AArnott committed Dec 24, 2024
1 parent 93d90f9 commit a7ae48e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/Nerdbank.Streams.Tests/MultiplexingStreamPerfTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public ValueTask DisposeAsync()
{
this.serverPipe.Dispose();
this.clientPipe.Dispose();
this.Dispose();
return default;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public async ValueTask DisposeAsync()

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

this.Dispose();
}

[Fact]
Expand Down
2 changes: 2 additions & 0 deletions test/Nerdbank.Streams.Tests/MultiplexingStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public async ValueTask DisposeAsync()

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

this.Dispose();
}

[Fact, Obsolete]
Expand Down
6 changes: 5 additions & 1 deletion test/Nerdbank.Streams.Tests/NestedPipeReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ public NestedPipeReaderTests(ITestOutputHelper logger)
{
}

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

public async ValueTask InitializeAsync()
{
Expand Down
1 change: 1 addition & 0 deletions test/Nerdbank.Streams.Tests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected TestBase(ITestOutputHelper logger)

public void Dispose()
{
this.timeoutLoggerRegistration.Dispose();
this.Dispose(true);
GC.SuppressFinalize(this);
}
Expand Down

0 comments on commit a7ae48e

Please sign in to comment.