anchor.diff:  type ByteArrayMemory(bytes: byte[], offset, length) =
       inherit ByteMemory()
   
  +    let checkCount count =
  +        if count < 0 then
  +            raise (ArgumentOutOfRangeException("count", "Count is less than zero."))
  +
       do
           if length < 0 || length > bytes.Length then
               raise (ArgumentOutOfRangeException("length"))
  
positive.code:     let check i =
          if i < 0 || i >= length then 
              raise (ArgumentOutOfRangeException("i"))
  
      do
          if length < 0 then
  
negative.code:         uint16(Marshal.ReadInt16(NativePtr.toNativeInt addr + nativeint pos))
  
      override _.Slice(pos, count) =
          checkCount count
          if count > 0 then
              check pos
              check (pos + count - 1)
              RawByteMemory(NativePtr.add addr pos, count, holder) :> ByteMemory
          else
              ByteArrayMemory(Array.empty, 0, 0) :> ByteMemory
  
      override x.CopyTo stream =
          if length > 0 then
              use stream2 = x.AsStream()
              stream2.CopyTo stream
  
      override _.Copy(srcOffset, dest, destOffset, count) =
          checkCount count
          if count > 0 then
              check srcOffset
              Marshal.Copy(NativePtr.toNativeInt addr + nativeint srcOffset, dest, destOffset, count)
  
      override _.ToArray() =
          if length > 0 then
              let res = Array.zeroCreate<byte> length
              Marshal.Copy(NativePtr.toNativeInt addr, res, 0, res.Length)
              res
          else
              Array.empty
  
      override _.AsStream() =
          if length > 0 then
              new SafeUnmanagedMemoryStream(addr, int64 length, holder) :> Stream
          else
              new MemoryStream([||], 0, 0, false) :> Stream
  
      override _.AsReadOnlyStream() =
          if length > 0 then
              new SafeUnmanagedMemoryStream(addr, int64 length, int64 length, FileAccess.Read, holder) :> Stream
          else
              new MemoryStream([||], 0, 0, false) :> Stream
  
  [<Struct;NoEquality;NoComparison>]
  type ReadOnlyByteMemory(bytes: ByteMemory) =
  