Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds async/await support to LZMA compression streams, enabling asynchronous I/O operations for better performance in async contexts.
- Implements
ReadAsyncandWriteAsyncmethods for LZMA-related stream classes - Adds a new
DecodeChunkHeaderAsyncmethod inLzmaStreamto support asynchronous chunk header reading - Ensures proper cancellation token handling throughout the async operations
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| CrcCheckStream.cs | Adds WriteAsync override that delegates to synchronous Write method |
| CrcBuilderStream.cs | Adds WriteAsync override that properly forwards async call to target stream |
| LzmaStream.cs | Adds comprehensive async support with ReadAsync, WriteAsync, and DecodeChunkHeaderAsync implementations |
| LZipStream.cs | Adds ReadAsync and WriteAsync overrides that delegate to underlying stream |
| Bcj2DecoderStream.cs | Adds ReadAsync override that uses Task.FromResult to wrap synchronous operation |
| AesDecoderStream.cs | Adds full ReadAsync implementation with proper async I/O operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/SharpCompress.Test/Streams/SharpCompressStreamAsyncTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _inputPosition += await _outWindow | ||
| .CopyStreamAsync(_inputStream, toProcess, cancellationToken) | ||
| .ConfigureAwait(false); | ||
| } |
There was a problem hiding this comment.
The synchronous _decoder.Code() method is being called within an async method without cancellation support. This could block the thread during async operations. Consider checking if the decoder operation can be made cancellable or document that this specific operation cannot be interrupted.
| } | |
| } | |
| // The synchronous _decoder.Code() method is called here. | |
| // This operation cannot be cancelled and may block the thread during async operations. |
| ) | ||
| { | ||
| _outWindow.SetLimit(toProcess + 1); | ||
| if (!_decoder.Code(_dictionarySize, _outWindow, _rangeDecoder)) |
There was a problem hiding this comment.
The synchronous _decoder.Code() method is called within an async method without cancellation support. This could block the thread during async operations. Consider checking if the decoder operation can be made cancellable or document that this specific operation cannot be interrupted.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Related to #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
ReadAsyncandWriteAsyncmethods, handling cancellation tokens, and updating internal logic to support async operations across the codebase.Async I/O Support Across Stream Classes
ReadAsyncandWriteAsyncmethods inLzmaStream, including an async version ofDecodeChunkHeaderto support asynchronous chunk decoding and data reading. [1] [2]ReadAsyncandWriteAsyncmethods toLZipStream, supporting bothMemory<byte>andbyte[]overloads for async operations, and delegated async calls to the underlying stream. [1] [2]AesDecoderStreamby implementingReadAsyncwith proper buffer management and cancellation handling.Async Write Support in Utility Streams
WriteAsynctoCrcBuilderStream, updating CRC asynchronously and supporting cancellation tokens.WriteAsyncinCrcCheckStream, allowing asynchronous CRC checking during write operations.Async Compatibility in Decoder Streams
ReadAsyncinBcj2DecoderStream, wrapping the synchronousReadmethod 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.