Class WorldFixture
Verified, disposable copy of a world fixture. Disposing removes only the new copy unless Preserve is set.
public sealed class WorldFixture
- Inheritance
-
objectWorldFixture
Examples
Obtain hashes with Manifest(string) when authoring the fixture, persist and review them in the plan, then use those hashes for the run. Never recalculate them from an unexpected source during the run:
WorldFixture.Verify(fixtureSource, reviewedHashes);
using var fixture = WorldFixture.Copy(fixtureSource, runDirectory, reviewedHashes);
string disposableWorld = fixture.DirectoryPath;
// Stop the owned game before the fixture is disposed.
See the runnable server preparation for the full preparation and cleanup sequence.
Properties
DirectoryPath
The full path of this disposable copy, never the source fixture directory.
public string DirectoryPath { get; }
Property Value
- string
Preserve
When true, Dispose() leaves the copy for inspection; the caller then owns its cleanup.
public bool Preserve { get; set; }
Property Value
- bool
SourceHashes
The source file SHA-256s pinned or recorded when this copy was made, by relative path.
public IReadOnlyDictionary<string, string> SourceHashes { get; }
Property Value
- IReadOnlyDictionary<string, string>
Methods
Copy(string, string, IReadOnlyDictionary<string, string>)
Copies an exact, previously pinned fixture into a new directory owned by this instance.
public static WorldFixture Copy(string source, string outputParent, IReadOnlyDictionary<string, string> expectedHashes)
Parameters
sourcestringoutputParentstringexpectedHashesIReadOnlyDictionary<string, string>
Returns
CopyAsFound(string, string)
Copies a fixture that has no expected manifest: every file's SHA256 is recorded in
SourceHashes and fixture-provenance.json and the copy is verified against it, but nothing says
the source was reviewed in advance. A strict standalone runner may bind these observed hashes as the run's pins;
a standalone run binds and enforces them after the copy. Prefer Copy(string, string, IReadOnlyDictionary<string, string>) when the
expected manifest is known.
public static WorldFixture CopyAsFound(string source, string outputParent)
Parameters
sourcestringoutputParentstring
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Manifest(string)
The SHA256 manifest of every file under source, keyed by this platform's relative path: what a
pinned plan records and Copy(string, string, IReadOnlyDictionary<string, string>) verifies. Build it on the platform that will copy the fixture, from the
exact directory the plan names. Links are refused, as in Copy(string, string, IReadOnlyDictionary<string, string>).
public static IReadOnlyDictionary<string, string> Manifest(string source)
Parameters
sourcestring
Returns
- IReadOnlyDictionary<string, string>
Retire(string, long, long)
Keeps what changed in the copy since it was made, then deletes the copy. Every file added, and every copied file whose
SHA256 changed, goes to keepIn under its relative path (the logs, configs and caches a run wrote). A
file larger than maxFileBytes, or past maxKeptBytes in all, is listed with its
size and SHA256 instead; a link is listed and never followed. changes.json in keepIn lists
the added, changed, missing and not-kept files. Every other file is the source's, by its hash in
SourceHashes, so nothing the run made is lost. Call it only once no process uses the copy. Refused after
Dispose(). When the copy cannot be deleted, what was kept stays and the error says which copy remains.
public RetiredCopy Retire(string keepIn, long maxFileBytes = 67108864, long maxKeptBytes = 268435456)
Parameters
keepInstringmaxFileByteslongmaxKeptByteslong
Returns
Verify(string, IReadOnlyDictionary<string, string>)
Refuses source unless its files are exactly expectedHashes (relative path to
SHA256), naming each missing, unexpected or changed file: the check Copy(string, string, IReadOnlyDictionary<string, string>) makes, without copying.
public static void Verify(string source, IReadOnlyDictionary<string, string> expectedHashes)
Parameters
sourcestringexpectedHashesIReadOnlyDictionary<string, string>