public void Advance()

in src/RecyclableMemoryStream.cs [630:664]


        public void Advance(int count)
        {
            this.CheckDisposed();
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count), $"{nameof(count)} must be non-negative.");
            }

            byte[] buffer = this.bufferWriterTempBuffer;
            if (buffer != null)
            {
                if (count > buffer.Length)
                {
                    throw new InvalidOperationException($"Cannot advance past the end of the buffer, which has a size of {buffer.Length}.");
                }

                this.Write(buffer, 0, count);
                this.ReturnTempBuffer(buffer);
                this.bufferWriterTempBuffer = null;
            }
            else
            {
                long bufferSize = this.largeBuffer == null
                    ? this.memoryManager.BlockSize - this.GetBlockAndRelativeOffset(this.position).Offset
                    : this.largeBuffer.Length - this.position;

                if (count > bufferSize)
                {
                    throw new InvalidOperationException($"Cannot advance past the end of the buffer, which has a size of {bufferSize}.");
                }

                this.position += count;
                this.length = Math.Max(this.position, this.length);
            }
        }