What's wrong
JsonUndoRedoSerializer serializes each command's Metadata. On load, though, PlaceholderCommand (UndoRedo/Services/JsonUndoRedoSerializer.cs:~186) passes only ChangeType and AffectedItems to the BaseCommand constructor, which builds a fresh ChangeMetadata with:
DateTimeOffset.Now,
- a size of 1,
- no
CustomData.
The deserialized metadata is thrown away, although the comment at around line 104 says the placeholder "preserves metadata".
Failure scenario (reproduced with a temporary MSTest)
Execute DelegateCommand(..., size: 42), then SaveStateAsync, then LoadStateAsync into a new service:
orig size=42 ts=...54.3085987
loaded size=1 ts=...54.4617403
After a reload, any history or change-visualization UI (GetChangeVisualizations) shows every change as having happened at load time with size 1, and any CustomData the app attached is gone.
Suggested fix
BaseCommand.Metadata is virtual with a protected setter. In PlaceholderCommand's constructor, assign the deserialized ChangeMetadata: Metadata = metadata;. Or override Metadata to return it.
Acceptance: a round-trip test asserting that Timestamp, ChangeSize and CustomData survive save and load.
What's wrong
JsonUndoRedoSerializerserializes each command'sMetadata. On load, though,PlaceholderCommand(UndoRedo/Services/JsonUndoRedoSerializer.cs:~186) passes onlyChangeTypeandAffectedItemsto theBaseCommandconstructor, which builds a freshChangeMetadatawith:DateTimeOffset.Now,CustomData.The deserialized metadata is thrown away, although the comment at around line 104 says the placeholder "preserves metadata".
Failure scenario (reproduced with a temporary MSTest)
Execute
DelegateCommand(..., size: 42), thenSaveStateAsync, thenLoadStateAsyncinto a new service:After a reload, any history or change-visualization UI (
GetChangeVisualizations) shows every change as having happened at load time with size 1, and anyCustomDatathe app attached is gone.Suggested fix
BaseCommand.Metadatais virtual with a protected setter. InPlaceholderCommand's constructor, assign the deserializedChangeMetadata:Metadata = metadata;. Or overrideMetadatato return it.Acceptance: a round-trip test asserting that
Timestamp,ChangeSizeandCustomDatasurvive save and load.