[PR #1132] [MERGED] Clean up for async creation #1562

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

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/1132
Author: @adamhathcock
Created: 1/15/2026
Status: Merged
Merged: 1/27/2026
Merged by: @adamhathcock

Base: masterHead: adam/async-creation


📝 Commits (10+)

  • a410f73 archive asyncs are more right
  • 2d597e6 be more lazy with loading of sync stuff
  • 33b6447 Merge remote-tracking branch 'origin/master' into adam/async-creation
  • 63736ef Merge remote-tracking branch 'origin/master' into adam/async-creation
  • 810df8a revert lazy archive
  • 5c06b8c enable single test
  • 0b2158f Initial plan
  • bbba2e6 Initial plan for fixing SevenZipArchive_LZMA_AsyncStreamExtraction test
  • 9bb670a Fix SevenZipArchive async stream handling by adding async Open and ReadDatabase methods
  • 491beab uncomment tests

📊 Changes

339 files changed (+17782 additions, -6732 deletions)

View changed files

📝 AGENTS.md (+55 -0)
📝 Directory.Packages.props (+1 -1)
src/SharpCompress/Archives/AbstractArchive.Async.cs (+103 -0)
📝 src/SharpCompress/Archives/AbstractArchive.cs (+5 -92)
src/SharpCompress/Archives/AbstractWritableArchive.Async.cs (+123 -0)
📝 src/SharpCompress/Archives/AbstractWritableArchive.cs (+23 -17)
src/SharpCompress/Archives/ArchiveFactory.Async.cs (+158 -0)
📝 src/SharpCompress/Archives/ArchiveFactory.cs (+10 -135)
📝 src/SharpCompress/Archives/ArchiveVolumeFactory.cs (+5 -0)
src/SharpCompress/Archives/AutoArchiveFactory.cs (+0 -52)
src/SharpCompress/Archives/GZip/GZipArchive.Async.cs (+86 -0)
📝 src/SharpCompress/Archives/GZip/GZipArchive.Factory.cs (+13 -9)
📝 src/SharpCompress/Archives/GZip/GZipArchive.cs (+0 -53)
📝 src/SharpCompress/Archives/IArchiveFactory.cs (+1 -5)
📝 src/SharpCompress/Archives/IAsyncArchiveExtensions.cs (+2 -2)
📝 src/SharpCompress/Archives/IWritableArchive.cs (+34 -8)
src/SharpCompress/Archives/IWritableArchiveCommonExtensions.cs (+0 -59)
📝 src/SharpCompress/Archives/IWritableArchiveExtensions.cs (+50 -0)
📝 src/SharpCompress/Archives/IWritableAsyncArchiveExtensions.cs (+50 -0)
📝 src/SharpCompress/Archives/Rar/FileInfoRarArchiveVolume.cs (+3 -0)

...and 80 more files

📄 Description

For some formats, async should be all the way. 7Zip needs fixing

This pull request introduces asynchronous detection methods for multiple archive and compression formats, allowing non-blocking checks to determine file types. It also refactors and simplifies some synchronous detection logic for improved performance and consistency. The most significant changes are grouped below:

Asynchronous Format Detection:

  • Added IsArchiveAsync or similar async methods for ACE (AceHeader.cs), ARJ (ArjHeader.cs), BZip2 (BZip2Stream.cs), LZip (LZipStream.cs), LZW (LzwStream.cs), ZStandard (ZStandardStream.cs), RAR (RarArchive.Factory.cs), SevenZip (SevenZipArchive.Factory.cs), TAR (TarArchive.Factory.cs), and XZ (XZStream.cs) formats, enabling asynchronous file type checks with CancellationToken support. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

  • Updated the ACE and ARJ factories to implement and expose these new asynchronous detection methods. [1] [2]

Synchronous Detection Refactoring & Performance:

  • Refactored synchronous detection logic to use pooled buffers (via ArrayPool<byte>.Shared) for ARC and SevenZip formats, reducing allocations and improving performance. [1] [2]

API Consistency and Interface Changes:

  • Removed the CancellationToken parameter from the IArchiveFactory.OpenAsyncArchive method and its implementations to simplify the API, as the token was not being used in actual asynchronous operations. [1] [2] [3]

General Codebase Improvements:

  • Added missing using directives for System.Threading and System.Threading.Tasks where needed to support the new asynchronous methods. [1] [2] [3] [4] [5] [6] [7]

These changes collectively modernize the archive/compression format detection APIs and improve their efficiency and usability.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/adamhathcock/sharpcompress/pull/1132 **Author:** [@adamhathcock](https://github.com/adamhathcock) **Created:** 1/15/2026 **Status:** ✅ Merged **Merged:** 1/27/2026 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `adam/async-creation` --- ### 📝 Commits (10+) - [`a410f73`](https://github.com/adamhathcock/sharpcompress/commit/a410f73bf3e44f406a46f8e5c0523783c526b4b6) archive asyncs are more right - [`2d597e6`](https://github.com/adamhathcock/sharpcompress/commit/2d597e6e43cbb315e8d6dba66b9fb208547db309) be more lazy with loading of sync stuff - [`33b6447`](https://github.com/adamhathcock/sharpcompress/commit/33b6447c1884b60d3b96957b2ca7c1b55cbbb81a) Merge remote-tracking branch 'origin/master' into adam/async-creation - [`63736ef`](https://github.com/adamhathcock/sharpcompress/commit/63736efcacef3b6da784439fd1731ff93affd86d) Merge remote-tracking branch 'origin/master' into adam/async-creation - [`810df8a`](https://github.com/adamhathcock/sharpcompress/commit/810df8a18b2080635a05bde81f6c3d3d7800847b) revert lazy archive - [`5c06b8c`](https://github.com/adamhathcock/sharpcompress/commit/5c06b8c48f6e11ad27eff906faf29af52160ffe2) enable single test - [`0b2158f`](https://github.com/adamhathcock/sharpcompress/commit/0b2158f74caaaadbd1a4914f6353730ad1ed4959) Initial plan - [`bbba2e6`](https://github.com/adamhathcock/sharpcompress/commit/bbba2e6c7ab3b96e286dcdcef2dacd5714a0023e) Initial plan for fixing SevenZipArchive_LZMA_AsyncStreamExtraction test - [`9bb670a`](https://github.com/adamhathcock/sharpcompress/commit/9bb670ad196acde024935e0f9fa4ec86075b5d6e) Fix SevenZipArchive async stream handling by adding async Open and ReadDatabase methods - [`491beab`](https://github.com/adamhathcock/sharpcompress/commit/491beabe032222ee3eb8559ae6b9a0bf819b4d2c) uncomment tests ### 📊 Changes **339 files changed** (+17782 additions, -6732 deletions) <details> <summary>View changed files</summary> 📝 `AGENTS.md` (+55 -0) 📝 `Directory.Packages.props` (+1 -1) ➕ `src/SharpCompress/Archives/AbstractArchive.Async.cs` (+103 -0) 📝 `src/SharpCompress/Archives/AbstractArchive.cs` (+5 -92) ➕ `src/SharpCompress/Archives/AbstractWritableArchive.Async.cs` (+123 -0) 📝 `src/SharpCompress/Archives/AbstractWritableArchive.cs` (+23 -17) ➕ `src/SharpCompress/Archives/ArchiveFactory.Async.cs` (+158 -0) 📝 `src/SharpCompress/Archives/ArchiveFactory.cs` (+10 -135) 📝 `src/SharpCompress/Archives/ArchiveVolumeFactory.cs` (+5 -0) ➖ `src/SharpCompress/Archives/AutoArchiveFactory.cs` (+0 -52) ➕ `src/SharpCompress/Archives/GZip/GZipArchive.Async.cs` (+86 -0) 📝 `src/SharpCompress/Archives/GZip/GZipArchive.Factory.cs` (+13 -9) 📝 `src/SharpCompress/Archives/GZip/GZipArchive.cs` (+0 -53) 📝 `src/SharpCompress/Archives/IArchiveFactory.cs` (+1 -5) 📝 `src/SharpCompress/Archives/IAsyncArchiveExtensions.cs` (+2 -2) 📝 `src/SharpCompress/Archives/IWritableArchive.cs` (+34 -8) ➖ `src/SharpCompress/Archives/IWritableArchiveCommonExtensions.cs` (+0 -59) 📝 `src/SharpCompress/Archives/IWritableArchiveExtensions.cs` (+50 -0) 📝 `src/SharpCompress/Archives/IWritableAsyncArchiveExtensions.cs` (+50 -0) 📝 `src/SharpCompress/Archives/Rar/FileInfoRarArchiveVolume.cs` (+3 -0) _...and 80 more files_ </details> ### 📄 Description For some formats, async should be all the way. 7Zip needs fixing This pull request introduces asynchronous detection methods for multiple archive and compression formats, allowing non-blocking checks to determine file types. It also refactors and simplifies some synchronous detection logic for improved performance and consistency. The most significant changes are grouped below: **Asynchronous Format Detection:** * Added `IsArchiveAsync` or similar async methods for ACE (`AceHeader.cs`), ARJ (`ArjHeader.cs`), BZip2 (`BZip2Stream.cs`), LZip (`LZipStream.cs`), LZW (`LzwStream.cs`), ZStandard (`ZStandardStream.cs`), RAR (`RarArchive.Factory.cs`), SevenZip (`SevenZipArchive.Factory.cs`), TAR (`TarArchive.Factory.cs`), and XZ (`XZStream.cs`) formats, enabling asynchronous file type checks with `CancellationToken` support. [[1]](diffhunk://#diff-33cc7b6697bb02c3e838edce251357c47d0e9e74e66e026ddcf3bd33377843f0R110-R129) [[2]](diffhunk://#diff-6f8a0d963a0c12fc7d1746934ec553bc4f163d1e7204d8276899fb3e1b2e6a5aR153-R172) [[3]](diffhunk://#diff-b4cbaaf64addd2a93675e79bf84d7840214f73a08d6c5638ccfbc0124fbe2ea1R152-R172) [[4]](diffhunk://#diff-44b45464653f8440fd0885412f8b8b22fdc507753278d389bd5b3b6b05a7a32cR225-R237) [[5]](diffhunk://#diff-74d195a64f0d55f0eec9f7b618e60241d5b1aa571c50a89d1b75444f0ca50cb8R100-R138) [[6]](diffhunk://#diff-51cd971e36b7f18e787302b135cacae4f9ebf87194d00f580121466aba16b585R47-R67) [[7]](diffhunk://#diff-c917224df3ff936ef99480cb13f4d79d64db4bac3abba0c377b716a24c209c69R167-R184) [[8]](diffhunk://#diff-3c93be69c25d07fa44b4fe2394bb54f93c4e63e05e387b7bd6d5713048d44d01L160-R208) [[9]](diffhunk://#diff-31112d7dfdc65bd7cca0da2d515de9d2b599c9a3196bc3562031d6e6a59788e3R168-R188) [[10]](diffhunk://#diff-ac3f8a33f27e97f618b5177fa107cdb4e26e43031510a9896223d8f67a83418eR63-R78) * Updated the ACE and ARJ factories to implement and expose these new asynchronous detection methods. [[1]](diffhunk://#diff-ed73ecc9390f716d464db47b9348155cd299e896469da34e16fdfa2ecd1aa47bR32-R38) [[2]](diffhunk://#diff-ed73ecc9390f716d464db47b9348155cd299e896469da34e16fdfa2ecd1aa47bL44-L49) **Synchronous Detection Refactoring & Performance:** * Refactored synchronous detection logic to use pooled buffers (via `ArrayPool<byte>.Shared`) for ARC and SevenZip formats, reducing allocations and improving performance. [[1]](diffhunk://#diff-800f1b0c584eba50b849faa713b1d38c49e98276a9c84787069a948f58d85606L39-R49) [[2]](diffhunk://#diff-3c93be69c25d07fa44b4fe2394bb54f93c4e63e05e387b7bd6d5713048d44d01L160-R208) **API Consistency and Interface Changes:** * Removed the `CancellationToken` parameter from the `IArchiveFactory.OpenAsyncArchive` method and its implementations to simplify the API, as the token was not being used in actual asynchronous operations. [[1]](diffhunk://#diff-4b08b3148476395372bc9e8bba6bebb7a72acfa5050129dc7a663e1006cbcbefL50-R50) [[2]](diffhunk://#diff-14afa030115e58257f705ec89e4ff1f3f81c9faa64fc5c1ae6f4ec1671f6c0f6L43-R44) [[3]](diffhunk://#diff-22b8bc5a3d713f2404d058a5fddfba4cec7f175d67a00be88fe4f96da36f7d18L81-R81) **General Codebase Improvements:** * Added missing `using` directives for `System.Threading` and `System.Threading.Tasks` where needed to support the new asynchronous methods. [[1]](diffhunk://#diff-33cc7b6697bb02c3e838edce251357c47d0e9e74e66e026ddcf3bd33377843f0R3-R4) [[2]](diffhunk://#diff-6f8a0d963a0c12fc7d1746934ec553bc4f163d1e7204d8276899fb3e1b2e6a5aR6) [[3]](diffhunk://#diff-51cd971e36b7f18e787302b135cacae4f9ebf87194d00f580121466aba16b585R6) [[4]](diffhunk://#diff-74d195a64f0d55f0eec9f7b618e60241d5b1aa571c50a89d1b75444f0ca50cb8R3-R4) [[5]](diffhunk://#diff-3c93be69c25d07fa44b4fe2394bb54f93c4e63e05e387b7bd6d5713048d44d01R2-L9) [[6]](diffhunk://#diff-800f1b0c584eba50b849faa713b1d38c49e98276a9c84787069a948f58d85606R2) [[7]](diffhunk://#diff-c917224df3ff936ef99480cb13f4d79d64db4bac3abba0c377b716a24c209c69R6) These changes collectively modernize the archive/compression format detection APIs and improve their efficiency and usability. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 22:21:09 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1562