Cacheless calls detach their registry when they end; the declared type decides the header; both pinned

Mutation of the restore line and of the header's Holds(runtime type) survived the previous tests (Stryker/hand mutants C1, C7). Not yet built.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-23 02:00:16 +02:00
commit a4e70ac4fb
2 changed files with 53 additions and 10 deletions

View file

@ -3591,12 +3591,7 @@ namespace GameCult.Caching
protected void Held(Action body) => Held(() => { body(); return true; });
private protected CultDocumentRegistry? SwapRegistry(CultDocumentRegistry? registry)
{
var previous = _registry;
_registry = registry;
return previous;
}
private protected void UseRegistry(CultDocumentRegistry? registry) => _registry = registry;
internal void AttachRegistry(CultDocumentRegistry registry)
{
@ -4294,19 +4289,19 @@ namespace GameCult.Caching
});
}
// The registry is the call's argument, not store state: it is attached for the call under the store's gate and the store's
// previous registry (none, for a store no cache ever attached) comes back whatever the call does.
// The registry is the call's argument, not store state: it is attached for the call under the store's gate and detached when
// the call ends, whatever it does. A cacheless store holds none between calls.
private void ForTheCall(CultDocumentRegistry? registry, Action body) =>
Held(() =>
{
var previous = SwapRegistry(registry);
UseRegistry(registry);
try
{
body();
}
finally
{
SwapRegistry(previous);
UseRegistry(null);
}
});