You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[API Proposal]: Add ReadOnlySequence overload for WriteRawValue #68223
When using the Utf8JsonWriter.WriteRawValue API, you can't pass multiple segments in to write a single value, you have to allocate a contiguous array and do a single call to WriteRawValue. In our use case we already have a ReadOnlySequence<byte> and want to write it as a raw json value.
But because the API only accepts string or span, we need to write the following:
There isn't an implicit conversion from a string to a ReadOnlySequence<char> so the [StringSyntax(StringSyntaxAttribute.Json)] is not needed. And you forgot an issue title. 😅
Suggestion looks good to me as proposed, although we unlikely will have time to do it in this release, marking as 8.0.0 so it's on our radar for vNext.
We don't want to add the overload ReadOnlySequence<char> because we'd have to deal with transcoding surrogate pairs across elements in the sequence, which is quite a bit of work that nobody seems to be asking for right now.
Hi, I would try to add this API by this PR, could you please review?
Also, I modified parameter name from json to utf8Json because it is for byte version rather than char (string), which seems being followed by existing overloads.
Correct me, thanks !
public void WriteRawValue(ReadOnlySequence{byte} utf8Json, bool skipInputValidation = false);
Also, I modified parameter name from json to utf8Json because it is for byte version rather than char (string), which seems being followed by existing overloads.
Change sounds reasonable to me, thanks for correcting it.
Activity
teo-tsirpanis commentedon Apr 19, 2022
There isn't an implicit conversion from a string to a
ReadOnlySequence<char>so the[StringSyntax(StringSyntaxAttribute.Json)]is not needed. And you forgot an issue title. 😅BrennanConroy commentedon Apr 19, 2022
Haha, I was too focused on filling out the API template!
[-][API Proposal]: [/-][+][API Proposal]: Add ReadOnlySequence overload for WriteRawValue[/+]krwq commentedon Jun 7, 2022
Suggestion looks good to me as proposed, although we unlikely will have time to do it in this release, marking as 8.0.0 so it's on our radar for vNext.
terrajobst commentedon Aug 16, 2022
Video
ReadOnlySequence<char>because we'd have to deal with transcoding surrogate pairs across elements in the sequence, which is quite a bit of work that nobody seems to be asking for right now.lateapexearlyspeed commentedon Sep 30, 2022
Hi, I would try to add this API by this PR, could you please review?
Also, I modified parameter name from
jsontoutf8Jsonbecause it is for byte version rather than char (string), which seems being followed by existing overloads.Correct me, thanks !
eiriktsarpalis commentedon Sep 30, 2022
Change sounds reasonable to me, thanks for correcting it.