Skip to content

Add ZstandardDecompressionOptions for symmetric decoder configuration#129768

Merged
rzikm merged 6 commits into
mainfrom
copilot/api-proposal-zstandarddecompressionoptions
Jun 25, 2026
Merged

Add ZstandardDecompressionOptions for symmetric decoder configuration#129768
rzikm merged 6 commits into
mainfrom
copilot/api-proposal-zstandarddecompressionoptions

Conversation

Copilot AI commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Closes #128456

ZstandardDecoder/ZstandardStream had no options-based constructor analogous to ZstandardCompressionOptions, making it impossible for callers (e.g. ASP.NET Core middleware) to cleanly configure and tie decoder lifetime to the stream.

Changes

  • ZstandardDecompressionOptions — new sealed class with MaxWindowLog (int, validated) and Dictionary (ZstandardDictionary?) properties, mirroring the compression counterpart
  • ZstandardDecoder(ZstandardDecompressionOptions) — new constructor applying window log and dictionary from options
  • ZstandardStream(Stream, ZstandardDecompressionOptions, bool leaveOpen = false) — stream creates and owns the decoder (disposed on stream dispose, unlike the ZstandardDecoder-accepting overload which resets but does not dispose)
  • Platform-not-supported stubs for browser/wasi, reference assembly updated
// Stream now owns decoder lifetime — no manual disposal needed
return new ZstandardStream(stream, new ZstandardDecompressionOptions
{
    Dictionary = _dictionary,
    MaxWindowLog = 24,
}, leaveOpen: true);

Testing

  • 351 Zstandard tests pass (0 failures)
  • New ZstandardDecompressionOptionsTests: property range validation, null/default values
  • New decoder constructor tests: null arg, default, window log, dictionary round-trip
  • New stream constructor tests: null check, basic decompression, ownership/disposal, dictionary round-trip

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot June 23, 2026 21:08
Copilot AI changed the title [WIP] Add ZstandardDecompressionOptions for better configuration Add ZstandardDecompressionOptions for symmetric decoder configuration Jun 23, 2026
Copilot finished work on behalf of rzikm June 23, 2026 21:09
Copilot AI requested a review from rzikm June 23, 2026 21:09
Co-authored-by: Radek Zikmund <32671551+rzikm@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 24, 2026 07:27
@rzikm rzikm marked this pull request as ready for review June 24, 2026 07:27
@rzikm rzikm requested a review from a team June 24, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR expands the System.IO.Compression Zstandard surface area by introducing decompression options and new overloads so callers can configure decoding (dictionary + max window log) via an options object, including a new ZstandardStream decompression constructor.

Changes:

  • Add new public ZstandardDecompressionOptions type (dictionary + MaxWindowLog) and wire it into ZstandardDecoder and ZstandardStream via new overloads.
  • Update browser/wasi platform-not-supported stubs and the reference assembly to include the new public APIs.
  • Add unit tests covering options validation and basic options-based decoding/stream usage.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/ZstandardDecompressionOptions.cs New public options type for configuring Zstandard decompression.
src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/ZstandardDecoder.cs New ZstandardDecoder(ZstandardDecompressionOptions) constructor that applies options.
src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/ZstandardStream.Decompress.cs New ZstandardStream(Stream, ZstandardDecompressionOptions, bool) decompression constructor creating a decoder from options.
src/libraries/System.IO.Compression/src/System/IO/Compression/Zstandard/Zstandard.PlatformNotSupported.cs Add stubs for the new options type and new overloads on browser/wasi.
src/libraries/System.IO.Compression/src/System.IO.Compression.csproj Include the new source file in the Zstandard compilation item group.
src/libraries/System.IO.Compression/ref/System.IO.Compression.cs Update ref surface area to include the new public type and overloads.
src/libraries/System.IO.Compression/tests/Zstandard/ZstandardEncoderDecoderTests.cs Add tests for the new decoder options constructor (null/default/windowlog/dictionary).
src/libraries/System.IO.Compression/tests/Zstandard/ZstandardCompressionOptionsTests.cs Add tests for ZstandardDecompressionOptions property validation and defaults.
src/libraries/System.IO.Compression/tests/Zstandard/CompressionStreamUnitTests.Zstandard.cs Add tests for the new options-based stream constructor (basic usage + null + dictionary round-trip).

Comment thread src/libraries/System.IO.Compression/ref/System.IO.Compression.cs
Comment thread src/libraries/System.IO.Compression/ref/System.IO.Compression.cs
@rzikm

rzikm commented Jun 24, 2026

Copy link
Copy Markdown
Member

@copilot address code review comments

…p test

Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>

Copilot AI commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address code review comments

Addressed all code review comments in commit 6bef7c9:

  • OverloadResolutionPriority(-1): Added [OverloadResolutionPriority(-1)] to ZstandardDecoder(ZstandardDecompressionOptions) in the implementation, platform-not-supported stubs, and ref assembly to prevent new ZstandardDecoder(null) ambiguity.
  • Ownership/disposal test: Added ZstandardStream_WithDecompressionOptions_DisposedStream_ThrowsObjectDisposedException verifying that reads after disposal throw ObjectDisposedException.
  • Redundant zero test (ZstandardCompressionOptionsTests.cs:83): Removed the separate MaxWindowLog_SetToZero_Succeeds fact and folded 0 as an [InlineData] into MaxWindowLog_SetToValidRange_Succeeds.
  • Below-minimum test coverage (ZstandardCompressionOptionsTests.cs:104): Added [InlineData(1)] (well below minimum of 10) alongside the existing boundary values.
  • Duplicate decoder test (ZstandardEncoderDecoderTests.cs:603): Merged Default_Succeeds and WithMaxWindowLog_Succeeds into a single [Theory] with [InlineData(0)] and [InlineData(10)].

Comment thread src/libraries/System.IO.Compression/ref/System.IO.Compression.cs Outdated
Co-authored-by: Radek Zikmund <32671551+rzikm@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

@rzikm

rzikm commented Jun 24, 2026

Copy link
Copy Markdown
Member

@copilot address the code review comments

Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Copilot finished work on behalf of rzikm June 24, 2026 15:50
Copilot AI requested a review from rzikm June 24, 2026 15:50

@alinpahontu2912 alinpahontu2912 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks fine to me, but there is no test with leaveopen:false, would we need that too?

@rzikm

rzikm commented Jun 25, 2026

Copy link
Copy Markdown
Member

would we need that too?

I think it's fine to not have them for absolutely all cases

@rzikm rzikm merged commit f156f4e into main Jun 25, 2026
85 of 88 checks passed
@rzikm rzikm deleted the copilot/api-proposal-zstandarddecompressionoptions branch June 25, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: ZstandardDecompressionOptions

6 participants