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:
parent
956c077a1a
commit
48d3f667e6
3 changed files with 38 additions and 6 deletions
|
|
@ -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 };
|
||||
|
|
|
|||
|
|
@ -607,7 +607,7 @@ namespace GameCult.Caching
|
|||
internal static bool WalksAsOwner(Type type) => Classify(Nullable.GetUnderlyingType(type) ?? type).Kind == Kind.Owner;
|
||||
|
||||
private static bool EnumeratesObjects(Type type) =>
|
||||
(ElementTypeOf(type) ?? MapTypes(type)?.Value) is { } inner && Classify(inner).Kind != Kind.Leaf;
|
||||
(MapTypes(type)?.Value ?? ElementTypeOf(type)) is { } inner && Classify(inner).Kind != Kind.Leaf;
|
||||
|
||||
private static int? KeyOf(MemberInfo member) => member.GetCustomAttribute<KeyAttribute>(true)?.IntKey;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue