Skip to content

Improve Json serialization by always reading a complete object.#2491

Merged
brentschmaltz merged 1 commit into
devfrom
brentsch/OidcSerialization
Feb 21, 2024
Merged

Improve Json serialization by always reading a complete object.#2491
brentschmaltz merged 1 commit into
devfrom
brentsch/OidcSerialization

Conversation

@brentschmaltz

@brentschmaltz brentschmaltz commented Feb 13, 2024

Copy link
Copy Markdown
Contributor

Basically, when reading a JsonToken read the entire token and position the reader at the next token.
When reading a JsonObject, the reader was positioned at a JsonTokenType.EndObject after reading.
If the runtime was currently reading a JsonObject, the exit condition of seeing a JsonTokenType.EndObject would be true and the serialization would exit. Same was true for JsonArray.

This will make it very difficult for embedded objects.

Tests were added to ensure that Arrays and Objects placed in the beginning, middle or end of the Json text will be processed correctly.

Test code was removed that was used to understand how the previous internal Newtonsoft, System.Text.Json and external Newtonsoft would work together.
That code is no longer needed as we are dealing with issues as they arise.

@keegan-caruso keegan-caruso added this to the 7.3.2 milestone Feb 13, 2024
Comment thread test/Microsoft.IdentityModel.TestUtils/DataSets.cs
Comment thread src/Microsoft.IdentityModel.Tokens/Json/JsonSerializerPrimitives.cs Outdated
Comment thread test/Microsoft.IdentityModel.Tokens.Tests/Json/JsonSerializerPrimitivesTests.cs Outdated
@brentschmaltz brentschmaltz force-pushed the brentsch/OidcSerialization branch from 308c541 to 652a173 Compare February 20, 2024 23:22

@jennyf19 jennyf19 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

Comment thread src/Microsoft.IdentityModel.Tokens/Json/JsonSerializerPrimitives.cs Outdated
Remove test code that is no longer needed.
@twogood

twogood commented Feb 23, 2024

Copy link
Copy Markdown

I'm wishing for a release with this fix ASAP, been spending days trying to understand and workaround incorrect parsing of "mtls_endpoint_aliases":{} in .well-known/openid-configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants