Skip to content

Inconsistency when parsing numbers with underscores #1058

@fh-yuxiao-zeng

Description

@fh-yuxiao-zeng

Describe the bug
YAML 1.1 allows to have underscore in number representations, like 123_456 (int) and 123_456.78 (float).

However, this seems partially supported in YamlDotNet.

Underscore is supported when a tag (!!int or !!float) is specified. But when AttemptingUnquotedStringTypeDeserialization is turned on while the tag is missing, the type is not properly inferred.

To Reproduce
Please check this fiddle: https://dotnetfiddle.net/uL0fls

I feel the regular expression here is not sufficient: https://github.com/aaubry/YamlDotNet/blob/master/YamlDotNet/Serialization/NodeDeserializers/ScalarNodeDeserializer.cs#L356

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions