YamlDotNet icon indicating copy to clipboard operation
YamlDotNet copied to clipboard

Bugfix: Tag resolving for "int" and "float"

Open bernd5 opened this issue 4 years ago • 4 comments

Missing support for 10.3.2. Tag Resolution

-> only null and bool were "resolved" correctly

bernd5 avatar Apr 03 '20 14:04 bernd5

Is there a test case to exercise this functionality?

pensono avatar Apr 18 '20 04:04 pensono

If you deserialize a yaml file with following content, the values were interpreted not as numbers (you got them as string):

SomeIntValue: 42
SomeFloatValue: 12.1

Please have a look at YamlSpec 10.3.2. Tag Resolution.

Boolean and Null value deserialization was done fine already.

bernd5 avatar Apr 18 '20 08:04 bernd5

The section of the spec that you mention refers to the "Core" schema, which is not the default one that parser should provide. I don't think this should be the default behaviour. Once we implement proper support for schemas, we'll be able to select the "Core" schema and have the behaviour you desire.

aaubry avatar Apr 19 '20 11:04 aaubry

What is the default one that a parser should provide?

If you deserialize this yaml file and serialize it back you loose the type info. You get:

SomeIntValue: "42"
SomeFloatValue: "12.1"

In addition you could argue for bool and null equally. You could deserialze those values to the strings "" or "true", "false"... But this would be very bad...

bernd5 avatar Apr 19 '20 15:04 bernd5

This PR appears to be abandoned, it's over a year old. I'm going to close it.

EdwardCooke avatar Jan 13 '23 20:01 EdwardCooke