mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
[PR #1145] [MERGED] Add leaveOpen parameter to LZipStream and BZip2Stream #1582
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/adamhathcock/sharpcompress/pull/1145
Author: @Copilot
Created: 1/19/2026
Status: ✅ Merged
Merged: 1/19/2026
Merged by: @adamhathcock
Base:
master← Head:copilot/add-leaveopen-parameter-lzipstream📝 Commits (3)
4998676Initial plan0e4a159Add leaveOpen parameter to LZipStream and BZip2Stream9454466Add comprehensive tests for leaveOpen behavior and fix BZip2 stream disposal📊 Changes
7 files changed (+309 additions, -23 deletions)
View changed files
📝
src/SharpCompress/Compressors/BZip2/BZip2Stream.cs(+15 -3)📝
src/SharpCompress/Compressors/BZip2/CBZip2InputStream.cs(+11 -3)📝
src/SharpCompress/Compressors/BZip2/CBZip2OutputStream.cs(+9 -4)📝
src/SharpCompress/Compressors/LZMA/LZipStream.cs(+5 -3)📝
src/SharpCompress/Compressors/LZMA/LzmaStream.cs(+28 -8)📝
tests/SharpCompress.Test/Streams/DisposalTests.cs(+15 -2)➕
tests/SharpCompress.Test/Streams/LeaveOpenBehaviorTests.cs(+226 -0)📄 Description
PR #1113 changed disposal behavior for
LZipStreamandBZip2Stream, breaking code that expected the underlying stream to remain open. These streams lacked theleaveOpenparameter available in other compression streams likeZStandard.Changes
leaveOpenparameter toLZipStreamandBZip2Streamconstructors (defaults tofalsefor backward compatibility)CBZip2InputStream,CBZip2OutputStream,LzmaStream) to propagate and respect theleaveOpenflagCBZip2InputStream.BsFinishedWithStream()which was disposing streams unconditionally during decompressionUsage
Testing
Added comprehensive tests in
LeaveOpenBehaviorTests.cscovering compress/decompress modes for both streams withleaveOpen=true/false.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.