From 2168385f2e824c4cb03841e4bca052e70bc1f69a Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 19 Oct 2026 10:52:07 +0100 Subject: [PATCH] fixes for release --- tests/SharpCompress.Test/Streams/Lzma2TruncationTests.cs | 8 ++++++++ .../Streams/LzmaDictionaryAllocationTests.cs | 7 ++++--- tests/SharpCompress.Test/Zip/ShrinkAllocationTests.cs | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/SharpCompress.Test/Streams/Lzma2TruncationTests.cs b/tests/SharpCompress.Test/Streams/Lzma2TruncationTests.cs index 4fa16d41..32dd795c 100644 --- a/tests/SharpCompress.Test/Streams/Lzma2TruncationTests.cs +++ b/tests/SharpCompress.Test/Streams/Lzma2TruncationTests.cs @@ -92,7 +92,11 @@ public class Lzma2TruncationTests data[i] = Convert.ToByte(TruncatedXzHex.Substring(i * 2, 2), 16); } using var input = new MemoryStream(data); +#if LEGACY_DOTNET + using var decoder = new XZStream(input); +#else await using var decoder = new XZStream(input); +#endif if (useAsync) { await Assert.ThrowsAnyAsync(() => @@ -116,7 +120,11 @@ public class Lzma2TruncationTests await using var archive = await ArchiveFactory.OpenAsyncArchive(input); await foreach (var entry in archive.EntriesAsync) { +#if LEGACY_DOTNET + using var stream = await entry.OpenEntryStreamAsync(CancellationToken.None); +#else await using var stream = await entry.OpenEntryStreamAsync(CancellationToken.None); +#endif await Assert.ThrowsAnyAsync(() => stream.CopyToAsync(Stream.Null, 81920, CancellationToken.None) ); diff --git a/tests/SharpCompress.Test/Streams/LzmaDictionaryAllocationTests.cs b/tests/SharpCompress.Test/Streams/LzmaDictionaryAllocationTests.cs index 6e8d536f..fefb6432 100644 --- a/tests/SharpCompress.Test/Streams/LzmaDictionaryAllocationTests.cs +++ b/tests/SharpCompress.Test/Streams/LzmaDictionaryAllocationTests.cs @@ -1,4 +1,5 @@ using System; +using System.Buffers; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -84,7 +85,7 @@ public class LzmaDictionaryAllocationTests bool useAsync ) { - using var window = new OutWindow(); + using var window = new OutWindow(ArrayPool.Create()); window.Create(int.MaxValue); window.SetLimit(int.MaxValue); using var input = new MemoryStream(new byte[] { 1 }); @@ -116,7 +117,7 @@ public class LzmaDictionaryAllocationTests [Fact] public void Lzma_Huge_Dictionary_Starts_Small_And_Grows_With_History() { - using var window = new OutWindow(); + using var window = new OutWindow(ArrayPool.Create()); window.Create(int.MaxValue); Assert.InRange(window.BufferCapacity, 1, 4096); Assert.Equal(0, window.GetByte(0)); @@ -188,7 +189,7 @@ public class LzmaDictionaryAllocationTests [InlineData(true)] public async Task Lzma_Preset_Dictionary_Does_Not_Allocate_Declared_Window(bool useAsync) { - using var window = new OutWindow(); + using var window = new OutWindow(ArrayPool.Create()); window.Create(int.MaxValue); using var preset = new MemoryStream(new byte[] { 1, 2, 3 }); if (useAsync) diff --git a/tests/SharpCompress.Test/Zip/ShrinkAllocationTests.cs b/tests/SharpCompress.Test/Zip/ShrinkAllocationTests.cs index 4fd281de..d196e804 100644 --- a/tests/SharpCompress.Test/Zip/ShrinkAllocationTests.cs +++ b/tests/SharpCompress.Test/Zip/ShrinkAllocationTests.cs @@ -37,7 +37,7 @@ public class ShrinkAllocationTests [Fact] public void Shrink_Grows_Only_For_Actual_Output() { - var pool = ArrayPool.Shared; + var pool = ArrayPool.Create(); var status = HwUnshrink.UnshrinkGrowing( new byte[] { 65, 132, 0 }, 3,