Table of Contents

Class SaveFormatChecks

Namespace
GrindFest
Assembly
GrindFest.dll

The assertions for the binary save format, as plain static methods so they can be run from outside the test runner as well - the editor can call these through reflection without entering play mode or building a player, which is how they were written in the first place. Each returns null when it passes, or the reason it failed.

public static class SaveFormatChecks
Inheritance
object
SaveFormatChecks

Methods

ComponentPayloadRoundTrip()

The payload slot a component is handed: it writes its own typed payload and reads it back, and every way of not having a readable payload has to come back as "nothing to restore" rather than as an exception - the save file is something a player can edit.

ItemResistancesSurviveAMemoryPackRoundTrip()

ResistanceDictionary is a Dictionary subclass, which MemoryPack has no built-in support for, so it depends on ResistanceDictionaryFormatter having been registered by MemoryPackSetup. Nothing else in the save would notice it missing: the item would round-trip with empty resistances and no error anywhere - which is why this is a test and not a comment.

RealComponentPayloadsRoundTrip()

Every payload type a component really writes, through the slot it is handed - the types themselves, not a stand-in.

RoundTripKeepsSaveData()

Everything a party would be made of, through MemoryPack.MemoryPackSerializer and back. Deliberately includes the shapes that are easy to get wrong: a nullable struct, a nullable int, an enum, an enum-keyed dictionary, a nested list of the same type twice (hero → inventory → item), a System.Version and a component payload.

It registers the formatters itself first, and that line is not decoration: the RuntimeInitializeOnLoadMethod hook that does it in a player does not run outside play mode, and this check is meant to run in the editor too. It failed on exactly that the first time it ran.

SaveKeysAreUniqueAndNamespaced()