[release/6.0-rc1] Fixed StreamPipeReader.CopyToAsync (#57966)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Tue, 24 Aug 2021 16:17:36 +0000 (10:17 -0600)
committerGitHub <noreply@github.com>
Tue, 24 Aug 2021 16:17:36 +0000 (10:17 -0600)
commit2170911873dd5712afa7b9b94b7a43f06722d9e4
treed1e44c3e86f9a962465cfdbb4314e286cc1997ae
parent0e4a871887a7f765c42dbf81512cc1af63d7ccc7
[release/6.0-rc1] Fixed StreamPipeReader.CopyToAsync (#57966)

* Fixed StreamPipeReader.CopyToAsync - Take the segment index into account when copying buffered data. This handles the case where ReadAsync has consumed a partial segment and then the same PipeReader instance is used to copy to a Stream and PipeWriter. - Added tests

* Always slice

Co-authored-by: David Fowler <davidfowl@gmail.com>
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/StreamPipeReader.cs
src/libraries/System.IO.Pipelines/tests/PipeReaderCopyToAsyncTests.cs