Replies: 1 comment
-
Possibly a case of issue #75866 e.g. where does _parser.Offset come from? The workaround is that issue: #75866 (comment) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I have a case where (.NET 5.0.400) I am getting different result when I call:
readResult.Buffer.Length
vsreadResult.Buffer.GetOffset(readResult.Buffer.End)
readResult was retrieved using System.IO.Pipeline.Pipe:
var readResult = pipe.Reader.ReadAsync(...);
Maybe important, I am using the following code to advance:
pipe.Reader.AdvanceTo(readResult.Buffer.GetPosition(_parser.Offset), readResult.Buffer.End);
where parser.offset is the number of bytes I successfully processed (i.e. if I received only part of the row, I can't process it).
I am sending End as a second parameter because I want to wait until something was actually pushed into the pipe, before reading it again.
First loop is working fine.
Parser offset: 1046287 Buffer length: 1048576 Buffer end offset: 1048576 so 2289 are left unprocessed.
After calling pipe.Reader.ReadAsync(...) again, the situation is "different" than I would expect:
Buffer length: 133361 Buffer end offset: 1179648
So the question is, how is it possible that buffer length (which should be total number of bytes in ReadOnlySequence is NOT EQUAL than the offset position of ReadOnlySequence END? Moreover it is drastically smaller.
Which part am I misunderstanding? It seems like
readResult.Buffer.GetOffset(readResult.Buffer.End
is returning size of the underlying memory buffer? I am assuming that this is not a bug, but a regular behavior - and that I am missing something - hence opening a discussion instead of an issue.Screenshot from VS which shows the difference in size after calling ReadAsync the second time:

Tnx
Beta Was this translation helpful? Give feedback.
All reactions