Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Why are Deflate Compression Levels ignored? #6923

@turbo

Description

@turbo

This is related to overloads for classes which rely on DeflateStream and expose a CompressionLevel setting (here's a list for reference). Case in point: #1437.

I've been working on a project and kept wondering why GZipStream in particular would compress anything with the CompressionLevel set to None. A trip down to deflate revealed that it's just ignored:

// snip
public DeflateStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen)
  : this(stream, compressionLevel, leaveOpen, false)
{
}

// snip

internal DeflateStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen, bool gzip)
  : this(stream, CompressionMode.Compress, leaveOpen, gzip)
{
  // ... what? 
}

Is there ... a technical reason for this? IMO the overload is really misleading. Compared to the MS API, this is a "breaking" change, is this documented somewhere?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions