Use relaxed JavascriptEncoder in S.T.JSON specific tests to improve coverage.#39560
Use relaxed JavascriptEncoder in S.T.JSON specific tests to improve coverage.#39560ahsonkhan merged 6 commits intodotnet:masterfrom
Conversation
| var ms = new MemoryStream(); | ||
| TextWriter streamWriter = new StreamWriter(ms, new UTF8Encoding(false), 1024, true); | ||
|
|
||
| var json = new JsonTextWriter(streamWriter) |
There was a problem hiding this comment.
We should discuss whether this is the best way to get expected strings going forward. Seems to work by coincidence in this case (same escaping rules). In other cases we have started to diverge (e.g. casing).
|
Any other feedback? |
| Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, | ||
| }; | ||
|
|
||
| using var writer = new Utf8JsonWriter(buffer, options); |
There was a problem hiding this comment.
Personally, I vastly prefer "block statement using". This using ends after AssertContents, but following the least-need principle the using should end after (or instead-of) writer.Flush. (The new using statement is particularly bad in async methods, where it can make the using straddle an await it didn't need to)
So, replacing all of the usings with scoped blocks would make me happier, but it's not critical.
|
@ahsonkhan are you planning to get this one in? |
|
Hello @ahsonkhan! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
|
Test failure is unrelated: |
…overage. (dotnet#39560) * Use relaxed JavascriptEncoder in S.T.JSON specific tests to improve coverage. * Add control characters as well as part of the test data. * Add JsonElement.WriteTo test and make sure all Utf8JsonWriter in tests are disposed. * Fix spacing/formatting. * Fix call to AssertEquals since it moved to JsonTestHelper.
…overage. (#39560) (#39850) * Use relaxed JavascriptEncoder in S.T.JSON specific tests to improve coverage. * Add control characters as well as part of the test data. * Add JsonElement.WriteTo test and make sure all Utf8JsonWriter in tests are disposed. * Fix spacing/formatting. * Fix call to AssertEquals since it moved to JsonTestHelper.
|
@ahsonkhan this specific PR went into master after last integration to release/3.0 branch, so I fixed milestone to 5.0. |
…overage. (dotnet/corefx#39560) * Use relaxed JavascriptEncoder in S.T.JSON specific tests to improve coverage. * Add control characters as well as part of the test data. * Add JsonElement.WriteTo test and make sure all Utf8JsonWriter in tests are disposed. * Fix spacing/formatting. * Fix call to AssertEquals since it moved to JsonTestHelper. Commit migrated from dotnet/corefx@74d26be
cc @steveharter