Fix a usage of ReadOnly that use dispose in 7Zip#1113
Merged
adamhathcock merged 4 commits intomasterfrom Jan 6, 2026
Merged
Conversation
This was referenced Jan 7, 2026
This was referenced Jan 19, 2026
This was referenced Jan 26, 2026
This was referenced Feb 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Maybe addresses #1105
This pull request improves stream disposal behavior and consistency across several stream types in the SharpCompress library, refactors the implementation of stream skipping utilities, and adds comprehensive tests to verify correct disposal semantics. The main changes are grouped below.
Stream disposal and leaveOpen support improvements:
ReadOnlySubStreamconstructors to accept aleaveOpenparameter, ensuring the inner stream is disposed correctly based on this flag.SevenZipFilePart.GetCompressedStream()to explicitly setleaveOpen: falsewhen creating aReadOnlySubStream, ensuring proper disposal of the underlying stream.LZipStreamto store a reference to the original stream and updated itsDisposemethod to dispose the original stream only in compression mode, improving disposal correctness. [1] [2]Stream skipping utilities refactor:
Stream.Skip,Stream.SkipAsync, and related methods inUtility.csto useReadOnlySubStreamandStream.Null, reducing buffer management complexity and improving maintainability.Testing and verification:
DisposalTestssuite to verify the disposal behavior of various stream implementations, including checks for correct handling of theleaveOpenparameter and always/never disposal patterns.Minor cleanup:
IsRecordingproperty fromSharpCompressStream, streamlining the codebase.