Skip to content

GZip stream returns buffer length of 15 in dotnet 10 #121710

@pkcoremont

Description

@pkcoremont

Describe the bug

The behaviour is different in dotnet8 vs dotnet10

To Reproduce

    static async Task<ReadOnlyMemory<byte>> CompressReadOnlyMemoryToGzip(ReadOnlyMemory<byte> buffer)
    {
        await using var stream = new MemoryStream();
        await using (var gzipStream = new GZipStream(stream, CompressionMode.Compress))
        {
            await gzipStream.WriteAsync(buffer);
            await gzipStream.FlushAsync();
        }
        return stream.ToArray();
    }
    
var buffer = await CompressReadOnlyMemoryToGzip(new ReadOnlyMemory<byte>());

Console.WriteLine(buffer.Length);

Exceptions (if any)

Further technical details

details of dotnet --info

- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version - Rider 2025.3 on Windows

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions