public override int Read(Span <char> buffer) { int writtenCount, result = 0; if (charPos < charLen) { ReadyToReadChars.CopyTo(buffer, out writtenCount); charPos += writtenCount; buffer = buffer.Slice(writtenCount); result += writtenCount; } while (!buffer.IsEmpty) { writtenCount = ReadBuffer(buffer); if (writtenCount == 0) { break; } buffer = buffer.Slice(writtenCount); result += writtenCount; } return(result); }