Skip to content

Comments

Make ZipArchiveEntry.CompressionMethod public#122045

Merged
iremyux merged 7 commits intodotnet:mainfrom
iremyux:95909-public-compressionmethod
Dec 4, 2025
Merged

Make ZipArchiveEntry.CompressionMethod public#122045
iremyux merged 7 commits intodotnet:mainfrom
iremyux:95909-public-compressionmethod

Conversation

@iremyux
Copy link
Contributor

@iremyux iremyux commented Nov 28, 2025

This PR exposes the compression method of ZIP archive entries through a new public ZipCompressionMethod enum and a public CompressionMethod property on ZipArchiveEntry.

  • Only supported compression methods are included.
  • Enum values (0, 8, 9) correspond to the compression method values defined in the ZIP File Format Specification (APPNOTE.TXT section 4.4.5).
  • Error handling for unsupported compression methods now uses a single generic message SR.UnsupportedCompression instead of method-specific messages for BZip2/LZMA.

Fixes #95909

Copy link
Contributor

Copilot AI left a comment

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 exposes the compression method of ZIP archive entries as a public API by introducing a new ZipCompressionMethod enum and a public CompressionMethod property on ZipArchiveEntry. The change replaces the internal CompressionMethodValues enum throughout the codebase and simplifies error handling for unsupported compression methods.

  • Adds public ZipCompressionMethod enum with values for Stored (0), Deflate (8), and Deflate64 (9)
  • Exposes CompressionMethod property on ZipArchiveEntry as a public getter
  • Consolidates error messages for unsupported compression methods to use a single generic message

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipCompressionMethod.cs New public enum defining supported ZIP compression methods (Stored, Deflate, Deflate64) with values matching ZIP specification
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs Replaces internal CompressionMethodValues with public ZipCompressionMethod; makes CompressionMethod property public; removes old internal enum; simplifies error handling
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.Async.cs Updates async methods to use ZipCompressionMethod instead of CompressionMethodValues
src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/DeflateManagedStream.cs Updates constructor parameter and assertions to use ZipCompressionMethod
src/libraries/System.IO.Compression/src/System.IO.Compression.csproj Adds new ZipCompressionMethod.cs file to compilation
src/libraries/System.IO.Compression/ref/System.IO.Compression.cs Adds public API surface for ZipCompressionMethod enum and CompressionMethod property
src/libraries/System.IO.Compression/tests/ZipArchive/zip_ReadTests.cs Updates existing test to use ZipCompressionMethod; adds three new tests for Deflate, Stored, and empty file compression methods

@iremyux iremyux requested a review from a team December 4, 2025 12:34
Copy link
Member

@rzikm rzikm left a comment

Choose a reason for hiding this comment

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

LGTM

@iremyux iremyux enabled auto-merge (squash) December 4, 2025 15:00
@iremyux iremyux merged commit 2d49a33 into dotnet:main Dec 4, 2025
85 of 87 checks passed
@iremyux iremyux deleted the 95909-public-compressionmethod branch December 4, 2025 21:53
@github-actions github-actions bot locked and limited conversation to collaborators Jan 4, 2026
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.

[API Proposal]: Make ZipArchiveEntry.CompressionMethod public

4 participants