Element ids: a keyed map counts as enumerating objects; family check tests assert the exact refusal

EnumeratesObjects took ElementTypeOf first, which for a dictionary is the
KeyValuePair (a leaf), so a keyed Dictionary subclass never reached the path; the
map's value type is asked first. The unreachable null-standard guard in
WrittenAsWalked is removed. Tests pin the direction and wording of the refusal, the
attribute-formatter collection case and the unwrapped inner exception.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-15 03:09:39 +02:00
commit 48d3f667e6
3 changed files with 38 additions and 6 deletions

View file

@ -149,8 +149,6 @@ public static class CultDocumentMessagePackSerialization
// collection resolver; a keyed class that is also an ICollection<T> is written as a collection and its [Key] layout dropped.
private static bool WrittenAsWalked(Type type, MethodInfo generic, object? standard)
{
if (standard == null)
return true;
var families = CultElementIds.WalksAsOwner(type)
? new IFormatterResolver[] { DynamicUnionResolver.Instance, DynamicObjectResolver.Instance }
: new IFormatterResolver[] { DynamicGenericResolver.Instance, ImmutableCollectionResolver.Instance, BuiltinResolver.Instance };