-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReadOnlySequence<byte>.PositionOf Error #102457
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/area-system-buffers |
Could this be a duplicate of #75866? |
Maybe, use ReadOnlySequence.GetOffset(point) value does not change after the ReadOnlySequence.Slice method is called. string name = "name:henryfan\r";
ReadOnlySequence<byte> sequence = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(name));
var point = sequence.PositionOf((byte)'\r');
var index = sequence.GetOffset(point.Value);//return 13 right
sequence = sequence.Slice(2);
point = sequence.PositionOf((byte)'\r');
index = sequence.GetOffset(point.Value);//return 13 wrong |
Yes, duplicate of #75866. |
ReadOnlySequence.PositionOf fun return index larger than array length?
Test code:
Debug info:
![image](https://private-user-images.githubusercontent.com/2564178/332107592-df436246-293c-4d75-a8e2-7c32988765ed.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MzMxOTksIm5iZiI6MTczOTYzMjg5OSwicGF0aCI6Ii8yNTY0MTc4LzMzMjEwNzU5Mi1kZjQzNjI0Ni0yOTNjLTRkNzUtYThlMi03YzMyOTg4NzY1ZWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTVUMTUyMTM5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDhmYzM0ZmFjNzlkZTVlZjg2ZGUyODQyYTA0NDk1ZGViNGIzMmZiNWRkZjk1ZWYxZGM0M2U2ZTQ5ZmFhYTMwOSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.MboMCg4WzZREVWc6cKWBAj1IDt2DwECMSwsaP1G1sdU)
The text was updated successfully, but these errors were encountered: