Implement TranscodingStream, a streaming equivalent of Encoding.Convert#35145
Merged
GrabYourPitchforks merged 6 commits intodotnet:masterfrom Apr 30, 2020
Merged
Conversation
Collaborator
|
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
|
Tagging subscribers to this area: @tarekgh |
Member
Author
|
And yes, I know I have array pool rentals inside a try / finally block. This follows the pattern already established by |
Member
Author
rynowak
reviewed
Apr 17, 2020
7a363e1 to
1155286
Compare
stephentoub
approved these changes
Apr 18, 2020
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/TranscodingStream.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/TranscodingStream.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/TranscodingStream.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/TranscodingStream.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/TranscodingStream.cs
Outdated
Show resolved
Hide resolved
pranavkm
approved these changes
Apr 20, 2020
src/libraries/System.Text.Encoding/tests/Encoding/TranscodingStreamTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/TranscodingStream.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/TranscodingStream.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/TranscodingStream.cs
Show resolved
Hide resolved
src/libraries/System.Text.Encoding/tests/Encoding/TranscodingStreamTests.cs
Show resolved
Hide resolved
jozkee
approved these changes
Apr 27, 2020
Member
jozkee
left a comment
There was a problem hiding this comment.
Thanks for updating System.Net.Http.Json as well.
src/libraries/System.Private.CoreLib/src/System/Text/TranscodingStream.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/TranscodingStream.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/TranscodingStream.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/TranscodingStream.cs
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #30260.
The general idea is that if you have an inner
Streamwhich represents machine-readable text under one encoding (say, shift-jis), this allows creating a wrappingStreamwhich represents that same machine-readable text under a different encoding (say, UTF-8). The primary scenario for this is as an adapter where you have System.Text.Json (as UTF-8) working on the outerStreambut where the client needs the response payload in a different encoding.Usage (showing writing)
Note: When writing, the call to
Stream.Close/Stream.Dispose/Stream.DisposeAsyncis the thing that flushes the underlyingEncoder/Decoderinstances. This shouldn't normally matter as long as the caller isn't trying to write ill-formed data to the outerStream. But if the caller does emit an incomplete multi-byte sequence (say, the UTF-8 bytes[ E0 BF ]) at the end of the stream, the fallback mechanism won't be invoked until the outer stream is disposed.