Resolve C# snapshot filters by schema alias

This commit is contained in:
Meta Vens 2026-06-27 21:37:03 +01:00
commit 4dfa9a6162
3 changed files with 128 additions and 6 deletions

View file

@ -280,12 +280,9 @@ namespace GameCult.Networking
value => CultDocumentMessagePackSerialization.SerializeUntyped(value, value.GetType()),
payload => CultDocumentMessagePackSerialization.DeserializeUntyped(document.GetType(), payload));
if (requestedSchemaIds != null && !requestedSchemaIds.Contains(descriptor.SchemaId))
if (requestedSchemaIds != null && !MatchesRequestedSchema(descriptor, binding, requestedSchemaIds))
{
if (!requestedSchemaIds.Contains(binding.SchemaId))
{
continue;
}
continue;
}
var handleMethod = typeof(CultCache)
@ -438,6 +435,27 @@ namespace GameCult.Networking
.Select(group => group.First());
}
private static bool MatchesRequestedSchema(
CultDocumentDescriptor descriptor,
CultNetDocumentBinding binding,
ISet<string> requestedSchemaIds)
{
if (requestedSchemaIds.Count == 0)
return true;
if (requestedSchemaIds.Contains(descriptor.SchemaId) ||
requestedSchemaIds.Contains(binding.SchemaId))
return true;
if (descriptor.ToCatalogEntry().CompatibleSchemaIds.Any(requestedSchemaIds.Contains))
return true;
return requestedSchemaIds
.Select(InferSchemaName)
.Where(schemaName => !string.IsNullOrWhiteSpace(schemaName))
.Any(schemaName => string.Equals(schemaName, descriptor.SchemaName, StringComparison.Ordinal));
}
private static string? TryReadSchemaVersion(byte[] payload)
{
try