Add span-based CopyTo and CopyToAsync methods (dotnet/coreclr#27639)
authorEmmanuel André <2341261+manandre@users.noreply.github.com>
Wed, 13 Nov 2019 19:47:18 +0000 (20:47 +0100)
committerStephen Toub <stoub@microsoft.com>
Wed, 13 Nov 2019 19:47:18 +0000 (14:47 -0500)
commit7dd7430eefcffcd114b7111498a815e367970db4
tree999831fb41e79285a5cac080a19b26e91b746f9e
parent5310fb5090d2ccd9ac36cdc835a54e7a18c2cf63
Add span-based CopyTo and CopyToAsync methods (dotnet/coreclr#27639)

* Add span-based CopyTo and CopyToAsync methods

* Update according to feedback

* Add span-based CopyTo overrides for MemoryStream

* Improve span-based CopyTo arguments validation

To avoid code duplication

* Update according to second review

Stream API is changed

* Resolve InternalReadSpan/Memory inlining

* Refactor ValidateCopyToArgs

* Update according to third review

* Update after fourth review

* Override span CopyTo for UnmanagedMemoryStream

* Apply suggestions from code review

Co-Authored-By: Stephen Toub <stoub@microsoft.com>
* Update after fifth review

* Add cross sync/async support for span-based CopyTo

* Call sync action directly in async context

* Rework cross sync/async support for span-based CopyTo

Co-Authored-By: Stephen Toub <stoub@microsoft.com>
Commit migrated from https://github.com/dotnet/coreclr/commit/6abc099d4a798dc9a267d04bc025efbcbf148473
src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs
src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs
src/libraries/System.Private.CoreLib/src/System/IO/StreamHelpers.CopyValidation.cs
src/libraries/System.Private.CoreLib/src/System/IO/UnmanagedMemoryStream.cs