Caching: SingleFileBackingStore.WriteDocument and DecodeDocument own element-id planning; CultElementIds is internal again

Mesh's typed single-file read and write call the store's typed members instead of planning ids through a public CultElementIds. Builds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-23 00:15:27 +02:00
commit 729754278a
5 changed files with 134 additions and 33 deletions

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using GameCult.Caching;
using MessagePack;
@ -17,8 +18,8 @@ var committed = outside.Commit(batch =>
if (!committed)
return 1;
// A store file is written and read without a cache through the two public members: this project has no InternalsVisibleTo, so
// building it pins that ReadStoreSnapshot and WriteRecord are public API.
// A store file is written and read without a cache through the public members: this project has no InternalsVisibleTo, so
// building it pins that ReadStoreSnapshot, WriteRecord, WriteDocument and DecodeDocument are public API.
var storePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "consumer-build-" + System.Guid.NewGuid().ToString("N") + ".cc");
try
{
@ -28,6 +29,11 @@ try
var snapshot = store.ReadStoreSnapshot();
if (snapshot == null || snapshot.Records.Length != 1 || snapshot.Records[0].Key != "r")
return 1;
var typedRegistry = CultDocumentRegistry.ForTypes(new[] { typeof(ConsumerFaction) });
store.WriteDocument(new CultRecordKey("f"), new ConsumerFaction { Name = "typed" }, registry: typedRegistry);
var typed = store.ReadStoreSnapshot()!.Records.Single(record => record.Key == "f");
if (store.DecodeDocument<ConsumerFaction>(new CultRecordKey("f"), typed.Payload, typedRegistry).Name != "typed")
return 1;
}
finally
{