Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Add Utf8JsonWriter along with unit tests #34425

Merged
merged 34 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
aeb2103
Move JsonReader related files to the Reader directory.
ahsonkhan Jan 7, 2019
76a459b
Update S.T.Json ref to include new JsonWriter APIs.
ahsonkhan Jan 7, 2019
f1eae6f
Port initial JsonWriter files from corefxlab.
ahsonkhan Jan 7, 2019
0e1a283
Auto-generate System.Text.Json ref to update the ordering for
ahsonkhan Jan 7, 2019
fd8bd6d
Fixed some TODOs, delete dead code, and formatting cleanup.
ahsonkhan Jan 7, 2019
39fc64d
Make use of self-descriptive constants where possible.
ahsonkhan Jan 7, 2019
41b7b2c
Fix leftover TODOs and update throw helper/exception messages.
ahsonkhan Jan 8, 2019
7988444
Add xml comments/docs to the public surface area.
ahsonkhan Jan 8, 2019
8276f4c
Add JsonWriter unit tests.
ahsonkhan Jan 8, 2019
9bec478
Change GetCurrentState back to a property and explicitly Flush on the
ahsonkhan Jan 8, 2019
5385574
Save current depth as part of state and update tests.
ahsonkhan Jan 8, 2019
a9f99be
Fix constant names, account for quotes in bytes needed, and add fixed…
ahsonkhan Jan 10, 2019
65b38cb
Fix inconsistent use of braces by adding them for single line ifs
ahsonkhan Jan 10, 2019
8d62b8a
Update parameter name to exclude encoding.
ahsonkhan Jan 10, 2019
c4fc141
Remove JsonWriterException and use InvalidOperationException instead.
ahsonkhan Jan 10, 2019
534ebf2
Use Rune and Utf8Formatter/TryFormat in more places and remove
ahsonkhan Jan 10, 2019
424835a
Fix nits, typos, and reorder field assignment and method calls.
ahsonkhan Jan 10, 2019
1c09b09
Pass spans by in (or by value) instead of by ref.
ahsonkhan Jan 12, 2019
a91c702
Update comments and remove unnecessary test.
ahsonkhan Jan 12, 2019
f1cdc28
Remove some aggressive inlining and pass spans by value rather than in
ahsonkhan Jan 12, 2019
baa5ac2
Update comments, dont compute bytes needed, and use if instead of loo…
ahsonkhan Jan 12, 2019
644118c
Reduce code bloat by removing duplciate calls to ValidateX.
ahsonkhan Jan 12, 2019
baa4931
Add details on how .NET types are formatted to comments.
ahsonkhan Jan 12, 2019
2b91e6c
Reduce code duplication when writing values.
ahsonkhan Jan 12, 2019
6c43954
Change the StandardFormat used for DateTime(Offset) to 'O'
ahsonkhan Jan 12, 2019
eb33db6
Refactor calculating the maximum escaped length to a helper.
ahsonkhan Jan 12, 2019
171f6c3
Remove unnecessary checks and rename locals to be more descriptive.
ahsonkhan Jan 12, 2019
a14a57e
Rename suppressEscaping to escape and flip default from false to true.
ahsonkhan Jan 12, 2019
712502b
Merge branch 'master' of https://github.com/dotnet/corefx into AddJso…
ahsonkhan Jan 15, 2019
3bc364c
Comment cleanup, add debug.asserts, and move transcoding helpers to a
ahsonkhan Jan 15, 2019
56382db
Increase the deicmal max size to account for sign and add tests.
ahsonkhan Jan 15, 2019
2900bc5
Rename ROS<byte> property name and value params to include utf8 in the
ahsonkhan Jan 15, 2019
6f41164
Remove redundant code where idx is set to 0 unnecessarily.
ahsonkhan Jan 15, 2019
c3c83e4
Remove dead code (dont escape forward slash) and make tests culture
ahsonkhan Jan 15, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@ private static IEnumerable<object[]> SerializableObjects()
#if netcoreapp
var jsonReaderException = new JsonReaderException("message", lineNumber: 0, bytePositionInLine: 0);
yield return new object[] { PopulateException(jsonReaderException), new TypeSerializableValue[] { new TypeSerializableValue("AAEAAAD/////AQAAAAAAAAAMAgAAAFNTeXN0ZW0uVGV4dC5Kc29uLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Y2M3YjEzZmZjZDJkZGQ1MQUBAAAAJFN5c3RlbS5UZXh0Lkpzb24uSnNvblJlYWRlckV4Y2VwdGlvbg4AAAAJQ2xhc3NOYW1lB01lc3NhZ2UERGF0YQ5Jbm5lckV4Y2VwdGlvbgdIZWxwVVJMEFN0YWNrVHJhY2VTdHJpbmcWUmVtb3RlU3RhY2tUcmFjZVN0cmluZxBSZW1vdGVTdGFja0luZGV4D0V4Y2VwdGlvbk1ldGhvZAdIUmVzdWx0BlNvdXJjZQ1XYXRzb25CdWNrZXRzCkxpbmVOdW1iZXISQnl0ZVBvc2l0aW9uSW5MaW5lAQEDAwEBAQABAAEHAAApU3lzdGVtLkNvbGxlY3Rpb25zLkxpc3REaWN0aW9uYXJ5SW50ZXJuYWwQU3lzdGVtLkV4Y2VwdGlvbggIAgkJAgAAAAYDAAAAJFN5c3RlbS5UZXh0Lkpzb24uSnNvblJlYWRlckV4Y2VwdGlvbgYEAAAAB21lc3NhZ2UJBQAAAAoGBgAAABlodHRwOi8vbXNkbi5taWNyb3NvZnQuY29tBgcAAAAUU3RhY2tUcmFjZSBzdHJpbmcuLi4GCAAAABtSZW1vdGUgU3RhY2tUcmFjZSBzdHJpbmcuLi4AAAAACugDAAAGCQAAABdFeGNlcHRpb25fQ2xhc3NfU2FtcGxlcwoAAAAAAAAAAAAAAAAAAAAABAUAAAApU3lzdGVtLkNvbGxlY3Rpb25zLkxpc3REaWN0aW9uYXJ5SW50ZXJuYWwDAAAABGhlYWQHdmVyc2lvbgVjb3VudAMAADhTeXN0ZW0uQ29sbGVjdGlvbnMuTGlzdERpY3Rpb25hcnlJbnRlcm5hbCtEaWN0aW9uYXJ5Tm9kZQgICQoAAAACAAAAAgAAAAQKAAAAOFN5c3RlbS5Db2xsZWN0aW9ucy5MaXN0RGljdGlvbmFyeUludGVybmFsK0RpY3Rpb25hcnlOb2RlAwAAAANrZXkFdmFsdWUEbmV4dAICAzhTeXN0ZW0uQ29sbGVjdGlvbnMuTGlzdERpY3Rpb25hcnlJbnRlcm5hbCtEaWN0aW9uYXJ5Tm9kZQYLAAAABnNlY3JldAgBAQkMAAAAAQwAAAAKAAAACAgBAAAABg0AAAADb25lCgs=", TargetFrameworkMoniker.netcoreapp30) } };

var jsonWriterException = new JsonWriterException("message");
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
yield return new object[] { PopulateException(jsonWriterException), new TypeSerializableValue[] { new TypeSerializableValue("AAEAAAD/////AQAAAAAAAAAMAgAAAFNTeXN0ZW0uVGV4dC5Kc29uLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Y2M3YjEzZmZjZDJkZGQ1MQUBAAAAJFN5c3RlbS5UZXh0Lkpzb24uSnNvbldyaXRlckV4Y2VwdGlvbgwAAAAJQ2xhc3NOYW1lB01lc3NhZ2UERGF0YQ5Jbm5lckV4Y2VwdGlvbgdIZWxwVVJMEFN0YWNrVHJhY2VTdHJpbmcWUmVtb3RlU3RhY2tUcmFjZVN0cmluZxBSZW1vdGVTdGFja0luZGV4D0V4Y2VwdGlvbk1ldGhvZAdIUmVzdWx0BlNvdXJjZQ1XYXRzb25CdWNrZXRzAQEDAwEBAQABAAEHKVN5c3RlbS5Db2xsZWN0aW9ucy5MaXN0RGljdGlvbmFyeUludGVybmFsEFN5c3RlbS5FeGNlcHRpb24ICAICAAAABgMAAAAkU3lzdGVtLlRleHQuSnNvbi5Kc29uV3JpdGVyRXhjZXB0aW9uBgQAAAAHbWVzc2FnZQkFAAAACgYGAAAAGWh0dHA6Ly9tc2RuLm1pY3Jvc29mdC5jb20GBwAAABRTdGFja1RyYWNlIHN0cmluZy4uLgYIAAAAG1JlbW90ZSBTdGFja1RyYWNlIHN0cmluZy4uLgAAAAAK6AMAAAYJAAAAF0V4Y2VwdGlvbl9DbGFzc19TYW1wbGVzCgQFAAAAKVN5c3RlbS5Db2xsZWN0aW9ucy5MaXN0RGljdGlvbmFyeUludGVybmFsAwAAAARoZWFkB3ZlcnNpb24FY291bnQDAAA4U3lzdGVtLkNvbGxlY3Rpb25zLkxpc3REaWN0aW9uYXJ5SW50ZXJuYWwrRGljdGlvbmFyeU5vZGUICAkKAAAAAgAAAAIAAAAECgAAADhTeXN0ZW0uQ29sbGVjdGlvbnMuTGlzdERpY3Rpb25hcnlJbnRlcm5hbCtEaWN0aW9uYXJ5Tm9kZQMAAAADa2V5BXZhbHVlBG5leHQCAgM4U3lzdGVtLkNvbGxlY3Rpb25zLkxpc3REaWN0aW9uYXJ5SW50ZXJuYWwrRGljdGlvbmFyeU5vZGUGCwAAAAZzZWNyZXQIAQEJDAAAAAEMAAAACgAAAAgIAQAAAAYNAAAAA29uZQoL", TargetFrameworkMoniker.netcoreapp30) } };
#endif

var keyNotFoundException = new KeyNotFoundException("message", exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,16 @@ public static void IsEqual(this JsonReaderException @this, JsonReaderException o
Assert.Equal(@this.LineNumber, other.LineNumber);
Assert.Equal(@this.BytePositionInLine, other.BytePositionInLine);
}

public static void IsEqual(this JsonWriterException @this, JsonWriterException other, bool isSamePlatform)
{
if (@this == null && other == null)
return;

Assert.NotNull(@this);
Assert.NotNull(other);
IsEqual(@this as Exception, other as Exception, isSamePlatform);
}
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
#endif

public static void IsEqual(this EventArgs @this, EventArgs other, bool isSamePlatform)
Expand Down
109 changes: 109 additions & 0 deletions src/System.Text.Json/ref/System.Text.Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ public enum JsonTokenType : byte
String = (byte)6,
True = (byte)8,
}
public sealed partial class JsonWriterException : System.Exception
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
{
public JsonWriterException(string message) { }
}
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; } }
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
public System.Text.Json.JsonWriterOptions Options { get { throw null; } }
}
public ref partial struct Utf8JsonReader
{
private object _dummy;
Expand All @@ -71,4 +89,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; } }
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these commonly accessed on the writer?

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 System.Text.Json.JsonWriterState CurrentState { get { throw null; } }
public void Flush(bool isFinalBlock = true) { }
public void WriteBoolean(System.ReadOnlySpan<byte> propertyName, bool value, bool suppressEscaping = false) { }
public void WriteBoolean(System.ReadOnlySpan<char> propertyName, bool value, bool suppressEscaping = false) { }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the double negative of supressEscaping a bit strange? I know we generally prefer default arguments to be false rather than true, but it seems like this would be better as bool escape = true or bool escapeIfNecessary = true or some such thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we generally prefer default arguments to be false rather than true

If we are OK with making an exception here, I am fine with calling it escape instead and avoid the double negative. How do others feel about the change? I want to avoid going back and forth.

cc @terrajobst

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we already have isFinalBlock = true as the default argument in Flush(), I am going to make this change as well.

public void WriteBoolean(string propertyName, bool value, bool suppressEscaping = false) { }
public void WriteBooleanValue(bool value) { }
public void WriteCommentValue(System.ReadOnlySpan<byte> utf8Text, bool suppressEscaping = false) { }
public void WriteCommentValue(System.ReadOnlySpan<char> utf16Text, bool suppressEscaping = false) { }
public void WriteCommentValue(string utf16Text, bool suppressEscaping = false) { }
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
public void WriteEndArray() { }
public void WriteEndObject() { }
public void WriteNull(System.ReadOnlySpan<byte> propertyName, bool suppressEscaping = false) { }
public void WriteNull(System.ReadOnlySpan<char> propertyName, bool suppressEscaping = false) { }
public void WriteNull(string propertyName, bool suppressEscaping = false) { }
public void WriteNullValue() { }
public void WriteNumber(System.ReadOnlySpan<byte> propertyName, decimal value, bool suppressEscaping = false) { }
public void WriteNumber(System.ReadOnlySpan<byte> propertyName, double value, bool suppressEscaping = false) { }
public void WriteNumber(System.ReadOnlySpan<byte> propertyName, int value, bool suppressEscaping = false) { }
public void WriteNumber(System.ReadOnlySpan<byte> propertyName, long value, bool suppressEscaping = false) { }
public void WriteNumber(System.ReadOnlySpan<byte> propertyName, float value, bool suppressEscaping = false) { }
[System.CLSCompliantAttribute(false)]
public void WriteNumber(System.ReadOnlySpan<byte> propertyName, uint value, bool suppressEscaping = false) { }
[System.CLSCompliantAttribute(false)]
public void WriteNumber(System.ReadOnlySpan<byte> propertyName, ulong value, bool suppressEscaping = false) { }
public void WriteNumber(System.ReadOnlySpan<char> propertyName, decimal value, bool suppressEscaping = false) { }
public void WriteNumber(System.ReadOnlySpan<char> propertyName, double value, bool suppressEscaping = false) { }
public void WriteNumber(System.ReadOnlySpan<char> propertyName, int value, bool suppressEscaping = false) { }
public void WriteNumber(System.ReadOnlySpan<char> propertyName, long value, bool suppressEscaping = false) { }
public void WriteNumber(System.ReadOnlySpan<char> propertyName, float value, bool suppressEscaping = false) { }
[System.CLSCompliantAttribute(false)]
public void WriteNumber(System.ReadOnlySpan<char> propertyName, uint value, bool suppressEscaping = false) { }
[System.CLSCompliantAttribute(false)]
public void WriteNumber(System.ReadOnlySpan<char> propertyName, ulong value, bool suppressEscaping = false) { }
public void WriteNumber(string propertyName, decimal value, bool suppressEscaping = false) { }
public void WriteNumber(string propertyName, double value, bool suppressEscaping = false) { }
public void WriteNumber(string propertyName, int value, bool suppressEscaping = false) { }
public void WriteNumber(string propertyName, long value, bool suppressEscaping = false) { }
public void WriteNumber(string propertyName, float value, bool suppressEscaping = false) { }
[System.CLSCompliantAttribute(false)]
public void WriteNumber(string propertyName, uint value, bool suppressEscaping = false) { }
[System.CLSCompliantAttribute(false)]
public void WriteNumber(string propertyName, ulong value, bool suppressEscaping = false) { }
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.
Show resolved Hide resolved
public void WriteStartArray() { }
public void WriteStartArray(System.ReadOnlySpan<byte> propertyName, bool suppressEscaping = false) { }
public void WriteStartArray(System.ReadOnlySpan<char> propertyName, bool suppressEscaping = false) { }
public void WriteStartArray(string propertyName, bool suppressEscaping = false) { }
public void WriteStartObject() { }
public void WriteStartObject(System.ReadOnlySpan<byte> propertyName, bool suppressEscaping = false) { }
public void WriteStartObject(System.ReadOnlySpan<char> propertyName, bool suppressEscaping = false) { }
public void WriteStartObject(string propertyName, bool suppressEscaping = false) { }
public void WriteString(System.ReadOnlySpan<byte> propertyName, System.DateTime value, bool suppressEscaping = false) { }
public void WriteString(System.ReadOnlySpan<byte> propertyName, System.DateTimeOffset value, bool suppressEscaping = false) { }
public void WriteString(System.ReadOnlySpan<byte> propertyName, System.Guid value, bool suppressEscaping = false) { }
public void WriteString(System.ReadOnlySpan<byte> propertyName, System.ReadOnlySpan<byte> value, bool suppressEscaping = false) { }
public void WriteString(System.ReadOnlySpan<byte> propertyName, System.ReadOnlySpan<char> value, bool suppressEscaping = false) { }
public void WriteString(System.ReadOnlySpan<byte> propertyName, string value, bool suppressEscaping = false) { }
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API design with a default argument value has same performance bug as the default format argument for integer formatters. This argument has to be always passed in (makes every callsite bigger) and then checked in the implementation.

I think these Write APIs should be split into 2 categories:

  • The APIs for the core types: strings and primitive numbers. These APIs should have the full variety of overloads to make them as lean and fast as possible in all cases. String and Span overloads, as well as overloads with the suppress-escaping argument.

  • The APIs for the fringe types: Guid, DateTimes, decimal, etc. These APIs should have just the single most general overload that takes Spans and bool suppressEscaping with default value.

Copy link
Member Author

@ahsonkhan ahsonkhan Jan 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API design with a default argument value has same performance bug as the default format argument for integer formatters

I considered splitting the APIs and removing optional arguments.

However, in my benchmarks, I didn't notice the same performance regression as Utf8Formatter (based on the current implementation). Having an API without the optional bool did not show any significant improvement.

Also, the common/high performance scenario is one where suppressEscaping is true. I would assume the APIs that don't accept suppressEscaping will behave the same as if suppressEscaping is false (i.e. they will do the escaping check). So, it won't really help the common case.

[Benchmark]
public void WriteStringsWithOptionalParam()
{
    _arrayFormatterWrapper.Clear();

    var state = new JsonWriterState(options: new JsonWriterOptions { Indented = Formatted, SkipValidation = SkipValidation });

    var json = new Utf8JsonWriter2(_arrayFormatterWrapper, state);

    json.WriteStartArray();
    for (int i = 0; i < 100; i++)
    {
        json.WriteStringValue(_strings[i], suppressEscaping: false);
    }
}

[Benchmark]
public void WriteStringsNoOptionalParam()
{
    _arrayFormatterWrapper.Clear();

    var state = new JsonWriterState(options: new JsonWriterOptions { Indented = Formatted, SkipValidation = SkipValidation });

    var json = new Utf8JsonWriter2(_arrayFormatterWrapper, state);

    json.WriteStartArray();
    for (int i = 0; i < 100; i++)
    {
        json.WriteStringValue(_strings[i]);
    }
}

public void WriteString(System.ReadOnlySpan<char> propertyName, System.DateTime value, bool suppressEscaping = false) { }
public void WriteString(System.ReadOnlySpan<char> propertyName, System.DateTimeOffset value, bool suppressEscaping = false) { }
public void WriteString(System.ReadOnlySpan<char> propertyName, System.Guid value, bool suppressEscaping = false) { }
public void WriteString(System.ReadOnlySpan<char> propertyName, System.ReadOnlySpan<byte> value, bool suppressEscaping = false) { }
public void WriteString(System.ReadOnlySpan<char> propertyName, System.ReadOnlySpan<char> value, bool suppressEscaping = false) { }
public void WriteString(System.ReadOnlySpan<char> propertyName, string value, bool suppressEscaping = false) { }
public void WriteString(string propertyName, System.DateTime value, bool suppressEscaping = false) { }
public void WriteString(string propertyName, System.DateTimeOffset value, bool suppressEscaping = false) { }
public void WriteString(string propertyName, System.Guid value, bool suppressEscaping = false) { }
public void WriteString(string propertyName, System.ReadOnlySpan<byte> value, bool suppressEscaping = false) { }
public void WriteString(string propertyName, System.ReadOnlySpan<char> value, bool suppressEscaping = false) { }
public void WriteString(string propertyName, string value, bool suppressEscaping = false) { }
public void WriteStringValue(System.DateTime value) { }
public void WriteStringValue(System.DateTimeOffset value) { }
public void WriteStringValue(System.Guid value) { }
public void WriteStringValue(System.ReadOnlySpan<byte> utf8Text, bool suppressEscaping = false) { }
public void WriteStringValue(System.ReadOnlySpan<char> utf16Text, bool suppressEscaping = false) { }
public void WriteStringValue(string utf16Text, bool suppressEscaping = false) { }
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
}
}
39 changes: 39 additions & 0 deletions src/System.Text.Json/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,30 @@
<data name="ArrayDepthTooLarge" xml:space="preserve">
<value>CurrentDepth ({0}) is larger than the maximum configured depth of {1}. Cannot read next JSON array.</value>
</data>
<data name="CannotStartObjectArrayAfterPrimitive" xml:space="preserve">
<value>Cannot write the start of an object or array after a single JSON value. Current token type is '{0}'.</value>
</data>
<data name="CannotStartObjectArrayWithoutProperty" xml:space="preserve">
<value>Cannot write the start of an object or array without a property name. Current token type is '{0}'.</value>
</data>
<data name="CannotWriteInvalidUTF16" xml:space="preserve">
<value>Cannot write invalid UTF-16 text as JSON. Invalid surrogate pair: '{0}'.</value>
</data>
<data name="CannotWriteInvalidUTF8" xml:space="preserve">
<value>Cannot write invalid UTF-8 text as JSON. Invalid input: '{0}'.</value>
</data>
<data name="CannotWritePropertyWithinArray" xml:space="preserve">
<value>Cannot write a JSON property within an array or as the first JSON token. Current token type is '{0}'.</value>
</data>
<data name="CannotWriteValueAfterPrimitive" xml:space="preserve">
<value>Cannot write a JSON value after a single JSON value. Current token type is '{0}'.</value>
</data>
<data name="CannotWriteValueWithinObject" xml:space="preserve">
<value>Cannot write a JSON value within an object without a property name. Current token type is '{0}'.</value>
</data>
<data name="DepthTooLarge" xml:space="preserve">
<value>CurrentDepth ({0}) is equal to or larger than the maximum allowed depth of 1000. Cannot write the next JSON object or array.</value>
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
</data>
<data name="EndOfCommentNotFound" xml:space="preserve">
<value>Expected end of comment, but instead reached end of data.</value>
</data>
Expand Down Expand Up @@ -159,6 +183,12 @@
<data name="ExpectedValueAfterPropertyNameNotFound" xml:space="preserve">
<value>Expected a value, but instead reached end of data.</value>
</data>
<data name="FailedToGetLargerSpan" xml:space="preserve">
<value>The 'IBufferWriter' could not provide an output buffer that is large enough to continue writing.</value>
</data>
<data name="FailedToGetMinimumSizeSpan" xml:space="preserve">
<value>The 'IBufferWriter' could not provide an output buffer that is large enough to continue writing. Need at least {0} bytes.</value>
</data>
<data name="FoundInvalidCharacter" xml:space="preserve">
<value>'{0}' is invalid after a value. Expected either ',', '}}', or ']'.</value>
</data>
Expand Down Expand Up @@ -186,6 +216,9 @@
<data name="ObjectDepthTooLarge" xml:space="preserve">
<value>CurrentDepth ({0}) is larger than the maximum configured depth of {1}. Cannot read next JSON object.</value>
</data>
<data name="PropertyNameTooLarge" xml:space="preserve">
<value>The JSON property name of length {0} is too large and not supported by the JSON writer.</value>
</data>
<data name="RequiredDigitNotFoundAfterDecimal" xml:space="preserve">
<value>'{0}' is invalid within a number, immediately after a decimal point ('.'). Expected a digit ('0'-'9').</value>
</data>
Expand All @@ -195,6 +228,12 @@
<data name="RequiredDigitNotFoundEndOfData" xml:space="preserve">
<value>Expected a digit ('0'-'9'), but instead reached end of data.</value>
</data>
<data name="SpecialNumberValuesNotSupported" xml:space="preserve">
<value>.NET number values such as positive and negative infinity cannot be written as valid JSON.</value>
</data>
<data name="ValueTooLarge" xml:space="preserve">
<value>The JSON value of length {0} is too large and not supported by the JSON writer.</value>
</data>
<data name="ZeroDepthAtEnd" xml:space="preserve">
<value>Expected CurrentDepth ({0}) to be zero at the end of the JSON payload. There is an open JSON object or array that should be closed.</value>
</data>
Expand Down
Loading