-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Steps to reproduce
- Create a project targeting .net 6 or higher
- use ZipOutputStream with "await using"
- Or call directly .DisposeAsync() on previously created ZipOutputStream
Expected behavior
When Disposing, or calling .DisposeAsync(), it uses DeflaterOutputStream.DisposeAsync()
Actual behavior
When Disposing, it uses the base class Stream.DisposeAsync() instead of DeflaterOutputStream.DisposeAsync() method.
This is caused by a compilation directive #if NETSTANDARD2_1 that does not take in consideration recent .net versions (.Net 6 and 7, and probably 5, I have not tested this version)

Version of SharpZipLib
- Compiled from source (latest commit on master)
full sample to reproduce (must create a .net 6 project) :
using ICSharpCode.SharpZipLib.Zip;
using System.Text;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", async (HttpContext context) =>
{
await using (var outputStream = new MemoryStream())
{
await using (var stream = new ZipOutputStream(outputStream))
{
//add file without compression
await stream.PutNextEntryAsync(new ZipEntry("test.txt") { CompressionMethod = CompressionMethod.Stored });
var bytes = Encoding.UTF8.GetBytes("ah ah !");
await stream.WriteAsync(bytes);
await stream.FinishAsync(CancellationToken.None);
outputStream.Position = 0;
await outputStream.CopyToAsync(context.Response.Body);
}
}
});
app.Run();Metadata
Metadata
Assignees
Labels
No labels