Skip to content

Document breaking change: PackagePart.GetStream() returns non-seekable stream for compressed parts in ReadWrite packages - #55225

Open
gewarren with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-packagepart-non-seekable-stream
Open

Document breaking change: PackagePart.GetStream() returns non-seekable stream for compressed parts in ReadWrite packages#55225
gewarren with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-packagepart-non-seekable-stream

Conversation

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

System.IO.Packaging.PackagePart.GetStream() now returns a forward-only stream instead of a seekable MemoryStream when reading a compressed, unmodified part from a package opened with FileAccess.ReadWrite, following dotnet/runtime#129698. This change adds the corresponding breaking-change documentation.

New article

  • Added docs/core/compatibility/core-libraries/11/packagepart-getstream-non-seekable.md covering:
    • Previous behavior (seekable MemoryStream) vs. new behavior (forward-only stream, CanSeek == false)
    • The five conditions required to observe the change, and scenarios that remain unaffected
    • Recommended action: manually copy to a MemoryStream when seekability is required, or use FileAccess.Read

Indexing

  • Added the article to docs/core/compatibility/toc.yml under Core .NET libraries for .NET 11
  • Added a row to the docs/core/compatibility/11.md breaking changes summary table

Example from the article

using Stream partStream = part.GetStream(FileMode.Open, FileAccess.Read);
using var seekable = new MemoryStream();
partStream.CopyTo(seekable);
seekable.Position = 0;
// Use 'seekable'. It's fully buffered and seekable.

Internal previews

File Preview link
docs/core/compatibility/11.md docs/core/compatibility/11
docs/core/compatibility/core-libraries/11/packagepart-getstream-non-seekable.md docs/core/compatibility/core-libraries/11/packagepart-getstream-non-seekable
docs/core/compatibility/toc.yml docs/core/compatibility/toc

Copilot AI review requested due to automatic review settings August 4, 2026 15:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix PackagePart.GetStream() to return seekable stream for unmodified parts Document breaking change: PackagePart.GetStream() returns non-seekable stream for compressed parts in ReadWrite packages Aug 4, 2026
Copilot AI requested a review from gewarren August 4, 2026 15:50
Comment thread docs/core/compatibility/toc.yml Outdated
Comment thread docs/core/compatibility/toc.yml Outdated
Comment thread docs/core/compatibility/core-libraries/11/packagepart-getstream-non-seekable.md Outdated
Comment thread docs/core/compatibility/core-libraries/11/packagepart-getstream-non-seekable.md Outdated
Comment thread docs/core/compatibility/core-libraries/11/packagepart-getstream-non-seekable.md Outdated
Comment thread docs/core/compatibility/core-libraries/11/packagepart-getstream-non-seekable.md Outdated
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
@gewarren
gewarren marked this pull request as ready for review August 4, 2026 16:49
@gewarren
gewarren requested a review from a team as a code owner August 4, 2026 16:49
@gewarren
gewarren enabled auto-merge (squash) August 4, 2026 16:50
- The part is opened for reading only (`GetStream(FileMode.Open, FileAccess.Read)`).
- The part is compressed (`CompressionOption` other than `NotCompressed`).
- The part wasn't written or modified earlier in the same session.
- The consumer seeks the stream or reads `Position`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this line is incorrect and needs to be removed. The intro to the list is talking about when you would see this change, the change being that a forward-only stream is returned. This line is actually describing what causes the exception to throw, which is just a artifact of trying to seek with a non-seekable stream. It has nothing to do with the change.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The list is the steps required to observe the change. The change would still be there, you just wouldn't observe it, if you didn't seek or read Position. cc @rzikm for his thoughts.

@adegeo adegeo Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's not entirely true though, if the logic checks stream.CanSeek before setting the position, no code will fail via an exception. However, the behavior may now have changed because the code is taking a different path. I think "observe" is the wrong word to use here. I viewed the list as what conditions need to exist to force the underlying type to change, which is what the breaking change is about.

Comment thread docs/core/compatibility/core-libraries/11/packagepart-getstream-non-seekable.md Outdated
Comment thread docs/core/compatibility/core-libraries/11/packagepart-getstream-non-seekable.md Outdated
Comment thread docs/core/compatibility/toc.yml
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
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.

[Breaking change]: PackagePart.GetStream() returns a non-seekable stream for compressed parts in ReadWrite packages

4 participants