Skip to content
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

Implement WriteStringValueSegment defined in Issue 67337 #101356

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9122ef8
Implement WriteStringValueSegment defined in Issue 67337
ificator Apr 21, 2024
e044b13
Fix some review comments
ificator May 26, 2024
e7abe7f
merge upstream/main
ificator May 26, 2024
b8d578c
Handle split surrogate pair
ificator May 26, 2024
181cef2
Merge remote-tracking branch 'upstream/main' into user/ificator/write…
ificator Dec 6, 2024
65006ce
Commit old changes responding to comments
ificator Dec 6, 2024
1601af8
utf8 and utf16
PranavSenthilnathan Dec 11, 2024
d6b66be
fix build error
PranavSenthilnathan Dec 16, 2024
a46a1cc
Update src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf…
PranavSenthilnathan Dec 16, 2024
b5d0c17
Update src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf…
PranavSenthilnathan Dec 16, 2024
4a0d1c6
PR comments
PranavSenthilnathan Dec 16, 2024
09d321d
Merge branch 'main' of https://github.com/dotnet/runtime into user/if…
PranavSenthilnathan Dec 16, 2024
96ed922
add encoding flags
PranavSenthilnathan Dec 17, 2024
a078bfd
add test for switching encoding
PranavSenthilnathan Dec 17, 2024
93e6ee9
use CoreLib Rune for polyfill instead of having a separate copy
PranavSenthilnathan Dec 17, 2024
501813f
Merge branch 'main' of https://github.com/dotnet/runtime into user/if…
PranavSenthilnathan Dec 17, 2024
c3b1c3b
move warning disabling to top and fix up tests
PranavSenthilnathan Dec 18, 2024
c9c4884
add fuzzer
PranavSenthilnathan Dec 19, 2024
8482b1c
Fix some tests I missed
PranavSenthilnathan Dec 19, 2024
d50bbca
clean up and add another test to fuzzer
PranavSenthilnathan Dec 19, 2024
55827d9
comment typo
PranavSenthilnathan Dec 20, 2024
a5cd855
pr comments
PranavSenthilnathan Dec 20, 2024
c82b035
Merge branch 'main' of https://github.com/dotnet/runtime into user/if…
PranavSenthilnathan Dec 20, 2024
4f63907
Merge branch 'user/ificator/writestringvaluesegment' of https://githu…
PranavSenthilnathan Dec 20, 2024
b7fd4a5
throw when encodings are mixed
PranavSenthilnathan Dec 24, 2024
c0a700c
update fuzzer to assert that mixing encodings always throws
PranavSenthilnathan Dec 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libraries/System.Text.Json/ref/System.Text.Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ public enum JsonTokenType : byte
True = (byte)9,
False = (byte)10,
Null = (byte)11,
StringSegment = (byte)12,
}
public enum JsonValueKind : byte
{
Expand Down Expand Up @@ -652,6 +653,10 @@ public void WriteStringValue(System.ReadOnlySpan<byte> utf8Value) { }
public void WriteStringValue(System.ReadOnlySpan<char> value) { }
public void WriteStringValue(string? value) { }
public void WriteStringValue(System.Text.Json.JsonEncodedText value) { }
public void WriteStringValueSegment(System.ReadOnlySpan<byte> utf8Value, bool isFinalSegment) { }
public void WriteStringValueSegment(ReadOnlySpan<char> value, bool isFinalSegment) { }
public void WriteStringValueSegment(string? value, bool isFinalSegment) { }
public void WriteStringValueSegment(System.Text.Json.JsonEncodedText value, bool isFinalSegment) { }
ificator marked this conversation as resolved.
Show resolved Hide resolved
}
}
namespace System.Text.Json.Nodes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,14 @@ public enum JsonTokenType : byte
/// Indicates that the token type is the JSON literal <c>null</c>.
/// </summary>
Null,

/// <summary>
/// Indicates that the token type is a segment of a JSON string.
/// </summary>
/// <remarks>
/// This does not represent a token defined in the JSON specification, but rather provides a means to track
/// that a string is being written in segments. This value will never be seen during deserialization.
/// </remarks>
StringSegment,
ificator marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private void ValidateWritingProperty()
{
if (!_options.SkipValidation)
{
if (!_inObject || _tokenType == JsonTokenType.PropertyName)
if (!_inObject || _tokenType == JsonTokenType.PropertyName || _tokenType == JsonTokenType.StringSegment)
ificator marked this conversation as resolved.
Show resolved Hide resolved
{
Debug.Assert(_tokenType != JsonTokenType.StartObject);
ThrowHelper.ThrowInvalidOperationException(ExceptionResource.CannotWritePropertyWithinArray, currentDepth: default, maxDepth: _options.MaxDepth, token: default, _tokenType);
Expand All @@ -49,7 +49,7 @@ private void ValidateWritingProperty(byte token)
{
if (!_options.SkipValidation)
{
if (!_inObject || _tokenType == JsonTokenType.PropertyName)
if (!_inObject || _tokenType == JsonTokenType.PropertyName || _tokenType == JsonTokenType.StringSegment)
{
Debug.Assert(_tokenType != JsonTokenType.StartObject);
ThrowHelper.ThrowInvalidOperationException(ExceptionResource.CannotWritePropertyWithinArray, currentDepth: default, maxDepth: _options.MaxDepth, token: default, _tokenType);
Expand Down
Loading
Loading