Fix appended file reuse - #1885
Merged
Merged
Conversation
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.
# Conflicts: # src/Verify/Guards.cs
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.
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.