Skip to content

Preserve manifest input streams when writing manifests - #14883

Open
dtivel wants to merge 1 commit into
mainfrom
dtivel/write-file
Open

Preserve manifest input streams when writing manifests#14883
dtivel wants to merge 1 commit into
mainfrom
dtivel/write-file

Conversation

@dtivel

@dtivel dtivel commented Aug 28, 2026

Copy link
Copy Markdown

Fixes #14881.

Summary

Ensure ManifestWriter.WriteManifest leaves the manifest's caller-owned input stream open after writing.

PR #9983 began disposing the StreamReader, which also disposed the underlying manifest input stream. This caused subsequent calls to ManifestWriter.WriteManifest using the same manifest to fail with Stream was not readable.

The explicit StreamReader arguments preserve the previous encoding, BOM detection, and buffer-size behavior while setting leaveOpen: true.

Compatibility

This restores the stream-ownership behavior from before PR #9983. No ChangeWave is needed because this is a narrow regression fix and does not change the public API surface.

Tests

Added regression coverage that:

  • writes the same manifest twice after rewinding its preserved input stream;
  • verifies the input stream remains readable after each write;
  • verifies both writes produce identical, non-empty output.

The regression test passes on both net11.0 and net472.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 28, 2026 23:38
@dtivel
dtivel requested a review from a team as a code owner August 28, 2026 23:38
@dtivel
dtivel temporarily deployed to copilot-pat-pool August 28, 2026 23:38 — with GitHub Actions Inactive
@dtivel
dtivel temporarily deployed to copilot-pat-pool August 28, 2026 23:38 — with GitHub Actions Inactive
@dtivel dtivel changed the title Preserve manifest input streams when writing temporary files Preserve manifest input streams when writing manifests Aug 28, 2026
@dtivel
dtivel temporarily deployed to copilot-pat-pool August 28, 2026 23:44 — with GitHub Actions Inactive
@dtivel
dtivel temporarily deployed to copilot-pat-pool August 28, 2026 23:45 — with GitHub Actions Inactive
@dtivel
dtivel temporarily deployed to copilot-pat-pool August 28, 2026 23:45 — with GitHub Actions Inactive

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 review overview

Review tier: Lite
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity src/​Tasks/​ManifestUtil/​Util.csWriteFile(string, Stream) now uses leaveOpen: true, so it no longer disposes the…
What changed in this PR

This PR fixes a regression in the manifest utilities where writing a manifest could dispose the manifest’s preserved (caller-owned) input stream, breaking subsequent reuse of the same Manifest instance.

Changes:

  • Update Util.WriteFile(string, Stream) to construct a StreamReader with leaveOpen: true so disposing the reader doesn’t close the supplied stream.
  • Add a regression unit test that writes the same manifest twice after rewinding its preserved input stream and verifies both outputs match and the input stream remains readable.
File Description
src/​Tasks/​ManifestUtil/​Util.cs Preserves caller-owned streams by leaving the input stream open when reading it via StreamReader.
src/​Tasks.UnitTests/​ManifestWriter_Tests.cs Adds regression coverage to ensure ManifestWriter.WriteManifest doesn’t dispose preserved input streams and that repeated writes are consistent.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Tasks/ManifestUtil/Util.cs
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.

ManifestWriter.WriteManifest unexpectedly disposes the preserved manifest input stream

4 participants