-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix reachable Debug.Assert in InterleavedZipPackagePartStream.Length #123817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…g NotSupportedException Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
src/libraries/System.IO.Packaging/src/System/IO/Packaging/InterleavedZipPackagePartStream.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
|
Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression |
There was a problem hiding this 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 PR fixes a reachable Debug.Assert in InterleavedZipPackagePartStream.Length that fails in debug builds when accessing the Length property of a package part stream opened with read-only access.
Changes:
- Removed incorrect
Debug.Assert(CanSeek)from theLengthproperty getter inInterleavedZipPackagePartStream - Added comprehensive test that verifies
Lengthreturns correct value even whenCanSeekis false
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/libraries/System.IO.Packaging/src/System/IO/Packaging/InterleavedZipPackagePartStream.cs | Removed the incorrect assertion that assumed CanSeek must be true for Length to work |
| src/libraries/System.IO.Packaging/tests/PartPieceTests.cs | Added test that verifies Length works correctly when CanSeek is false, validating the exact byte count |
Debug.Assert(CanSeek)inInterleavedZipPackagePartStream.Lengthfails in debug buildsLengthreturned correct values becauseZipWrappingStream.Lengthgets length fromZipArchiveEntry.Lengtheven whenCanSeekis falseDebug.Assert(CanSeek)entirely - the underlying streams supportLengtheven when not seekableInterleavedZipPackagePartStream_Length_ReturnsCorrectValueWhenCanSeekIsFalsewith exact length verificationOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.