Add Reset() to the Zlib-based Encoders/Decoders#131307
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression |
There was a problem hiding this comment.
Pull request overview
Adds Reset() support to the zlib-based streamless encoders/decoders in System.IO.Compression so instances can be reused for independent compression/decompression operations, backed by a new native deflateReset export and expanded test coverage.
Changes:
- Add native
CompressionNative_DeflateResetexport and managedLibraryImportwrapper plumbing. - Add public
Reset()APIs toDeflate*,ZLib*, andGZip*encoder/decoder types and route them to zlib reset functionality. - Enable and extend shared encoder/decoder tests to validate reset semantics (no-op on fresh instance, reset after partial work).
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/libs/System.IO.Compression.Native/System.IO.Compression.Native.def | Exports the new native CompressionNative_DeflateReset symbol on Windows. |
| src/native/libs/System.IO.Compression.Native/System.IO.Compression.Native_unixexports.src | Exports the new native CompressionNative_DeflateReset symbol on Unix. |
| src/native/libs/System.IO.Compression.Native/pal_zlib.h | Declares the PAL entrypoint for CompressionNative_DeflateReset (with documentation). |
| src/native/libs/System.IO.Compression.Native/pal_zlib.c | Implements CompressionNative_DeflateReset via deflateReset. |
| src/native/libs/System.IO.Compression.Native/entrypoints.c | Adds CompressionNative_DeflateReset to the resolver table for LibraryImport. |
| src/libraries/Common/src/Interop/Interop.zlib.cs | Adds LibraryImport for CompressionNative_DeflateReset. |
| src/libraries/Common/src/System/IO/Compression/ZLibNative.cs | Adds ZLibStreamHandle.DeflateReset() wrapper on the SafeHandle. |
| src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateEncoder.cs | Adds public Reset() that calls into DeflateReset and clears managed finished state. |
| src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateDecoder.cs | Adds public Reset() that calls InflateReset2_ and clears managed finished state. |
| src/libraries/System.IO.Compression/src/System/IO/Compression/ZLibEncoder.cs | Adds public Reset() delegating to the underlying DeflateEncoder. |
| src/libraries/System.IO.Compression/src/System/IO/Compression/ZLibDecoder.cs | Adds public Reset() delegating to the underlying DeflateDecoder. |
| src/libraries/System.IO.Compression/src/System/IO/Compression/GZipEncoder.cs | Adds public Reset() delegating to the underlying DeflateEncoder. |
| src/libraries/System.IO.Compression/src/System/IO/Compression/GZipDecoder.cs | Adds public Reset() delegating to the underlying DeflateDecoder. |
| src/libraries/System.IO.Compression/ref/System.IO.Compression.cs | Adds the new public Reset() members to the public surface area. |
| src/libraries/Common/tests/System/IO/Compression/EncoderDecoderTestBase.cs | Adds reset-focused tests to the shared encoder/decoder test base. |
| src/libraries/System.IO.Compression/tests/ZLibEncoderDecoderTestBase.cs | Enables reset tests for zlib-based test suites (SupportsReset => true). |
| src/libraries/System.IO.Compression/tests/DeflateEncoderDecoderTests.cs | Updates adapters to forward Reset() to DeflateEncoder/DeflateDecoder. |
| src/libraries/System.IO.Compression/tests/GZipEncoderDecoderTests.cs | Updates adapters to forward Reset() to GZipEncoder/GZipDecoder. |
| src/libraries/System.IO.Compression/tests/ZLibEncoderDecoderTests.cs | Updates adapters to forward Reset() to ZLibEncoder/ZLibDecoder. |
| public sealed partial class DeflateDecoder : System.IDisposable | ||
| { | ||
| public DeflateDecoder() { } | ||
| public System.Buffers.OperationStatus Decompress(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesConsumed, out int bytesWritten) { throw null; } | ||
| public void Dispose() { } | ||
| public void Reset() { } | ||
| public static bool TryDecompress(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesWritten) { throw null; } |
…net-runtime into 129090-decoder-reset
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/libraries/System.IO.Compression/ref/System.IO.Compression.cs:27
- This PR adds new public API surface (e.g.,
DeflateDecoder.Reset()and similarReset()methods on other encoders/decoders), but the linked issue (#130465) is only labeledapi-ready-for-reviewand does not have the requiredapi-approvedlabel. Per the API approval process, new public APIs should not be implemented/merged until an approved API shape is available and linked.
Please complete API review/approval (issue gets api-approved and an approved API shape comment), then verify the ref/ changes match that approved shape; or, if approval is pending, keep these APIs out of ref/ (and out of public surface) until approval is granted.
public sealed partial class DeflateDecoder : System.IDisposable
{
public DeflateDecoder() { }
public System.Buffers.OperationStatus Decompress(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesConsumed, out int bytesWritten) { throw null; }
public void Dispose() { }
public void Reset() { }
public static bool TryDecompress(System.ReadOnlySpan<byte> source, System.Span<byte> destination, out int bytesWritten) { throw null; }
Implements #130465