From 686b32831bc5c141aacdad851aeaca4f48d1e04d Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 14 Oct 2026 04:31:52 +0200 Subject: [PATCH] GameCult.Thing.Contract: Present refuses the default byte view, not every unbacked empty one MemoryMarshal.TryGetArray answers true for any empty view, so it cannot tell nil from empty; equality with default can. The commit before this fails the new payload test. Co-Authored-By: Claude Opus 5.5 --- packages/GameCult.Thing.Contract/Domain.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/GameCult.Thing.Contract/Domain.cs b/packages/GameCult.Thing.Contract/Domain.cs index 0239cfe..77c0700 100644 --- a/packages/GameCult.Thing.Contract/Domain.cs +++ b/packages/GameCult.Thing.Contract/Domain.cs @@ -50,11 +50,11 @@ public static class ThingDomain value ?? throw new ThingDomainException(slot, "present"); /// - /// A required byte slot. A null on the wire decodes to a default view with no backing store, so a view that is - /// empty and backed by nothing is refused as nil; an empty array is a present, empty payload. + /// A required byte slot. A null on the wire decodes to a default view with no backing store, so the default view is + /// refused as nil; an empty array is a present, empty payload. /// public static ReadOnlyMemory Present(ReadOnlyMemory value, string slot) => - value.IsEmpty && !System.Runtime.InteropServices.MemoryMarshal.TryGetArray(value, out _) + value.Equals(default(ReadOnlyMemory)) ? throw new ThingDomainException(slot, "present") : value;