fixes for release

This commit is contained in:
Adam Hathcock
2026-10-19 10:52:07 +01:00
parent 2fe5f3a4e8
commit 2168385f2e
3 changed files with 13 additions and 4 deletions

View File

@@ -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<SharpCompressException>(() =>
@@ -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<SharpCompressException>(() =>
stream.CopyToAsync(Stream.Null, 81920, CancellationToken.None)
);

View File

@@ -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<byte>.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<byte>.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<byte>.Create());
window.Create(int.MaxValue);
using var preset = new MemoryStream(new byte[] { 1, 2, 3 });
if (useAsync)

View File

@@ -37,7 +37,7 @@ public class ShrinkAllocationTests
[Fact]
public void Shrink_Grows_Only_For_Actual_Output()
{
var pool = ArrayPool<byte>.Shared;
var pool = ArrayPool<byte>.Create();
var status = HwUnshrink.UnshrinkGrowing(
new byte[] { 65, 132, 0 },
3,