ResolverClaim: a resolver returning MessagePack's standard formatter for an id-path type claims nothing
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
73b4b47451
commit
b0cc36bc7e
4 changed files with 181 additions and 5 deletions
|
|
@ -82,10 +82,17 @@ public static class CultDocumentMessagePackSerialization
|
|||
foreach (var type in CultElementIds.Inspect(documentType).IdPath)
|
||||
{
|
||||
var generic = GetFormatterMethod.MakeGenericMethod(type);
|
||||
// A resolver that hands back MessagePack's own formatter for the type writes its [Key] layout: that is no claim, and the
|
||||
// composite stops there, so no later resolver is asked.
|
||||
var standard = generic.Invoke(StandardResolver.Instance, null);
|
||||
foreach (var resolver in ahead)
|
||||
{
|
||||
if (generic.Invoke(resolver, null) != null)
|
||||
return $"Cult document {documentType.Name}: formatter resolver {resolver.GetType().FullName} formats {type.Name}, which is on the path to a list whose elements carry ids, so its element ids would never reach disk. A resolver may not claim such a type; write it by its [Key] layout or keep it out of the document's lists.";
|
||||
var formatter = generic.Invoke(resolver, null);
|
||||
if (formatter == null)
|
||||
continue;
|
||||
if (ReferenceEquals(formatter, standard))
|
||||
break;
|
||||
return $"Cult document {documentType.Name}: formatter resolver {resolver.GetType().FullName} formats {type.Name}, which is on the path to a list whose elements carry ids, so its element ids would never reach disk. A resolver may not claim such a type; write it by its [Key] layout or keep it out of the document's lists.";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -295,9 +295,13 @@ exclusive open of the same lock file exclude each other is not established.
|
|||
- An assembly that declares nothing, and the store envelope, use the base
|
||||
options.
|
||||
- A resolver may not claim a type a document's element lists pass through: the list's
|
||||
element types, the types and members on the way to them. Those are written by their
|
||||
`[Key]` layout so each element's id reaches disk, and the codec refuses the document
|
||||
on first encode or decode, naming the resolver and the type.
|
||||
element types, the types and members on the way to them, and the collection types
|
||||
the walk passes (`List<T>`, `T[]`, a collection class, a dictionary on the way).
|
||||
Those are written by their `[Key]` layout so each element's id reaches disk, and the
|
||||
codec refuses the document on first encode or decode, naming the resolver and the
|
||||
type. A resolver that returns MessagePack's standard formatter for a type does not
|
||||
claim it. A value list (`List<float2>`, a list of a non-keyed class) is not on the
|
||||
path, so a resolver may claim it.
|
||||
- Deserialization runs under untrusted-data security. `CultRecordRef<T>` is a
|
||||
permitted dictionary key, compared by its key string.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue