From 0a3c36dc804a0814ef0681f6bc8acb32e593c0af Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 08:04:39 +0000 Subject: [PATCH] Dispose caller-provided stream in async archive open test --- .../AsyncParityAndCancellationTests.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/SharpCompress.Test/AsyncParityAndCancellationTests.cs b/tests/SharpCompress.Test/AsyncParityAndCancellationTests.cs index c19edf7c..49beacfa 100644 --- a/tests/SharpCompress.Test/AsyncParityAndCancellationTests.cs +++ b/tests/SharpCompress.Test/AsyncParityAndCancellationTests.cs @@ -125,15 +125,22 @@ public class AsyncParityAndCancellationTests : TestBase ); var stream = new TestStream(new MemoryStream(archiveBytes)); - await using (var archive = await ArchiveFactory.OpenAsyncArchive(stream)) + try { - await foreach (var _ in archive.EntriesAsync) + await using (var archive = await ArchiveFactory.OpenAsyncArchive(stream)) { - break; + await foreach (var _ in archive.EntriesAsync) + { + break; + } } - } - Assert.False(stream.IsDisposed); + Assert.False(stream.IsDisposed); + } + finally + { + await stream.DisposeAsync(); + } } private static List ReadArchiveEntries(string archivePath)