Add ZstandardDecompressionOptions for symmetric decoder configuration#129768
Conversation
|
Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression |
Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Co-authored-by: Radek Zikmund <32671551+rzikm@users.noreply.github.com>
There was a problem hiding this comment.
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
ZstandardDecompressionOptionstype (dictionary +MaxWindowLog) and wire it intoZstandardDecoderandZstandardStreamvia 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). |
|
@copilot address code review comments |
…p test Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Addressed all code review comments in commit
|
Co-authored-by: Radek Zikmund <32671551+rzikm@users.noreply.github.com>
|
@copilot address the code review comments |
Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
I think it's fine to not have them for absolutely all cases |
Closes #128456
ZstandardDecoder/ZstandardStreamhad no options-based constructor analogous toZstandardCompressionOptions, 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 withMaxWindowLog(int, validated) andDictionary(ZstandardDictionary?) properties, mirroring the compression counterpartZstandardDecoder(ZstandardDecompressionOptions)— new constructor applying window log and dictionary from optionsZstandardStream(Stream, ZstandardDecompressionOptions, bool leaveOpen = false)— stream creates and owns the decoder (disposed on stream dispose, unlike theZstandardDecoder-accepting overload which resets but does not dispose)Testing
ZstandardDecompressionOptionsTests: property range validation, null/default values