Property ordering in JSON: net10.0, MSTest 4.3.3, converter Read() fix - #2156
Open
vladimir-pecanac-main wants to merge 1 commit into
Open
Property ordering in JSON: net10.0, MSTest 4.3.3, converter Read() fix#2156vladimir-pecanac-main wants to merge 1 commit into
vladimir-pecanac-main wants to merge 1 commit into
Conversation
…ter Read() re-entry - All three projects net7.0 -> net10.0 - Newtonsoft.Json 13.0.3 -> 13.0.4, BenchmarkDotNet 0.13.5 -> 0.15.8, Microsoft.NET.Test.Sdk 17.3.2 -> 18.9.0, MSTest.TestAdapter/TestFramework 2.2.10 -> 4.3.3, coverlet.collector 3.1.2 -> 10.0.1 - MicrosoftOrderedPropertiesConverter<T>.Read() called JsonSerializer.Deserialize<T> with the same options the converter is registered in, so deserializing re-entered the converter and recursed until the process died with a stack overflow. It now throws NotSupportedException; the converter exists to control write order only. One test covers it. - Typo in a public member: Student.RegistratioNumber -> RegistrationNumber
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates the sample for
json-csharp/OrderPropertyJsonInCSharpalongside a rewrite of the article Property Ordering in C# JSON Serialization.net7.0->net10.0.Newtonsoft.Json13.0.3 -> 13.0.4,BenchmarkDotNet0.13.5 -> 0.15.8,Microsoft.NET.Test.Sdk17.3.2 -> 18.9.0,MSTest.TestAdapter/MSTest.TestFramework2.2.10 -> 4.3.3,coverlet.collector3.1.2 -> 10.0.1. The MSTest jump crosses two majors; the existing six tests use onlyAssert.AreEqualand needed no rewrite, and the build emits zero MSTESTxxxx analyzer diagnostics.MicrosoftOrderedPropertiesConverter<T>.Read()calledJsonSerializer.Deserialize<T>(ref reader, options)with the same options instance the converter is registered in, so deserializing re-entered the converter. It does not throw a catchable exception: it recurses until the process dies withStack overflow., reproduced through both the optionsConverterscollection and the[JsonConverter]attribute.Read()now throwsNotSupportedExceptionwith a message saying the converter exists to control write order. The six existing tests only serialize, so nothing caught this; a seventh test now covers it.Student.RegistratioNumber->RegistrationNumber. The name is printed in the article's console output, so the article, the snippet and the output block move with it.dotnet build0 warnings, 0 errors anddotnet test7/7 green on SDK 10.0.302 / runtime 10.0.10. Benchmark re-run on .NET 10 with BenchmarkDotNet 0.15.8; the article's figures are replaced with the new run.