Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ZLib, Brotli compression options #105430

Merged
merged 11 commits into from
Jul 29, 2024
Merged

Conversation

buyaa-n
Copy link
Contributor

@buyaa-n buyaa-n commented Jul 24, 2024

Approved API shape:

namespace System.IO.Compression
{
    public enum ZLibCompressionStrategy
    {
        Default = 0,
        Filtered = 1,
        HuffmanOnly = 2,
        RunLengthEncoding = 3,
        Fixed = 4,
    }
    public sealed class ZLibCompressionOptions
    {
        public int CompressionLevel { get; set; }
        public ZLibCompressionStrategy CompressionStrategy { get; set; }
    }
    public sealed class ZLibStream : Stream
    {
        // CompressionMode.Compress
        public ZLibStream(Stream stream, ZLibCompressionOptions compressionOptions, bool leaveOpen = false);
    }
    public partial class DeflateStream : Stream
    {
        public DeflateStream(Stream stream, ZLibCompressionOptions compressionOptions, bool leaveOpen = false);
    }
    public partial class GZipStream : Stream
    {
        public GZipStream(Stream stream, ZLibCompressionOptions compressionOptions, bool leaveOpen = false);
    }


    public sealed class BrotliCompressionOptions
    {
        public int Quality { get; set; }
    }
    public sealed partial class BrotliStream : System.IO.Stream
    {
        public BrotliStream(Stream stream, BrotliCompressionOptions compressionOptions, bool leaveOpen = false) { }
    }
}

Fixes #42820

Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

{
Debug.Assert(windowBits >= minWindowBits && windowBits <= maxWindowBits);

int memLevel = options.CompressionLevel == 0 ? ZLibNative.Deflate_NoCompressionMemLevel : ZLibNative.Deflate_DefaultMemLevel;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has anyone requested being able to configure the memory level? I assume this is something we would consider adding as another property on the options in the future if it was needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real request, yes it can be added when needed

@buyaa-n buyaa-n added this to the 9.0.0 milestone Jul 26, 2024
Copy link
Member

@carlossanlop carlossanlop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. I left a few comments for you to consider.

Co-authored-by: Carlos Sánchez López <[email protected]>
…ZLibCompressionOptions.cs

Co-authored-by: Carlos Sánchez López <[email protected]>
@buyaa-n buyaa-n merged commit 4c58b5a into dotnet:main Jul 29, 2024
84 checks passed
@buyaa-n buyaa-n deleted the compression-options branch July 29, 2024 20:03
@Mrgaton
Copy link

Mrgaton commented Jul 29, 2024

what about dictionary size

@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Standardize pattern for exposing advanced configuration for compression streams
4 participants