UnionArmGuardTests: a later resolver's claim on a type the standard formatter already answered is never asked
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9eb43be7f1
commit
c9c96642e8
2 changed files with 21 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ using MessagePack.Formatters;
|
|||
[assembly: CultCacheFormatterResolver(typeof(UnionArmGuardTests.ClaimArmResolver))]
|
||||
[assembly: CultCacheFormatterResolver(typeof(UnionArmGuardTests.OrderResolver))]
|
||||
[assembly: CultCacheFormatterResolver(typeof(UnionArmGuardTests.ListClaimResolver))]
|
||||
[assembly: CultCacheFormatterResolver(typeof(UnionArmGuardTests.FbLaterClaimResolver))]
|
||||
|
||||
namespace GameCult.Caching.Tests
|
||||
{
|
||||
|
|
|
|||
|
|
@ -454,6 +454,26 @@ namespace GameCult.Caching.Tests
|
|||
}
|
||||
}
|
||||
|
||||
// Composed after ListClaimResolver: once that resolver has answered FbArm with the standard formatter the composite never
|
||||
// asks this one, so its claim on the same type must not refuse the document.
|
||||
public sealed class FbLaterClaimResolver : IFormatterResolver
|
||||
{
|
||||
public static readonly IFormatterResolver Instance = new FbLaterClaimResolver();
|
||||
|
||||
public IMessagePackFormatter<T>? GetFormatter<T>() => typeof(T) == typeof(FbArm) ? (IMessagePackFormatter<T>)(object)new LaterFormatter() : null;
|
||||
|
||||
private sealed class LaterFormatter : IMessagePackFormatter<FbArm>
|
||||
{
|
||||
public void Serialize(ref MessagePackWriter writer, FbArm value, MessagePackSerializerOptions options) => writer.WriteNil();
|
||||
|
||||
public FbArm Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
reader.Skip();
|
||||
return new FbArm();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OptionsRefuseANullDocumentTypeOrAssembly()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue