Skip to content

More async for ZipReader and ZipWriter#1121

Merged
adamhathcock merged 56 commits intomasterfrom
adam/async
Jan 12, 2026
Merged

More async for ZipReader and ZipWriter#1121
adamhathcock merged 56 commits intomasterfrom
adam/async

Conversation

@adamhathcock
Copy link
Owner

@adamhathcock adamhathcock commented Jan 7, 2026

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]

adamhathcock and others added 26 commits November 25, 2025 14:44
- Added IsArchiveAsync interface method to IFactory
- Implemented async versions of IsZipFile, IsZipMulti, IsGZipFile
- Updated ZipFactory and GZipFactory to override IsArchiveAsync
- Updated ReaderFactory.OpenAsync to use IsArchiveAsync
- Fixed Zip_Reader_Disposal_Test2_Async to use ReaderFactory.OpenAsync
- Fixed TestStream to properly forward ReadAsync calls
- Removed BufferedStream wrapping from AsyncBinaryReader as it uses sync Read
- Added default implementation in Factory base class

Co-authored-by: adamhathcock <[email protected]>
…plementations

Consolidate stream extension methods and simplify with framework methods
# Conflicts:
#	src/SharpCompress/Utility.cs
Copilot AI review requested due to automatic review settings January 7, 2026 16:22
@adamhathcock adamhathcock review requested due to automatic review settings January 7, 2026 16:23
@adamhathcock adamhathcock marked this pull request as draft January 7, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants