From 26159f9cfa4c3c5b4abd5c7d34076d13a9d1009e Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 27 Jun 2026 22:16:26 +0100 Subject: [PATCH] Index C# document catalogs by schema id --- src/GameCult.Mesh/CultMeshPrimitives.cs | 9 +++++++-- tests/GameCult.Mesh.Tests/CultMeshStreamingTests.cs | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/GameCult.Mesh/CultMeshPrimitives.cs b/src/GameCult.Mesh/CultMeshPrimitives.cs index 70ab2737..f45a9ae8 100644 --- a/src/GameCult.Mesh/CultMeshPrimitives.cs +++ b/src/GameCult.Mesh/CultMeshPrimitives.cs @@ -892,6 +892,9 @@ namespace GameCult.Mesh /// Gets the stable CultCache schema version. string SchemaVersion { get; } + /// Gets the content-derived schema identifier. + string SchemaId { get; } + /// Gets the preferred or observed route for document access. CultMeshRouteHint RouteHint { get; } @@ -1577,6 +1580,8 @@ namespace GameCult.Mesh foreach (var document in documentList) { byType[document.DocumentType] = document; + if (!string.IsNullOrWhiteSpace(document.SchemaId)) + bySchema[document.SchemaId] = document; if (!string.IsNullOrWhiteSpace(document.SchemaVersion)) bySchema[document.SchemaVersion] = document; if (!string.IsNullOrWhiteSpace(document.SchemaName)) @@ -1591,7 +1596,7 @@ namespace GameCult.Mesh /// Gets the handles in this catalog. public IReadOnlyList Documents => _documents; - /// Looks up a document handle by shared schema name or schema version. + /// Looks up a document handle by schema id, shared schema name, or schema version. public bool TryGetDocumentBySchema( string schema, out ICultMeshDocumentHandle document) @@ -1606,7 +1611,7 @@ namespace GameCult.Mesh return false; } - /// Looks up a document handle by shared schema name or schema version. + /// Looks up a document handle by schema id, shared schema name, or schema version. public ICultMeshDocumentHandle DocumentBySchema(string schema) { if (TryGetDocumentBySchema(schema, out var document)) diff --git a/tests/GameCult.Mesh.Tests/CultMeshStreamingTests.cs b/tests/GameCult.Mesh.Tests/CultMeshStreamingTests.cs index 205789a9..3d4e3c04 100644 --- a/tests/GameCult.Mesh.Tests/CultMeshStreamingTests.cs +++ b/tests/GameCult.Mesh.Tests/CultMeshStreamingTests.cs @@ -724,6 +724,9 @@ public sealed class CultMeshStreamingTests catalog.TryGetDocumentBySchema("tests.mesh_note.v1", out var byVersion).Should().BeTrue(); byVersion.Should().BeSameAs(handle); catalog.DocumentBySchema("tests.mesh_note").Should().BeSameAs(handle); + catalog.DocumentBySchema(CultDocumentRegistry.Shared.GetRequired().SchemaId) + .Should() + .BeSameAs(handle); catalog.TryGetDocument(out var alias).Should().BeTrue(); alias.DocumentId.Should().Be(handle.DocumentId);