-
-
Notifications
You must be signed in to change notification settings - Fork 916
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 number precision for Newtonsoft.Json #2843
Conversation
I do not understand. Can you explain what this PR is fixing? |
Newtonsoft.Json always adds |
And why is that an issue? It’s not wrong. There looks to be a lot of code that now has to execute for every single floating point number serialized. Seems like a complete waste of CPU power. There’s no reason why the serializers cannot perform differently so long as they meet spec. We could add the converter to execute only during tests if we need to unify the testing. But it would be a shame not to test the default environment. I just don’t see that anyone would request this change. Except us, and only because of our tests that cover two serialization engines. (User code uses one serializer or the other.) So, it does not seem an appropriate change to make. Now personally this doesn’t affect me because I don’t use Newtonsoft.Json. But if I did I wouldn’t want this extra code added for no reason (as seen from the users perspective). This code hurt anything except performance. So, we could add this code. But why injure performance for the sake of a few tests? |
JamesNK/Newtonsoft.Json#1726 reasoning and reactions here |
I read through that. It seems people have issues with large integer |
throw new NotSupportedException(); | ||
} | ||
|
||
public override bool CanConvert(Type objType) => objType == typeof(decimal) || objType == typeof(float) || objType == typeof(double); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public override bool CanConvert(Type objType) => objType == typeof(decimal) || objType == typeof(float) || objType == typeof(double); | |
public override bool CanConvert(Type objType) => objType == typeof(decimal); |
Ready for review. |
Codecov Report
@@ Coverage Diff @@
## master #2843 +/- ##
==========================================
+ Coverage 83.67% 83.78% +0.11%
==========================================
Files 363 364 +1
Lines 14924 14978 +54
Branches 2361 2369 +8
==========================================
+ Hits 12487 12549 +62
+ Misses 1808 1798 -10
- Partials 629 631 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
First commit demonstrates issue with Newtonsoft.
Inspired by changes in tests from #2841.