-
Notifications
You must be signed in to change notification settings - Fork 382
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
💥Remove decimal support #1359
💥Remove decimal support #1359
Conversation
ea94306
to
8f655e4
Compare
I rebased this to clean up the commit history, which should aid in reviewing. |
They were not specific to decimal, adapted to work with double values.
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.
Looks good to me!
As you said, it's a bit sad to see a lot of thought and work being thrown out, but I still do think reducing this complexity is worth it until we find a better way to support multiple numeric types in a more holistic way.
I made a few minor improvements and pushed it.
}; | ||
} | ||
|
||
if (valueType.Type != JTokenType.String) |
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.
I was contemplating whether we should keep the JSON serialization stuff for backwards compatibility, but I realized the JSON already was backwards compatible by storing both double and decimal (string) values. So by now only reading the double value, it should still work as before except for the change in precision that would happen even if we kept reading the decimal string value and converted that to double.
Changes
QuantityValue
, replaced withdouble
TValueType
from interfacesIQuantity<TUnitType, out TValueType>
IValueQuantity<out TValueType>
IQuantity<TSelf, TUnitType, out TValueType>
toIQuantity<TSelf, TUnitType>
IArithmeticQuantity<TSelf, TUnitType, TValueType>
toIArithmeticQuantity<TSelf, TUnitType>
Changes to UnitsNet.Serialiation.JsonNet
Information
,BitRate
andPower
still work, but it now reads justdouble Value
property and ignoresstring ValueString
andstring ValueType
properties. This may lose precision compared to preserving the fulldecimal
value, butdecimal
is no longer supported in v6.Background
In #1195 @angularsen says:
This made me wonder how deep that complexity goes so I decided to experiment, and this is the result.
I must say some of these changes make me a bit sad. A lot of work and some very clever thinking went into supporting multiple numerical types, and I want to acknowledge that. 🙇
Also, I took it as far as possible but that might not be the best outcome, for example we might want to keep deserialization support. This just demonstrates a possible direction we could go in.