Add new line to be specified for JSON formatting#100890
Add new line to be specified for JSON formatting#100890eiriktsarpalis merged 8 commits intodotnet:mainfrom
Conversation
Allow the new line string to use for indented JSON to be specified through options. Resolves dotnet#84117.
|
Note regarding the |
|
@eiriktsarpalis I've left this in draft for now before I dig around tomorrow and see if I've missed anything, but feel free to start reviewing at your convenience. |
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.cs
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/System.Text.Json.Tests/JsonWriterOptionsTests.cs
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/OptionsTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.cs
Show resolved
Hide resolved
|
Failing test is |
- Cater for `_newLine` in JsonSerializerOptions caching. - Lazily initialize field. - Allow null to reset to default. - Add assertions. - Add/update comments. - Use `nameof()`. - Remove redundant field. - Extend tests.
- Update property count to fix assertion. - Update test to validate `NewLine` can be set/bound.
Only normalize the line endings if the `JsonWriterOptions` are not using the defaults.
src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.cs
Show resolved
Hide resolved
...braries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs
Outdated
Show resolved
Hide resolved
...braries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs
Outdated
Show resolved
Hide resolved
|
I'm not sure why the Mono tests are failing - there's something in the logs about how some of the tests take a long time to run under the interpreter, so I wonder if the extra test cases I've added to the combinations for |
...braries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs
Outdated
Show resolved
Hide resolved
- Access lazily initialized field through property. - Update hash code assertion.
Use similar format string to `Format_InvalidGuidFormatSpecification`/
...braries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs
Outdated
Show resolved
Hide resolved
...braries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterOptions.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/OptionsTests.cs
Outdated
Show resolved
Hide resolved
Looks like these are known issues. |
Reword comment as suggested.
- Simplify condition. - Disallow null for `string NewLine` properties.
We generally use the "Build Analysis" leg to determine if there any test failures that haven't been flagged as known issues. |
* Add new line to be specified for JSON formatting Allow the new line string to use for indented JSON to be specified through options. Resolves dotnet#84117. * Address review feedback - Cater for `_newLine` in JsonSerializerOptions caching. - Lazily initialize field. - Allow null to reset to default. - Add assertions. - Add/update comments. - Use `nameof()`. - Remove redundant field. - Extend tests. * Update Logging.Console tests - Update property count to fix assertion. - Update test to validate `NewLine` can be set/bound. * Only normalize line endings if needed Only normalize the line endings if the `JsonWriterOptions` are not using the defaults. * Address feedback - Access lazily initialized field through property. - Update hash code assertion. * Update exception message Use similar format string to `Format_InvalidGuidFormatSpecification`/ * Address feedback Reword comment as suggested. * Address feedback - Simplify condition. - Disallow null for `string NewLine` properties.
Allow the new line string to use for indented JSON to be specified through options.
Resolves #84117.