[PR #1121] More async for ZipReader and ZipWriter #1551

Closed
opened 2026-01-29 22:21:06 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/1121

State: closed
Merged: Yes


This pull request introduces comprehensive support for asynchronous operations in the archive handling codebase, making it possible to open, read, and extract archives using async/await patterns. It adds new async APIs, refactors existing classes to support asynchronous enumeration and disposal, and updates package references to include analyzers that help enforce best practices for threading and async code.

Async API Extensions and Core Refactoring:

  • Added async versions of archive opening methods (OpenAsync) in ArchiveFactory, supporting various input types (streams, file paths, file collections) and implemented corresponding async factory resolution logic. [1] [2] [3] [4] [5] [6] [7]
  • Refactored AbstractArchive to implement IAsyncArchive, introducing async enumeration of entries and volumes, async disposal, and async extraction methods. Also added support for async reader creation and solid extraction. [1] [2] [3] [4] [5] [6]
  • Updated AbstractWritableArchive to use ValueTask for its async save methods, improving performance and consistency with new async patterns. [1] [2]

Dependency and Analyzer Updates:

  • Added Microsoft.VisualStudio.Threading.Analyzers and updated package references to use GlobalPackageReference for threading and async best practices enforcement. Updated lock files accordingly. [1] [2]
  • Set new analyzer severities (VSTHRD110, VSTHRD107) to error in .editorconfig to enforce correct threading usage.

Miscellaneous Improvements:

  • Changed AutoArchiveFactory to internal and added async methods for opening archives and checking archive types, delegating to the new async APIs in ArchiveFactory. [1] [2]
**Original Pull Request:** https://github.com/adamhathcock/sharpcompress/pull/1121 **State:** closed **Merged:** Yes --- This pull request introduces comprehensive support for asynchronous operations in the archive handling codebase, making it possible to open, read, and extract archives using async/await patterns. It adds new async APIs, refactors existing classes to support asynchronous enumeration and disposal, and updates package references to include analyzers that help enforce best practices for threading and async code. **Async API Extensions and Core Refactoring:** * Added async versions of archive opening methods (`OpenAsync`) in `ArchiveFactory`, supporting various input types (streams, file paths, file collections) and implemented corresponding async factory resolution logic. [[1]](diffhunk://#diff-22b8bc5a3d713f2404d058a5fddfba4cec7f175d67a00be88fe4f96da36f7d18R29-R50) [[2]](diffhunk://#diff-22b8bc5a3d713f2404d058a5fddfba4cec7f175d67a00be88fe4f96da36f7d18R76-R91) [[3]](diffhunk://#diff-22b8bc5a3d713f2404d058a5fddfba4cec7f175d67a00be88fe4f96da36f7d18R104-R122) [[4]](diffhunk://#diff-22b8bc5a3d713f2404d058a5fddfba4cec7f175d67a00be88fe4f96da36f7d18R149-R182) [[5]](diffhunk://#diff-22b8bc5a3d713f2404d058a5fddfba4cec7f175d67a00be88fe4f96da36f7d18R209-R243) [[6]](diffhunk://#diff-22b8bc5a3d713f2404d058a5fddfba4cec7f175d67a00be88fe4f96da36f7d18R297-R342) [[7]](diffhunk://#diff-14afa030115e58257f705ec89e4ff1f3f81c9faa64fc5c1ae6f4ec1671f6c0f6R25-R50) * Refactored `AbstractArchive` to implement `IAsyncArchive`, introducing async enumeration of entries and volumes, async disposal, and async extraction methods. Also added support for async reader creation and solid extraction. [[1]](diffhunk://#diff-628683fbef185403c5464b90bb2562672e3d38873b30b0d66c1fc7a435332426L1-R10) [[2]](diffhunk://#diff-628683fbef185403c5464b90bb2562672e3d38873b30b0d66c1fc7a435332426R28-R33) [[3]](diffhunk://#diff-628683fbef185403c5464b90bb2562672e3d38873b30b0d66c1fc7a435332426R42-L49) [[4]](diffhunk://#diff-628683fbef185403c5464b90bb2562672e3d38873b30b0d66c1fc7a435332426R77-R89) [[5]](diffhunk://#diff-628683fbef185403c5464b90bb2562672e3d38873b30b0d66c1fc7a435332426R136) [[6]](diffhunk://#diff-628683fbef185403c5464b90bb2562672e3d38873b30b0d66c1fc7a435332426R159-R221) * Updated `AbstractWritableArchive` to use `ValueTask` for its async save methods, improving performance and consistency with new async patterns. [[1]](diffhunk://#diff-d9ed0f511148da76d233d734091d18177d526bcb026ed5463061cde0c6d00c7cL165-R165) [[2]](diffhunk://#diff-d9ed0f511148da76d233d734091d18177d526bcb026ed5463061cde0c6d00c7cL211-R211) **Dependency and Analyzer Updates:** * Added `Microsoft.VisualStudio.Threading.Analyzers` and updated package references to use `GlobalPackageReference` for threading and async best practices enforcement. Updated lock files accordingly. [[1]](diffhunk://#diff-5baf5f9e448ad54ab25a091adee0da05d4d228481c9200518fcb1b53a65d4156L16-R21) [[2]](diffhunk://#diff-d4f5e1663f2dbe2f891a4b071854faf7059d2c898fb4372b75eb98e4be04945bR17-R61) * Set new analyzer severities (`VSTHRD110`, `VSTHRD107`) to error in `.editorconfig` to enforce correct threading usage. **Miscellaneous Improvements:** * Changed `AutoArchiveFactory` to `internal` and added async methods for opening archives and checking archive types, delegating to the new async APIs in `ArchiveFactory`. [[1]](diffhunk://#diff-14afa030115e58257f705ec89e4ff1f3f81c9faa64fc5c1ae6f4ec1671f6c0f6R4-R11) [[2]](diffhunk://#diff-14afa030115e58257f705ec89e4ff1f3f81c9faa64fc5c1ae6f4ec1671f6c0f6R25-R50)
claunia added the pull-request label 2026-01-29 22:21:06 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1551