Skip to content

Fix appended file reuse - #1885

Merged
SimonCropp merged 3 commits into
mainfrom
fix-appended-file-reuse
Aug 29, 2026
Merged

Fix appended file reuse#1885
SimonCropp merged 3 commits into
mainfrom
fix-appended-file-reuse

Conversation

@SimonCropp

@SimonCropp SimonCropp commented Aug 29, 2026

Copy link
Copy Markdown
Member

Build appended file targets per verification
Appended files were stored as Targets, and a binary one holds a live stream. The
engine disposes the stream of every target it writes, so a second Verify with
the same settings instance failed with ObjectDisposedException, even though the
caller had handed over re-readable bytes or a file path. Settings are reused
routinely, since SettingsTask copies them per Verify call.

They are now stored as factories and built once per verification:
AppendContentAsFile(byte[]) opens a fresh MemoryStream over the same array, and
AppendFile(string) opens the file per verification instead of holding a handle
from the moment it was appended. Existence is still checked eagerly, so a
missing path is still reported where it was passed.

AppendFile(Stream) is unchanged and still single use: the stream is owned by the
caller and cannot be replayed. That is now documented on the overload.

Appended files were stored as Targets, and a binary one holds a live stream. The
engine disposes the stream of every target it writes, so a second Verify with
the same settings instance failed with ObjectDisposedException, even though the
caller had handed over re-readable bytes or a file path. Settings are reused
routinely, since SettingsTask copies them per Verify call.

They are now stored as factories and built once per verification:
AppendContentAsFile(byte[]) opens a fresh MemoryStream over the same array, and
AppendFile(string) opens the file per verification instead of holding a handle
from the moment it was appended. Existence is still checked eagerly, so a
missing path is still reported where it was passed.

AppendFile(Stream) is unchanged and still single use: the stream is owned by the
caller and cannot be replayed. That is now documented on the overload.
@SimonCropp SimonCropp added this to the 33.0.0 milestone Aug 29, 2026
# Conflicts:
#	src/Verify/Guards.cs
@SimonCropp
SimonCropp merged commit 42b9db2 into main Aug 29, 2026
3 of 5 checks passed
@SimonCropp
SimonCropp deleted the fix-appended-file-reuse branch August 29, 2026 12:08
@github-actions
github-actions Bot restored the fix-appended-file-reuse branch August 29, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant