[PR #1003] [MERGED] async lzma #1423

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

📋 Pull Request Information

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

Base: masterHead: adam/async-lzma


📝 Commits (10+)

📊 Changes

18 files changed (+1574 additions, -179 deletions)

View changed files

📝 Directory.Packages.props (+1 -0)
📝 src/SharpCompress/Compressors/LZMA/AesDecoderStream.cs (+67 -0)
📝 src/SharpCompress/Compressors/LZMA/Bcj2DecoderStream.cs (+14 -0)
📝 src/SharpCompress/Compressors/LZMA/LZ/LzOutWindow.cs (+134 -0)
📝 src/SharpCompress/Compressors/LZMA/LZipStream.cs (+26 -0)
📝 src/SharpCompress/Compressors/LZMA/LzmaDecoder.cs (+177 -25)
📝 src/SharpCompress/Compressors/LZMA/LzmaStream.cs (+201 -0)
📝 src/SharpCompress/Compressors/LZMA/Utilites/CrcBuilderStream.cs (+20 -0)
📝 src/SharpCompress/Compressors/LZMA/Utilites/CrcCheckStream.cs (+17 -1)
📝 src/SharpCompress/SharpCompress.csproj (+3 -0)
📝 src/SharpCompress/packages.lock.json (+3 -3)
tests/SharpCompress.Test/Streams/LzmaStreamAsyncTests.cs (+606 -0)
📝 tests/SharpCompress.Test/Streams/LzmaStreamTests.cs (+1 -2)
tests/SharpCompress.Test/Streams/RewindableStreamAsyncTest.cs (+96 -0)
📝 tests/SharpCompress.Test/Streams/SharpCompressStreamAsyncTests.cs (+73 -110)
📝 tests/SharpCompress.Test/Streams/SharpCompressStreamTest.cs (+4 -10)
tests/SharpCompress.Test/Streams/ZLibBaseStreamAsyncTests.cs (+112 -0)
📝 tests/SharpCompress.Test/Tar/TarReaderAsyncTests.cs (+19 -28)

📄 Description

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

This pull request adds asynchronous read and write support to several LZMA-related stream classes, enhancing their compatibility with modern .NET patterns and improving performance in I/O-bound scenarios. The changes include implementing ReadAsync and WriteAsync methods, handling cancellation tokens, and updating internal logic to support async operations across the codebase.

Async I/O Support Across Stream Classes

  • Implemented ReadAsync and WriteAsync methods in LzmaStream, including an async version of DecodeChunkHeader to support asynchronous chunk decoding and data reading. [1] [2]
  • Added ReadAsync and WriteAsync methods to LZipStream, supporting both Memory<byte> and byte[] overloads for async operations, and delegated async calls to the underlying stream. [1] [2]
  • Provided async read support in AesDecoderStream by implementing ReadAsync with proper buffer management and cancellation handling.

Async Write Support in Utility Streams

  • Added WriteAsync to CrcBuilderStream, updating CRC asynchronously and supporting cancellation tokens.
  • Implemented WriteAsync in CrcCheckStream, allowing asynchronous CRC checking during write operations.

Async Compatibility in Decoder Streams

  • Implemented ReadAsync in Bcj2DecoderStream, wrapping the synchronous Read method for compatibility with async APIs and cancellation tokens.

These updates ensure that all major LZMA stream classes in the codebase now support asynchronous I/O, making them suitable for modern, high-performance applications that require non-blocking operations.


🔄 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/1003 **Author:** [@adamhathcock](https://github.com/adamhathcock) **Created:** 10/30/2025 **Status:** ✅ Merged **Merged:** 11/1/2025 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `adam/async-lzma` --- ### 📝 Commits (10+) - [`321233b`](https://github.com/adamhathcock/sharpcompress/commit/321233b82c90338868009a4908940b5713822596) some async implementations - [`d4f11e0`](https://github.com/adamhathcock/sharpcompress/commit/d4f11e00b1ba0d9ab5fe802a97684da09015001e) some more async changes - [`53c9619`](https://github.com/adamhathcock/sharpcompress/commit/53c96193c1aa1b150ad07531cf9237d75b400006) format - [`60e1dc0`](https://github.com/adamhathcock/sharpcompress/commit/60e1dc023932307605e141a1782923e34449fa78) review fixes - [`e1e9c44`](https://github.com/adamhathcock/sharpcompress/commit/e1e9c449e94a55661debb9db38dc9d623846c40f) use proper async versions - [`a669de2`](https://github.com/adamhathcock/sharpcompress/commit/a669de24b7fd65a16aacb3dbaf1c04245794f8cb) Merge remote-tracking branch 'origin/master' into adam/async-lzma - [`74e2dca`](https://github.com/adamhathcock/sharpcompress/commit/74e2dca207cdec823ef95ccff6a56fbddda03bde) fmt - [`1e22b47`](https://github.com/adamhathcock/sharpcompress/commit/1e22b47fe1f9ef71f64ff5dc62123f67a49132d2) some fixes - [`c53ca37`](https://github.com/adamhathcock/sharpcompress/commit/c53ca372f2f28a7bb562afcdafa68aa0805be8b8) don't use pools in tests - [`7fa271a`](https://github.com/adamhathcock/sharpcompress/commit/7fa271a1b41a99f178b06db5ce2ccf0d2a4377b5) fix ILLink ### 📊 Changes **18 files changed** (+1574 additions, -179 deletions) <details> <summary>View changed files</summary> 📝 `Directory.Packages.props` (+1 -0) 📝 `src/SharpCompress/Compressors/LZMA/AesDecoderStream.cs` (+67 -0) 📝 `src/SharpCompress/Compressors/LZMA/Bcj2DecoderStream.cs` (+14 -0) 📝 `src/SharpCompress/Compressors/LZMA/LZ/LzOutWindow.cs` (+134 -0) 📝 `src/SharpCompress/Compressors/LZMA/LZipStream.cs` (+26 -0) 📝 `src/SharpCompress/Compressors/LZMA/LzmaDecoder.cs` (+177 -25) 📝 `src/SharpCompress/Compressors/LZMA/LzmaStream.cs` (+201 -0) 📝 `src/SharpCompress/Compressors/LZMA/Utilites/CrcBuilderStream.cs` (+20 -0) 📝 `src/SharpCompress/Compressors/LZMA/Utilites/CrcCheckStream.cs` (+17 -1) 📝 `src/SharpCompress/SharpCompress.csproj` (+3 -0) 📝 `src/SharpCompress/packages.lock.json` (+3 -3) ➕ `tests/SharpCompress.Test/Streams/LzmaStreamAsyncTests.cs` (+606 -0) 📝 `tests/SharpCompress.Test/Streams/LzmaStreamTests.cs` (+1 -2) ➕ `tests/SharpCompress.Test/Streams/RewindableStreamAsyncTest.cs` (+96 -0) 📝 `tests/SharpCompress.Test/Streams/SharpCompressStreamAsyncTests.cs` (+73 -110) 📝 `tests/SharpCompress.Test/Streams/SharpCompressStreamTest.cs` (+4 -10) ➕ `tests/SharpCompress.Test/Streams/ZLibBaseStreamAsyncTests.cs` (+112 -0) 📝 `tests/SharpCompress.Test/Tar/TarReaderAsyncTests.cs` (+19 -28) </details> ### 📄 Description Related to https://github.com/adamhathcock/sharpcompress/issues/992 This pull request adds asynchronous read and write support to several LZMA-related stream classes, enhancing their compatibility with modern .NET patterns and improving performance in I/O-bound scenarios. The changes include implementing `ReadAsync` and `WriteAsync` methods, handling cancellation tokens, and updating internal logic to support async operations across the codebase. **Async I/O Support Across Stream Classes** * Implemented `ReadAsync` and `WriteAsync` methods in `LzmaStream`, including an async version of `DecodeChunkHeader` to support asynchronous chunk decoding and data reading. [[1]](diffhunk://#diff-df001a76141a3c3cc816eea154e5c069ca675be3febf7281ef78df69a327e080R428-R503) [[2]](diffhunk://#diff-df001a76141a3c3cc816eea154e5c069ca675be3febf7281ef78df69a327e080R516-R622) * Added `ReadAsync` and `WriteAsync` methods to `LZipStream`, supporting both `Memory<byte>` and `byte[]` overloads for async operations, and delegated async calls to the underlying stream. [[1]](diffhunk://#diff-44b45464653f8440fd0885412f8b8b22fdc507753278d389bd5b3b6b05a7a32cR162-R166) [[2]](diffhunk://#diff-44b45464653f8440fd0885412f8b8b22fdc507753278d389bd5b3b6b05a7a32cR189-R211) * Provided async read support in `AesDecoderStream` by implementing `ReadAsync` with proper buffer management and cancellation handling. **Async Write Support in Utility Streams** * Added `WriteAsync` to `CrcBuilderStream`, updating CRC asynchronously and supporting cancellation tokens. * Implemented `WriteAsync` in `CrcCheckStream`, allowing asynchronous CRC checking during write operations. **Async Compatibility in Decoder Streams** * Implemented `ReadAsync` in `Bcj2DecoderStream`, wrapping the synchronous `Read` method for compatibility with async APIs and cancellation tokens. These updates ensure that all major LZMA stream classes in the codebase now support asynchronous I/O, making them suitable for modern, high-performance applications that require non-blocking operations. --- <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:29 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1423