-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add Utf8JsonWriter along with unit tests #34425
Changes from all commits
aeb2103
76a459b
f1eae6f
0e1a283
fd8bd6d
39fc64d
41b7b2c
7988444
8276f4c
9bec478
5385574
a9f99be
65b38cb
8d62b8a
c4fc141
534ebf2
424835a
1c09b09
a91c702
f1cdc28
baa5ac2
644118c
baa4931
2b91e6c
6c43954
eb33db6
171f6c3
a14a57e
712502b
3bc364c
56382db
2900bc5
6f41164
c3c83e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,20 @@ public enum JsonTokenType : byte | |
| String = (byte)6, | ||
| True = (byte)8, | ||
| } | ||
| public partial struct JsonWriterOptions | ||
| { | ||
| private object _dummy; | ||
| public bool Indented { get { throw null; } set { } } | ||
| public bool SkipValidation { get { throw null; } set { } } | ||
| } | ||
| public partial struct JsonWriterState | ||
| { | ||
| private object _dummy; | ||
| public JsonWriterState(System.Text.Json.JsonWriterOptions options = default(System.Text.Json.JsonWriterOptions)) { throw null; } | ||
| public long BytesCommitted { get { throw null; } } | ||
| public long BytesWritten { get { throw null; } } | ||
| public System.Text.Json.JsonWriterOptions Options { get { throw null; } } | ||
| } | ||
| public ref partial struct Utf8JsonReader | ||
| { | ||
| private object _dummy; | ||
|
|
@@ -71,4 +85,95 @@ public ref partial struct Utf8JsonReader | |
| public bool TryGetInt64Value(out long value) { throw null; } | ||
| public bool TryGetSingleValue(out float value) { throw null; } | ||
| } | ||
| public ref partial struct Utf8JsonWriter | ||
| { | ||
| private object _dummy; | ||
| public Utf8JsonWriter(System.Buffers.IBufferWriter<byte> bufferWriter, System.Text.Json.JsonWriterState state = default(System.Text.Json.JsonWriterState)) { throw null; } | ||
| public long BytesCommitted { get { throw null; } } | ||
| public long BytesWritten { get { throw null; } } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these commonly accessed on the writer? Wondering when you'd use these rather than getting the CurrentState and using its BytesCommitted/Written.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I can see them being useful if the user is doing synchronous writing and wants to get how much has been written so far. For that pattern, the user never really has to deal with state, so forcing them to call state to get meaningful data that the writer already tracks seems unnecessary. For example, @KrzysztofCwalina needs it for his scenario: https://github.com/Azure/azure-sdk-for-net-lab/blob/4d8369fe96e99514c108dacb2cd39bc589b0042a/Configuration/Azure.Configuration/ConfigurationSettingParser.cs#L30 With the change from #34425 (comment), BytesCommitted == BytesWritten when you access them on the CurrentState (since it forces you to flush). If the user wants to know the difference between how much has been written versus committed so far (without flushing). they would need the properties on Utf8JsonWriter. We could remove one of BytesCommitted or BytesWritten from the CurrentState though. |
||
| public int CurrentDepth { get { throw null; } } | ||
| public void Flush(bool isFinalBlock = true) { } | ||
| public System.Text.Json.JsonWriterState GetCurrentState() { throw null; } | ||
| public void WriteBoolean(System.ReadOnlySpan<byte> utf8PropertyName, bool value, bool escape = true) { } | ||
| public void WriteBoolean(System.ReadOnlySpan<char> propertyName, bool value, bool escape = true) { } | ||
| public void WriteBoolean(string propertyName, bool value, bool escape = true) { } | ||
| public void WriteBooleanValue(bool value) { } | ||
| public void WriteCommentValue(System.ReadOnlySpan<byte> utf8Value, bool escape = true) { } | ||
| public void WriteCommentValue(System.ReadOnlySpan<char> value, bool escape = true) { } | ||
| public void WriteCommentValue(string value, bool escape = true) { } | ||
| public void WriteEndArray() { } | ||
| public void WriteEndObject() { } | ||
| public void WriteNull(System.ReadOnlySpan<byte> utf8PropertyName, bool escape = true) { } | ||
| public void WriteNull(System.ReadOnlySpan<char> propertyName, bool escape = true) { } | ||
| public void WriteNull(string propertyName, bool escape = true) { } | ||
| public void WriteNullValue() { } | ||
| public void WriteNumber(System.ReadOnlySpan<byte> utf8PropertyName, decimal value, bool escape = true) { } | ||
| public void WriteNumber(System.ReadOnlySpan<byte> utf8PropertyName, double value, bool escape = true) { } | ||
| public void WriteNumber(System.ReadOnlySpan<byte> utf8PropertyName, int value, bool escape = true) { } | ||
| public void WriteNumber(System.ReadOnlySpan<byte> utf8PropertyName, long value, bool escape = true) { } | ||
| public void WriteNumber(System.ReadOnlySpan<byte> utf8PropertyName, float value, bool escape = true) { } | ||
| [System.CLSCompliantAttribute(false)] | ||
| public void WriteNumber(System.ReadOnlySpan<byte> utf8PropertyName, uint value, bool escape = true) { } | ||
| [System.CLSCompliantAttribute(false)] | ||
| public void WriteNumber(System.ReadOnlySpan<byte> utf8PropertyName, ulong value, bool escape = true) { } | ||
| public void WriteNumber(System.ReadOnlySpan<char> propertyName, decimal value, bool escape = true) { } | ||
| public void WriteNumber(System.ReadOnlySpan<char> propertyName, double value, bool escape = true) { } | ||
| public void WriteNumber(System.ReadOnlySpan<char> propertyName, int value, bool escape = true) { } | ||
| public void WriteNumber(System.ReadOnlySpan<char> propertyName, long value, bool escape = true) { } | ||
| public void WriteNumber(System.ReadOnlySpan<char> propertyName, float value, bool escape = true) { } | ||
| [System.CLSCompliantAttribute(false)] | ||
| public void WriteNumber(System.ReadOnlySpan<char> propertyName, uint value, bool escape = true) { } | ||
| [System.CLSCompliantAttribute(false)] | ||
| public void WriteNumber(System.ReadOnlySpan<char> propertyName, ulong value, bool escape = true) { } | ||
| public void WriteNumber(string propertyName, decimal value, bool escape = true) { } | ||
| public void WriteNumber(string propertyName, double value, bool escape = true) { } | ||
| public void WriteNumber(string propertyName, int value, bool escape = true) { } | ||
| public void WriteNumber(string propertyName, long value, bool escape = true) { } | ||
| public void WriteNumber(string propertyName, float value, bool escape = true) { } | ||
| [System.CLSCompliantAttribute(false)] | ||
| public void WriteNumber(string propertyName, uint value, bool escape = true) { } | ||
| [System.CLSCompliantAttribute(false)] | ||
| public void WriteNumber(string propertyName, ulong value, bool escape = true) { } | ||
| public void WriteNumberValue(decimal value) { } | ||
| public void WriteNumberValue(double value) { } | ||
| public void WriteNumberValue(int value) { } | ||
| public void WriteNumberValue(long value) { } | ||
| public void WriteNumberValue(float value) { } | ||
| [System.CLSCompliantAttribute(false)] | ||
| public void WriteNumberValue(uint value) { } | ||
| [System.CLSCompliantAttribute(false)] | ||
| public void WriteNumberValue(ulong value) { } | ||
|
ahsonkhan marked this conversation as resolved.
|
||
| public void WriteStartArray() { } | ||
| public void WriteStartArray(System.ReadOnlySpan<byte> utf8PropertyName, bool escape = true) { } | ||
| public void WriteStartArray(System.ReadOnlySpan<char> propertyName, bool escape = true) { } | ||
| public void WriteStartArray(string propertyName, bool escape = true) { } | ||
| public void WriteStartObject() { } | ||
| public void WriteStartObject(System.ReadOnlySpan<byte> utf8PropertyName, bool escape = true) { } | ||
| public void WriteStartObject(System.ReadOnlySpan<char> propertyName, bool escape = true) { } | ||
| public void WriteStartObject(string propertyName, bool escape = true) { } | ||
| public void WriteString(System.ReadOnlySpan<byte> utf8PropertyName, System.DateTime value, bool escape = true) { } | ||
| public void WriteString(System.ReadOnlySpan<byte> utf8PropertyName, System.DateTimeOffset value, bool escape = true) { } | ||
| public void WriteString(System.ReadOnlySpan<byte> utf8PropertyName, System.Guid value, bool escape = true) { } | ||
| public void WriteString(System.ReadOnlySpan<byte> utf8PropertyName, System.ReadOnlySpan<byte> utf8Value, bool escape = true) { } | ||
| public void WriteString(System.ReadOnlySpan<byte> utf8PropertyName, System.ReadOnlySpan<char> value, bool escape = true) { } | ||
| public void WriteString(System.ReadOnlySpan<byte> utf8PropertyName, string value, bool escape = true) { } | ||
| public void WriteString(System.ReadOnlySpan<char> propertyName, System.DateTime value, bool escape = true) { } | ||
| public void WriteString(System.ReadOnlySpan<char> propertyName, System.DateTimeOffset value, bool escape = true) { } | ||
| public void WriteString(System.ReadOnlySpan<char> propertyName, System.Guid value, bool escape = true) { } | ||
| public void WriteString(System.ReadOnlySpan<char> propertyName, System.ReadOnlySpan<byte> utf8Value, bool escape = true) { } | ||
| public void WriteString(System.ReadOnlySpan<char> propertyName, System.ReadOnlySpan<char> value, bool escape = true) { } | ||
| public void WriteString(System.ReadOnlySpan<char> propertyName, string value, bool escape = true) { } | ||
| public void WriteString(string propertyName, System.DateTime value, bool escape = true) { } | ||
| public void WriteString(string propertyName, System.DateTimeOffset value, bool escape = true) { } | ||
| public void WriteString(string propertyName, System.Guid value, bool escape = true) { } | ||
| public void WriteString(string propertyName, System.ReadOnlySpan<byte> utf8Value, bool escape = true) { } | ||
| public void WriteString(string propertyName, System.ReadOnlySpan<char> value, bool escape = true) { } | ||
| public void WriteString(string propertyName, string value, bool escape = true) { } | ||
| public void WriteStringValue(System.DateTime value) { } | ||
| public void WriteStringValue(System.DateTimeOffset value) { } | ||
| public void WriteStringValue(System.Guid value) { } | ||
| public void WriteStringValue(System.ReadOnlySpan<byte> utf8Value, bool escape = true) { } | ||
| public void WriteStringValue(System.ReadOnlySpan<char> value, bool escape = true) { } | ||
| public void WriteStringValue(string value, bool escape = true) { } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.