Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SystemTextJson serializer to allow custom json converters for any data type #3189

Merged
merged 2 commits into from
Jun 20, 2022

Conversation

Shane32
Copy link
Member

@Shane32 Shane32 commented Jun 20, 2022

Fixes #2257 for System.Text.Json and allows any registered JsonConverter to work properly.

It comes at a cost of an additional 25-50% of serialization time. For the "middle" query below, this represents a half of a millionth of a second of processing time. Even for the introspection query, it's only 45 millionths of a second (45μs / 0.045ms). I believe that the benefits here are worth the infinitesimal speed loss.

"Alt" is the new code

Method Code Mean Error StdDev Gen 0 Allocated
SystemTextJson Introspection 79,349.3 ns 159.36 ns 141.27 ns - 161 B
SystemTextJsonAlt Introspection 124,444.6 ns 467.13 ns 436.95 ns - 168 B
SystemTextJson Middle 1,442.3 ns 2.38 ns 1.98 ns 0.0229 152 B
SystemTextJsonAlt Middle 2,075.8 ns 3.94 ns 3.68 ns 0.0229 152 B
SystemTextJson Small 397.0 ns 1.11 ns 0.98 ns 0.0238 152 B
SystemTextJsonAlt Small 535.5 ns 2.46 ns 2.18 ns 0.0238 152 B

@Shane32 Shane32 added the bugfix Pull request that fixes a bug label Jun 20, 2022
@Shane32 Shane32 requested a review from sungam3r June 20, 2022 14:19
@Shane32 Shane32 self-assigned this Jun 20, 2022
Copy link
Member

@sungam3r sungam3r left a comment

Choose a reason for hiding this comment

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

Interesting change 😄 . Any test to verify decimal bug fixed?

@Shane32
Copy link
Member Author

Shane32 commented Jun 20, 2022

Interesting change 😄 . Any test to verify decimal bug fixed?

I'll do that.

@Shane32 Shane32 added this to the 5.4 milestone Jun 20, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #3189 (25bb1bf) into master (23e0fff) will increase coverage by 0.01%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master    #3189      +/-   ##
==========================================
+ Coverage   84.41%   84.43%   +0.01%     
==========================================
  Files         371      371              
  Lines       16106    16034      -72     
  Branches     2605     2600       -5     
==========================================
- Hits        13596    13538      -58     
+ Misses       1884     1873      -11     
+ Partials      626      623       -3     
Impacted Files Coverage Δ
...hQL.SystemTextJson/ExecutionResultJsonConverter.cs 89.28% <66.66%> (+2.74%) ⬆️
src/GraphQL/Types/Schema.cs 79.90% <0.00%> (+0.91%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 23e0fff...25bb1bf. Read the comment docs.

@Shane32 Shane32 merged commit dc379ff into master Jun 20, 2022
@Shane32 Shane32 deleted the fix_serializer branch June 20, 2022 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Pull request that fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to change output of decimal scalar (removing trailing zeros)
3 participants