I'm puzzled by the fact that PipeReader.AdvanceTo accepts a default(SequencePosition) but throws InvalidCastException when provided a position from an empty sequence. Is that by design?
var pipe = new Pipe();
pipe.Reader.AdvanceTo(default); // this works
pipe.Reader.AdvanceTo(ReadOnlySequence<byte>.Empty.Start); // this throws InvalidCastException
Should it throw ArgumentException instead given the SequencePosition came from an unrelated ReadOnlySequence<byte>?
I'm a bit puzzled that PipeReader.AdvanceTo can be called before reading anyway.
I'm puzzled by the fact that
PipeReader.AdvanceToaccepts adefault(SequencePosition)but throwsInvalidCastExceptionwhen provided a position from an empty sequence. Is that by design?Should it throw
ArgumentExceptioninstead given theSequencePositioncame from an unrelatedReadOnlySequence<byte>?I'm a bit puzzled that
PipeReader.AdvanceTocan be called before reading anyway.