public void WriteValue <T>(T value)
        {
            var isPrimitive = PrimitiveTypes.Primitives.Contains(typeof(T));
            var sizeOf      = isPrimitive ? _sizing.SizeOf <T>() : _sizing.SizeOf(value);

            if (Remaining < sizeOf)
            {
                throw new ArgumentOutOfRangeException(nameof(Remaining),
                                                      $"Not enough bytes remaining in the buffer to write {typeof(T).Name}. " +
                                                      $"Position : {Position}, Length : {Count}, Remaining : {Remaining}, SizeOf : {sizeOf}.");
            }

            if (!isPrimitive)
            {
                BinaryCache <T> .WriteValue(this, value);

                return;
            }

            var dst = _bufferOwner.Memory.Slice(Position, sizeOf);

            PrimitiveBinaryCache <T> .WriteValue(dst.Span, value);

            Advance(sizeOf);
        }
 [Fact] public void CreateCompiled_ShouldHandlePrimitiveValues()
 => Assert.Equal(SizeOfPrimitive, Sizing.SizeOf(new Primitive()));
        public void SizeOfTWithVal_ShouldSizeString()
        {
            const string value = "four";

            Assert.Equal(8, Sizing.SizeOf(value));
        }