ISaveUpgradeStep

Summary: Transform the saved data of one version before it is read into the current type.

Description

An upgrade step changes the saved JSON of one data version so it can be read by the next version. Register steps with AddUpgradeStep. When an older save loads, Save System runs the matching steps in version order, then reads the result into the current type.

Most projects use JsonUpgradeStep<T>, which implements this interface with the optional Newtonsoft JSON package. Implement it yourself to edit the JSON another way.

Namespace Gley.SaveSystem.

Declaration

C#
public interface ISaveUpgradeStep

Members

MemberTypeDescription
TargetTypeTypeThe data type the step upgrades. It must have a SaveVersion above FromVersion.
FromVersionintThe saved version the step accepts. It upgrades the data to the next version.
TryApply—bool TryApply(byte[] wrappedUtf8Json, out byte[] upgraded, out string error)
Receives the saved UTF-8 JSON, where your data is the value object, and returns the transformed JSON in the same shape. Return false with an error to fail the load with SerializationError.

Example

See AddUpgradeStep for a complete component that registers a JSON field rename, and Changing your save data after release for the full workflow.

On This Page