[PR #1002] [MERGED] async bzip2 and add #1420

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

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/1002
Author: @adamhathcock
Created: 10/30/2025
Status: Merged
Merged: 10/31/2025
Merged by: @adamhathcock

Base: masterHead: adam/async-bzip2


📝 Commits (4)

📊 Changes

9 files changed (+620 additions, -3 deletions)

View changed files

📝 src/SharpCompress/Compressors/ADC/ADCBase.cs (+186 -0)
📝 src/SharpCompress/Compressors/ADC/ADCStream.cs (+72 -0)
📝 src/SharpCompress/Compressors/BZip2/BZip2Stream.cs (+27 -1)
📝 src/SharpCompress/Compressors/BZip2/CBZip2InputStream.cs (+24 -0)
📝 src/SharpCompress/Compressors/BZip2/CBZip2OutputStream.cs (+17 -0)
📝 src/SharpCompress/Writers/Zip/ZipWriter.cs (+2 -2)
tests/SharpCompress.Test/AdcAsyncTest.cs (+61 -0)
tests/SharpCompress.Test/BZip2/BZip2StreamAsyncTests.cs (+231 -0)
📝 tests/SharpCompress.Test/Rar/RarCRCTest.cs (+0 -0)

📄 Description

Related to https://github.com/adamhathcock/sharpcompress/issues/992

This pull request adds asynchronous read and write support to the ADC and BZip2 compression streams, enabling non-blocking operations and cancellation support. It introduces new async methods and refactors existing classes to handle asynchronous workflows, improving integration with modern .NET applications. Comprehensive tests are also added to verify the correctness and robustness of the new async features.

ADC Compression/Decompression Enhancements

  • Added AdcDecompressResult class to encapsulate results of ADC decompression, including bytes read and output buffer.
  • Implemented DecompressAsync methods in ADCBase.cs for asynchronous decompression of byte arrays and streams, supporting cancellation tokens and buffer pooling.
  • Added ReadAsync method to ADCStream.cs to support async reading and decompression with cancellation support.

BZip2 Compression/Decompression Enhancements

  • Added async read and write methods to BZip2Stream.cs, including overloads for both byte[] and Memory<byte> buffers, supporting cancellation tokens.
  • Implemented async read in CBZip2InputStream.cs and async write in CBZip2OutputStream.cs, both with cancellation support. [1] [2]

Test Coverage

  • Added AdcAsyncTest.cs to test asynchronous ADC decompression, chunked reads, and cancellation scenarios.
  • Added BZip2StreamAsyncTests.cs to verify async compression/decompression, multiple async writes, cancellation, and large data handling for BZip2 streams.

🔄 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/1002 **Author:** [@adamhathcock](https://github.com/adamhathcock) **Created:** 10/30/2025 **Status:** ✅ Merged **Merged:** 10/31/2025 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `adam/async-bzip2` --- ### 📝 Commits (4) - [`bc06f31`](https://github.com/adamhathcock/sharpcompress/commit/bc06f3179d4a855b5ad63de8108513bd3b56e1ff) add basics for async bzip2 - [`a136084`](https://github.com/adamhathcock/sharpcompress/commit/a136084e11e40a30b0c670484216e3021262a2b9) add adc async - [`eb18805`](https://github.com/adamhathcock/sharpcompress/commit/eb188051d44ad7de493cf0803b300ed5b8bb1883) fmt - [`ccc8587`](https://github.com/adamhathcock/sharpcompress/commit/ccc8587e5f8b5f41101b0ba30b06fb90a44c9593) review fixes ### 📊 Changes **9 files changed** (+620 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/SharpCompress/Compressors/ADC/ADCBase.cs` (+186 -0) 📝 `src/SharpCompress/Compressors/ADC/ADCStream.cs` (+72 -0) 📝 `src/SharpCompress/Compressors/BZip2/BZip2Stream.cs` (+27 -1) 📝 `src/SharpCompress/Compressors/BZip2/CBZip2InputStream.cs` (+24 -0) 📝 `src/SharpCompress/Compressors/BZip2/CBZip2OutputStream.cs` (+17 -0) 📝 `src/SharpCompress/Writers/Zip/ZipWriter.cs` (+2 -2) ➕ `tests/SharpCompress.Test/AdcAsyncTest.cs` (+61 -0) ➕ `tests/SharpCompress.Test/BZip2/BZip2StreamAsyncTests.cs` (+231 -0) 📝 `tests/SharpCompress.Test/Rar/RarCRCTest.cs` (+0 -0) </details> ### 📄 Description Related to https://github.com/adamhathcock/sharpcompress/issues/992 This pull request adds asynchronous read and write support to the ADC and BZip2 compression streams, enabling non-blocking operations and cancellation support. It introduces new async methods and refactors existing classes to handle asynchronous workflows, improving integration with modern .NET applications. Comprehensive tests are also added to verify the correctness and robustness of the new async features. ### ADC Compression/Decompression Enhancements * Added `AdcDecompressResult` class to encapsulate results of ADC decompression, including bytes read and output buffer. * Implemented `DecompressAsync` methods in `ADCBase.cs` for asynchronous decompression of byte arrays and streams, supporting cancellation tokens and buffer pooling. * Added `ReadAsync` method to `ADCStream.cs` to support async reading and decompression with cancellation support. ### BZip2 Compression/Decompression Enhancements * Added async read and write methods to `BZip2Stream.cs`, including overloads for both `byte[]` and `Memory<byte>` buffers, supporting cancellation tokens. * Implemented async read in `CBZip2InputStream.cs` and async write in `CBZip2OutputStream.cs`, both with cancellation support. [[1]](diffhunk://#diff-72084fa6f9f496017ced93be8a9992e22603cbb971e9596ba321e5aa3fb7952aR1132-R1153) [[2]](diffhunk://#diff-5e2e4f79a7a5f987d4bf24b368eab7273264466d77d29013714cb9df5c4afe9aR2027-R2041) ### Test Coverage * Added `AdcAsyncTest.cs` to test asynchronous ADC decompression, chunked reads, and cancellation scenarios. * Added `BZip2StreamAsyncTests.cs` to verify async compression/decompression, multiple async writes, cancellation, and large data handling for BZip2 streams. --- <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:28 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1420