Tomlyn
Tomlyn copied to clipboard
The decimal type is not serialized
There is no toString method in TomlFormatHelper defined for the decimal floating point type. Decimal numbers are then simply missing from the output.
Reading numbers into a decimal type works.
Cheers, Torsten
Toml (the spec) supports only binary64/double/f64 representable numbers. There's overlap between the numbers representable in binary64 and decimal, but both can express numbers that the other can't. This makes for a particularly challenging situation to implement, unless we were to use a string literal or something (which seems bad). I prototyped a solution that worked until the unit tests started testing decimal.MaxValue. It can't roundtrip, unfortunately.
Here's my branch that explored this: https://github.com/lilith/Tomlyn/tree/decimal-support Honestly the safest approach might be to explicitly document decimal is not supported, and also throw an exception on use.
Reading numbers into a decimal type won't work if the double is too small or large.
Honestly the safest approach might be to explicitly document decimal is not supported, and also throw an exception on use.
Yep, agreed. TOML was not meant for portable data but for easy configuration.