[PR #991] [MERGED] Add more Async tests and complete Zip tests #1410

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

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/991
Author: @adamhathcock
Created: 10/28/2025
Status: Merged
Merged: 10/28/2025
Merged by: @adamhathcock

Base: masterHead: async-reader-methods


📝 Commits (10+)

  • 72d5884 added async reader overloads
  • f6eabc5 Merge remote-tracking branch 'origin/master' into async-reader-methods
  • c68d8de add async tests
  • e287d08 minor clean up
  • 16ad86c add async implementations to readonlysubstream
  • 79653ee Merge remote-tracking branch 'origin/master' into async-reader-methods
  • a1de3eb add async tests and clean up deflate64stream
  • 19967f5 allow forward only write
  • 42f7d43 enable zip64 tests that pass
  • 06713c6 async deflate 64

📊 Changes

14 files changed (+1331 additions, -82 deletions)

View changed files

📝 src/SharpCompress/Common/Zip/StreamingZipHeaderFactory.cs (+2 -3)
📝 src/SharpCompress/Compressors/Deflate64/Deflate64Stream.cs (+110 -73)
📝 src/SharpCompress/IO/ReadOnlySubStream.cs (+43 -0)
📝 src/SharpCompress/Readers/AbstractReader.cs (+75 -0)
📝 src/SharpCompress/Readers/IReader.cs (+14 -0)
📝 src/SharpCompress/packages.lock.json (+3 -3)
📝 tests/SharpCompress.Test/Mocks/ForwardOnlyStream.cs (+35 -2)
📝 tests/SharpCompress.Test/ReaderTests.cs (+1 -1)
tests/SharpCompress.Test/Zip/Zip64AsyncTests.cs (+242 -0)
📝 tests/SharpCompress.Test/Zip/Zip64Tests.cs (+8 -0)
tests/SharpCompress.Test/Zip/ZipArchiveAsyncTests.cs (+196 -0)
tests/SharpCompress.Test/Zip/ZipMemoryArchiveWithCrcAsyncTests.cs (+281 -0)
tests/SharpCompress.Test/Zip/ZipReaderAsyncTests.cs (+254 -0)
tests/SharpCompress.Test/Zip/ZipWriterAsyncTests.cs (+67 -0)

📄 Description

This pull request introduces asynchronous support to the SharpCompress library, enabling non-blocking operations for reading and skipping entries in compressed archives. The changes add async methods to core stream and reader classes, improve compatibility with modern .NET features, and update tests and mocks to support async operations. Additionally, some code cleanup and minor refactoring are included.

Async API additions and enhancements:

  • Added ReadAsync and ValueTask<int> ReadAsync methods to Deflate64Stream and ReadOnlySubStream to support asynchronous decompression and reading, including handling for Memory<byte> buffers on modern .NET platforms. [1] [2]
  • Introduced async methods to the reader API: MoveToNextEntryAsync and OpenEntryStreamAsync in both IReader interface and AbstractReader class, allowing entries to be processed asynchronously. [1] [2] [3]
  • Implemented async skipping logic with SkipEntryAsync and SkipAsync in AbstractReader, enabling efficient skipping of entries without blocking. [1] [2]

Test and mock updates for async support:

  • Updated ForwardOnlyStream mock to implement async read/write/flush methods, and adjusted CanWrite to support writing, improving test coverage for async scenarios. [1] [2]
  • Modified ReaderTests to use the new async reader API, ensuring tests validate asynchronous behavior.

Codebase cleanup and minor refactoring:

  • Removed unused fields and methods in Deflate64Stream, simplified property implementations, and updated disposal logic for better resource management. [1] [2] [3] [4] [5]
  • Minor refactoring in StreamingZipHeaderFactory for improved code clarity. [1] [2]

Dependency update:

  • Downgraded Microsoft.NET.ILLink.Tasks package version in packages.lock.json for compatibility.

🔄 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/991 **Author:** [@adamhathcock](https://github.com/adamhathcock) **Created:** 10/28/2025 **Status:** ✅ Merged **Merged:** 10/28/2025 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `async-reader-methods` --- ### 📝 Commits (10+) - [`72d5884`](https://github.com/adamhathcock/sharpcompress/commit/72d5884db64b1b8378b4801215fdc9c81af248ee) added async reader overloads - [`f6eabc5`](https://github.com/adamhathcock/sharpcompress/commit/f6eabc5db1265230394dc2d351c7a23a33dd9ac7) Merge remote-tracking branch 'origin/master' into async-reader-methods - [`c68d8de`](https://github.com/adamhathcock/sharpcompress/commit/c68d8deddd4634530e6cde5ba94367241f5dcf3a) add async tests - [`e287d08`](https://github.com/adamhathcock/sharpcompress/commit/e287d0811d4887ba3eccc8dcec4c7c435b31ab3e) minor clean up - [`16ad86c`](https://github.com/adamhathcock/sharpcompress/commit/16ad86c52ad1a0f2b9dfd157355cd75da029ae97) add async implementations to readonlysubstream - [`79653ee`](https://github.com/adamhathcock/sharpcompress/commit/79653eee8005b53075fb496f4f79fcf9b9fc2607) Merge remote-tracking branch 'origin/master' into async-reader-methods - [`a1de3eb`](https://github.com/adamhathcock/sharpcompress/commit/a1de3eb47d3dfc2f96913ea714ce9fa096d084fc) add async tests and clean up deflate64stream - [`19967f5`](https://github.com/adamhathcock/sharpcompress/commit/19967f5ad79c4623f9fd2d12469d76c39554b6d4) allow forward only write - [`42f7d43`](https://github.com/adamhathcock/sharpcompress/commit/42f7d43139ef8bb1eb2e9d43bf729577dc5fd593) enable zip64 tests that pass - [`06713c6`](https://github.com/adamhathcock/sharpcompress/commit/06713c641ec7d12359ee8d6dfa89f8b84368fb6a) async deflate 64 ### 📊 Changes **14 files changed** (+1331 additions, -82 deletions) <details> <summary>View changed files</summary> 📝 `src/SharpCompress/Common/Zip/StreamingZipHeaderFactory.cs` (+2 -3) 📝 `src/SharpCompress/Compressors/Deflate64/Deflate64Stream.cs` (+110 -73) 📝 `src/SharpCompress/IO/ReadOnlySubStream.cs` (+43 -0) 📝 `src/SharpCompress/Readers/AbstractReader.cs` (+75 -0) 📝 `src/SharpCompress/Readers/IReader.cs` (+14 -0) 📝 `src/SharpCompress/packages.lock.json` (+3 -3) 📝 `tests/SharpCompress.Test/Mocks/ForwardOnlyStream.cs` (+35 -2) 📝 `tests/SharpCompress.Test/ReaderTests.cs` (+1 -1) ➕ `tests/SharpCompress.Test/Zip/Zip64AsyncTests.cs` (+242 -0) 📝 `tests/SharpCompress.Test/Zip/Zip64Tests.cs` (+8 -0) ➕ `tests/SharpCompress.Test/Zip/ZipArchiveAsyncTests.cs` (+196 -0) ➕ `tests/SharpCompress.Test/Zip/ZipMemoryArchiveWithCrcAsyncTests.cs` (+281 -0) ➕ `tests/SharpCompress.Test/Zip/ZipReaderAsyncTests.cs` (+254 -0) ➕ `tests/SharpCompress.Test/Zip/ZipWriterAsyncTests.cs` (+67 -0) </details> ### 📄 Description This pull request introduces asynchronous support to the SharpCompress library, enabling non-blocking operations for reading and skipping entries in compressed archives. The changes add async methods to core stream and reader classes, improve compatibility with modern .NET features, and update tests and mocks to support async operations. Additionally, some code cleanup and minor refactoring are included. **Async API additions and enhancements:** * Added `ReadAsync` and `ValueTask<int> ReadAsync` methods to `Deflate64Stream` and `ReadOnlySubStream` to support asynchronous decompression and reading, including handling for `Memory<byte>` buffers on modern .NET platforms. [[1]](diffhunk://#diff-f78ab66baf09df421fda840a268c3eb1ec7e1dc092111e3a9d5357d9f26f1441R148-R247) [[2]](diffhunk://#diff-01392f77a66f217a50843b0f4bdbbd22415dc03d91a27724cdc87a436a440852R98-R138) * Introduced async methods to the reader API: `MoveToNextEntryAsync` and `OpenEntryStreamAsync` in both `IReader` interface and `AbstractReader` class, allowing entries to be processed asynchronously. [[1]](diffhunk://#diff-4627c1288264a95de3957607770dc3facf65ea86eb7e68204567b52ec578da76R42-R60) [[2]](diffhunk://#diff-083fd66e1dab6e8c43abba168d79aad52ea814263e77dcca1eb34f7ce342842fR99-R125) [[3]](diffhunk://#diff-083fd66e1dab6e8c43abba168d79aad52ea814263e77dcca1eb34f7ce342842fR297-R309) * Implemented async skipping logic with `SkipEntryAsync` and `SkipAsync` in `AbstractReader`, enabling efficient skipping of entries without blocking. [[1]](diffhunk://#diff-083fd66e1dab6e8c43abba168d79aad52ea814263e77dcca1eb34f7ce342842fR159-R166) [[2]](diffhunk://#diff-083fd66e1dab6e8c43abba168d79aad52ea814263e77dcca1eb34f7ce342842fR189-R215) **Test and mock updates for async support:** * Updated `ForwardOnlyStream` mock to implement async read/write/flush methods, and adjusted `CanWrite` to support writing, improving test coverage for async scenarios. [[1]](diffhunk://#diff-92402dc8b3eef09492a1cf16e8cdb89f574a8d97b0902f80f70fec486b373199L60-R62) [[2]](diffhunk://#diff-92402dc8b3eef09492a1cf16e8cdb89f574a8d97b0902f80f70fec486b373199R77-R113) * Modified `ReaderTests` to use the new async reader API, ensuring tests validate asynchronous behavior. **Codebase cleanup and minor refactoring:** * Removed unused fields and methods in `Deflate64Stream`, simplified property implementations, and updated disposal logic for better resource management. [[1]](diffhunk://#diff-f78ab66baf09df421fda840a268c3eb1ec7e1dc092111e3a9d5357d9f26f1441L42) [[2]](diffhunk://#diff-f78ab66baf09df421fda840a268c3eb1ec7e1dc092111e3a9d5357d9f26f1441L65-R80) [[3]](diffhunk://#diff-f78ab66baf09df421fda840a268c3eb1ec7e1dc092111e3a9d5357d9f26f1441L141) [[4]](diffhunk://#diff-f78ab66baf09df421fda840a268c3eb1ec7e1dc092111e3a9d5357d9f26f1441L223-L242) [[5]](diffhunk://#diff-f78ab66baf09df421fda840a268c3eb1ec7e1dc092111e3a9d5357d9f26f1441L284-L297) * Minor refactoring in `StreamingZipHeaderFactory` for improved code clarity. [[1]](diffhunk://#diff-d14a822972011bcae9ce03bf5f46e7c5af6bcbfae71613909be671a58f3a7c15L39-L43) [[2]](diffhunk://#diff-d14a822972011bcae9ce03bf5f46e7c5af6bcbfae71613909be671a58f3a7c15L158-R157) **Dependency update:** * Downgraded `Microsoft.NET.ILLink.Tasks` package version in `packages.lock.json` for compatibility. --- <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:20:25 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1410