Decide dictionary key edits in the inspection model
A refused key and an unavailable fresh key are now the model's answer: ReplaceKey returns the kept key with the notice text, FreshKey returns null with its notice, and IMGUI only shows them. A key is taken when another serializes the same or when the dictionary's own comparer calls them equal, so 0.0 against -0.0 is refused instead of throwing in BuildDictionary. Keys never actually compared by bytes: the Studio handed the model the document codec, whose registry guard throws for any non-document value, so every key fell back to ToString. CultCacheMessagePack now builds the model with a value serializer, and the Studio and tests both use it. Tests pin the comparer rule, the unchanged-key rule (an old empty reference key survives an edit of its value) and serialized identity (keys whose ToString collides); each fails with its rule removed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
5de49ebc60
commit
2a46409017
5 changed files with 138 additions and 70 deletions
|
|
@ -19,6 +19,13 @@ namespace GameCult.Caching.MessagePack
|
|||
|
||||
public static class CultCacheMessagePack
|
||||
{
|
||||
// The inspection model over this codec. Values serialize without the document guard, so dictionary keys and other
|
||||
// non-document values compare by their bytes; clones deserialize as registered documents.
|
||||
public static CultInspectorModel CreateInspectorModel(CultDocumentRegistry registry) => new CultInspectorModel(
|
||||
registry,
|
||||
(value, type) => global::MessagePack.MessagePackSerializer.Serialize(type, value, CultDocumentMessagePackSerialization.OptionsFor(type.Assembly)),
|
||||
(type, bytes) => CultDocumentMessagePackSerialization.DeserializeUntyped(type, bytes, registry));
|
||||
|
||||
// Opening hydrates. A consumer that wants a fresh store removes the records it does not keep, upserts, and
|
||||
// flushes; the atomic replace does the rest.
|
||||
public static CultCache Create(string filePath, CultCacheOpenOptions? options = null)
|
||||
|
|
|
|||
Loading…
Reference in a new issue