Skip to content

Add async 7z writing#1235

Merged
adamhathcock merged 1 commit intomasterfrom
adam/support-async-7z-writing
Feb 25, 2026
Merged

Add async 7z writing#1235
adamhathcock merged 1 commit intomasterfrom
adam/support-async-7z-writing

Conversation

@adamhathcock
Copy link
Owner

This pull request adds asynchronous write support for 7Zip archives, allowing users to create 7z files using async APIs. It introduces an async compression pipeline for LZMA/LZMA2, updates documentation and metadata to reflect 7Zip write support, and provides comprehensive tests to verify async functionality.

Async 7Zip Write Support

  • Added CompressAsync method to SevenZipStreamsCompressor, enabling asynchronous compression of streams using LZMA/LZMA2 with cancellation support.
  • Updated SevenZipWriter.WriteAsync to fully support async file entry writing, including cancellation and proper handling of empty files.

Testing

  • Introduced SevenZipWriterAsyncTests with multiple tests covering async round-trip, directory support, factory integration, async source reads, and cancellation behavior.

Documentation and Metadata

  • Updated docs/FORMATS.md to clarify that 7Zip write support is available via SevenZipWriter for non-solid archives and requires a seekable output stream.
  • Modified project description in SharpCompress.csproj to mention 7Zip write support.

Internal Improvements

  • Added async utility method CopyWithCrcAsync for efficient CRC calculation during async compression.

Copilot AI review requested due to automatic review settings February 25, 2026 16:48
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Feb 25, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • docs/FORMATS.md - Documentation updated to reflect 7Zip writing support
  • src/SharpCompress/Common/SevenZip/SevenZipStreamsCompressor.cs - Added async compression methods
  • src/SharpCompress/SharpCompress.csproj - Updated project description
  • src/SharpCompress/Writers/SevenZip/SevenZipWriter.Async.cs - Implemented async WriteAsync method
  • tests/SharpCompress.Test/SevenZip/SevenZipWriterAsyncTests.cs - Comprehensive test coverage

Code Quality Observations

The implementation follows SharpCompress patterns correctly:

  1. Async patterns: Uses ConfigureAwait(false) and proper CancellationToken handling
  2. Consistency: Async implementation mirrors the sync version's logic
  3. Tests: Cover round-trip, directories, factory usage, async sources, and cancellation
  4. Documentation: Updated to accurately reflect new 7Zip writing capabilities

No inline comments were necessary as no issues were identified.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds comprehensive asynchronous write support for 7Zip archives, enabling users to create 7z files using async APIs. The implementation closely mirrors the existing synchronous implementation while properly supporting true async I/O operations and cancellation.

Changes:

  • Added CompressAsync method to SevenZipStreamsCompressor for async LZMA/LZMA2 compression with cancellation support
  • Implemented WriteAsync method in SevenZipWriter that mirrors the sync Write logic with proper async compression
  • Added comprehensive test suite (SevenZipWriterAsyncTests) covering round-trip scenarios, factory integration, async-only streams, and cancellation
  • Updated documentation in FORMATS.md and SharpCompress.csproj to reflect 7Zip write support

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/SharpCompress.Test/SevenZip/SevenZipWriterAsyncTests.cs New test suite covering async write scenarios including round-trip, directories, factory integration, async-only streams, and cancellation
src/SharpCompress/Writers/SevenZip/SevenZipWriter.Async.cs Async implementation of WriteAsync with proper compression pipeline and WriteDirectoryAsync delegating to sync version
src/SharpCompress/Common/SevenZip/SevenZipStreamsCompressor.cs Added CompressAsync method with async CRC calculation helper (CopyWithCrcAsync)
src/SharpCompress/SharpCompress.csproj Updated project description to mention 7zip write support
docs/FORMATS.md Updated format documentation to clarify 7Zip write support availability and limitations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants