Description
It seems that when attempting to deserialize a type that's nested within another, and there's a failure (e.g. wrong JSON type) on the nested data, the reported position information is incorrect.
Reproduction Steps
Repro: ConsoleApp1.zip
It might not be minimal, but it's pretty small.
Expected behavior
The position in the JSON source should be reported correctly.
Actual behavior
The position in the JSON source is not reported correctly.
Regression?
I'm not sure if this is a regression for source gen, but it definitely works without source gen.
Known Workarounds
We've created a number of JsonSerializerOptions extension methods in Json.More to mitigate this for now, but it's a less desired approach.
Configuration
Libraries multitargeting .Net Standard 2.0 & .Net 8
Tests running in .Net 6 and .Net 8 (fails in both)
Repro is just .Net 8
Other information
Some offline context from @eiriktsarpalis:
JsonSerializer.Deserialize methods acceping a Ut8fJsonReader. The methods need to create a new Utf8JsonReader that is scoped to the particular JSON value you are trying to deserialize, which in the process loses information on the data that has been read so far.
Description
It seems that when attempting to deserialize a type that's nested within another, and there's a failure (e.g. wrong JSON type) on the nested data, the reported position information is incorrect.
Reproduction Steps
Repro: ConsoleApp1.zip
It might not be minimal, but it's pretty small.
Expected behavior
The position in the JSON source should be reported correctly.
Actual behavior
The position in the JSON source is not reported correctly.
Regression?
I'm not sure if this is a regression for source gen, but it definitely works without source gen.
Known Workarounds
We've created a number of
JsonSerializerOptionsextension methods inJson.Moreto mitigate this for now, but it's a less desired approach.Configuration
Libraries multitargeting .Net Standard 2.0 & .Net 8
Tests running in .Net 6 and .Net 8 (fails in both)
Repro is just .Net 8
Other information
Some offline context from @eiriktsarpalis: