Strip doc comments from the Caching projects

Every /// line in GameCult.Caching and GameCult.Caching.MessagePack goes; they
restated member names. Three blocks that state a rule stay as // comments:
MaterializeMissingGlobals runs after hydration so persisted globals win,
ExecuteTransactionAsync commits durably before the cache and observers
advance, and CommitBatch implementations restore their staged view on
failure. Both projects add NoWarn CS1591, since GenerateDocumentationFile is
on in src/Directory.Build.props.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-13 16:54:43 +02:00
commit 60cbfdde6d
10 changed files with 7 additions and 717 deletions

View file

@ -4,54 +4,27 @@ using System.Threading.Tasks;
namespace GameCult.Caching.MessagePack
{
/// <summary>
/// Options for opening a CultCache over the canonical single-file MessagePack backing store.
/// </summary>
public sealed class CultCacheOpenOptions
{
/// <summary>
/// Gets or sets the document registry to use. When omitted, the shared registry is used.
/// </summary>
public CultDocumentRegistry? Registry { get; set; }
/// <summary>
/// Gets or sets whether the cache should pull the existing snapshot during open.
/// </summary>
public bool PullOnOpen { get; set; } = true;
/// <summary>
/// Gets or sets whether the cache should flush attached stores when disposed.
/// </summary>
public bool FlushOnDispose { get; set; }
/// <summary>
/// Gets or sets whether the backing store should flush when disposed.
/// </summary>
public bool StoreFlushOnDispose { get; set; }
/// <summary>
/// Gets or sets whether the cache should use a paged directory store instead of one whole-file snapshot.
/// </summary>
public bool UseDirectoryStore { get; set; }
}
/// <summary>
/// Friendly MessagePack entrypoints for opening a CultCache with the canonical backing store.
/// </summary>
public static class CultCacheMessagePack
{
/// <summary>
/// Creates a cache with the canonical single-file MessagePack backing store attached.
/// </summary>
public static CultCache Create(string filePath, CultCacheOpenOptions? options = null)
{
options ??= new CultCacheOpenOptions();
return CreateCore(filePath, options, initializeGlobals: true);
}
/// <summary>
/// Creates a cache with the canonical single-file MessagePack backing store attached and optionally pulls the on-disk snapshot.
/// </summary>
public static async Task<CultCache> OpenAsync(string filePath, CultCacheOpenOptions? options = null)
{
options ??= new CultCacheOpenOptions();

View file

@ -7,20 +7,11 @@ using MessagePack.Resolvers;
namespace GameCult.Caching.MessagePack;
/// <summary>
/// MessagePack resolver for CultCache-specific value types.
/// </summary>
public sealed class CultDocumentResolver : IFormatterResolver
{
/// <summary>
/// Gets the shared resolver instance.
/// </summary>
public static readonly CultDocumentResolver Instance = new();
private CultDocumentResolver() { }
/// <summary>
/// Gets a formatter for the requested type, when this resolver owns it.
/// </summary>
public IMessagePackFormatter<T>? GetFormatter<T>()
{
var type = typeof(T);
@ -34,9 +25,6 @@ public sealed class CultDocumentResolver : IFormatterResolver
}
}
/// <summary>
/// MessagePack serialization helpers for CultCache documents and backing stores.
/// </summary>
public static class CultDocumentMessagePackSerialization
{
private const int PersistedRecordFieldCount = 4;
@ -44,9 +32,6 @@ public static class CultDocumentMessagePackSerialization
private const int SchemaCatalogMemberFieldCount = 8;
private const int StoreSnapshotFieldCount = 3;
/// <summary>
/// Gets the shared MessagePack serializer options for CultCache payloads.
/// </summary>
public static readonly MessagePackSerializerOptions Options =
MessagePackSerializerOptions.Standard
.WithResolver(CompositeResolver.Create(
@ -54,33 +39,21 @@ public static class CultDocumentMessagePackSerialization
StandardResolver.Instance))
.WithSecurity(MessagePackSecurity.UntrustedData);
/// <summary>
/// Serializes a typed value with the CultCache MessagePack options.
/// </summary>
public static byte[] Serialize<T>(T value)
{
return MessagePackSerializer.Serialize(value, Options);
}
/// <summary>
/// Deserializes a typed value with the CultCache MessagePack options.
/// </summary>
public static T Deserialize<T>(byte[] payload)
{
return MessagePackSerializer.Deserialize<T>(payload, Options);
}
/// <summary>
/// Serializes a value whose document type is known at runtime.
/// </summary>
public static byte[] SerializeUntyped(object value, Type type)
{
return SerializeUntyped(value, type, CultDocumentRegistry.Shared);
}
/// <summary>
/// Serializes a value through an explicitly owned document registry.
/// </summary>
public static byte[] SerializeUntyped(object value, Type type, CultDocumentRegistry registry)
{
if (registry == null) throw new ArgumentNullException(nameof(registry));
@ -96,17 +69,11 @@ public static class CultDocumentMessagePackSerialization
return MessagePackSerializer.Serialize(type, value, Options);
}
/// <summary>
/// Deserializes a value whose document type is known at runtime.
/// </summary>
public static object DeserializeUntyped(Type type, byte[] payload)
{
return DeserializeUntyped(type, payload, CultDocumentRegistry.Shared);
}
/// <summary>
/// Deserializes a value through an explicitly owned document registry.
/// </summary>
public static object DeserializeUntyped(Type type, byte[] payload, CultDocumentRegistry registry)
{
if (registry == null) throw new ArgumentNullException(nameof(registry));
@ -120,9 +87,6 @@ public static class CultDocumentMessagePackSerialization
?? throw new InvalidOperationException($"MessagePack returned null for Cult document type {type.FullName}.");
}
/// <summary>
/// Serializes one persisted store record.
/// </summary>
public static byte[] SerializePersistedRecord(CultPersistedRecord record)
{
var buffer = new global::System.Buffers.ArrayBufferWriter<byte>();
@ -132,18 +96,12 @@ public static class CultDocumentMessagePackSerialization
return buffer.WrittenSpan.ToArray();
}
/// <summary>
/// Deserializes one persisted store record.
/// </summary>
public static CultPersistedRecord DeserializePersistedRecord(byte[] payload)
{
var reader = new MessagePackReader(payload);
return ReadPersistedRecord(ref reader);
}
/// <summary>
/// Serializes a complete persisted store snapshot.
/// </summary>
public static byte[] SerializeSnapshot(CultPersistedStoreSnapshot snapshot)
{
var buffer = new global::System.Buffers.ArrayBufferWriter<byte>();
@ -166,9 +124,6 @@ public static class CultDocumentMessagePackSerialization
return buffer.WrittenSpan.ToArray();
}
/// <summary>
/// Deserializes a complete persisted store snapshot.
/// </summary>
public static CultPersistedStoreSnapshot DeserializeSnapshot(byte[] payload)
{
var reader = new MessagePackReader(payload);
@ -396,45 +351,27 @@ public static class CultDocumentMessagePackSerialization
}
}
/// <summary>
/// Single-file CultCache backing store that persists snapshots as MessagePack.
/// </summary>
public class SingleFileMessagePackBackingStore : SingleFileBackingStore
{
/// <summary>
/// Creates a MessagePack single-file backing store.
/// </summary>
public SingleFileMessagePackBackingStore(string filePath) : base(filePath)
{
}
/// <summary>
/// Serializes a store snapshot.
/// </summary>
protected override byte[] SerializeSnapshot(CultPersistedStoreSnapshot snapshot)
{
return CultDocumentMessagePackSerialization.SerializeSnapshot(snapshot);
}
/// <summary>
/// Deserializes a store snapshot.
/// </summary>
protected override CultPersistedStoreSnapshot DeserializeSnapshot(byte[] data)
{
return CultDocumentMessagePackSerialization.DeserializeSnapshot(data);
}
/// <summary>
/// Serializes one document payload.
/// </summary>
protected override byte[] SerializePayload(object document)
{
return CultDocumentMessagePackSerialization.SerializeUntyped(document, document.GetType(), Registry);
}
/// <summary>
/// Deserializes one document payload.
/// </summary>
protected override object DeserializePayload(Type documentType, byte[] payload)
{
return CultDocumentMessagePackSerialization.DeserializeUntyped(documentType, payload, Registry);

View file

@ -3,22 +3,13 @@ using MessagePack.Formatters;
namespace GameCult.Caching;
/// <summary>
/// Serializes typed CultCache record references as their persisted key strings.
/// </summary>
public sealed class CultRecordRefFormatter<T> : IMessagePackFormatter<CultRecordRef<T>>
{
/// <summary>
/// Writes a typed record reference to MessagePack.
/// </summary>
public void Serialize(ref MessagePackWriter writer, CultRecordRef<T> value, MessagePackSerializerOptions options)
{
options.Resolver.GetFormatterWithVerify<string>().Serialize(ref writer, value.Key.Value, options);
}
/// <summary>
/// Reads a typed record reference from MessagePack.
/// </summary>
public CultRecordRef<T> Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
{
var key = options.Resolver.GetFormatterWithVerify<string>().Deserialize(ref reader, options) ?? string.Empty;

View file

@ -11,9 +11,6 @@ using MessagePack;
namespace GameCult.Caching.MessagePack;
/// <summary>
/// MessagePack backing store that keeps a small schema manifest hot and stores each record as its own cold file.
/// </summary>
public sealed class DirectoryMessagePackBackingStore : CacheBackingStore
{
private const string IndexedFormatVersion = "cultcache.store.v4.directory-content-addressed-pages";
@ -26,9 +23,6 @@ public sealed class DirectoryMessagePackBackingStore : CacheBackingStore
private Dictionary<string, CultPersistedRecord> _durableIndex = new(StringComparer.Ordinal);
private CultSchemaCatalogEntry[] _durableCatalog = Array.Empty<CultSchemaCatalogEntry>();
/// <summary>
/// Creates a paged MessagePack backing store.
/// </summary>
public DirectoryMessagePackBackingStore(string manifestPath, string? recordDirectoryPath = null)
{
if (string.IsNullOrWhiteSpace(manifestPath))
@ -40,12 +34,8 @@ public sealed class DirectoryMessagePackBackingStore : CacheBackingStore
_recordDirectory = new DirectoryInfo(recordDirectoryPath ?? DefaultRecordDirectoryPath(manifestPath));
}
/// <summary>
/// Gets the default record directory path for a manifest path.
/// </summary>
public static string DefaultRecordDirectoryPath(string manifestPath) => manifestPath + ".records";
/// <inheritdoc />
public override void PullAll()
{
lock (_mutationGate)
@ -120,14 +110,12 @@ public sealed class DirectoryMessagePackBackingStore : CacheBackingStore
Trace("publish");
}
/// <inheritdoc />
public override bool ContainsDurableRecord(CultRecordKey key)
{
lock (_mutationGate)
return _durableIndex.ContainsKey(key.Value) || base.ContainsDurableRecord(key);
}
/// <inheritdoc />
public override void Push(CultStoredDocument entry)
{
lock (_mutationGate)
@ -139,7 +127,6 @@ public sealed class DirectoryMessagePackBackingStore : CacheBackingStore
}
}
/// <inheritdoc />
public override void Delete(CultStoredDocument entry)
{
lock (_mutationGate)
@ -151,7 +138,6 @@ public sealed class DirectoryMessagePackBackingStore : CacheBackingStore
}
}
/// <inheritdoc />
public override void CommitBatch(
IReadOnlyCollection<CultStoredDocument> upserts,
IReadOnlyCollection<CultStoredDocument> deletes)
@ -196,7 +182,6 @@ public sealed class DirectoryMessagePackBackingStore : CacheBackingStore
}
}
/// <inheritdoc />
public override void PushAll()
{
lock (_mutationGate)

View file

@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>File-based MessagePack backing store for CultCache</Description>
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>
<ItemGroup>