Skip to content

Incorrect NumberStyles validation in System.Decimal #126643

Description

@lilinus

Description

In #124139 support for hex-format for float/double/Half/BFloat16 was added, but not for decimal which seems to be in-line with discussions in #1630

The validation of NumberStyles parameter in decimal is incorrect.

Reproduction Steps

decimal.Parse("1.0", NumberStyles.AllowBinarySpecifier); // expected=throws, actual=throws
decimal.Parse("1.0", NumberStyles.AllowHexSpecifier); // expected=throws, actual=works
decimal.Parse(Encoding.UTF8.GetBytes("1.0"), NumberStyles.AllowBinarySpecifier); // expected=throws, actual=works
decimal.Parse(Encoding.UTF8.GetBytes("1.0"), NumberStyles.AllowHexSpecifier); // expected=throws, actual=works

Expected behavior

See above.

OR support for AllowHexSpecifier is implemented for decimal.

Actual behavior

See above

Regression?

Only affects .NET 11

Known Workarounds

No response

Configuration

No response

Other information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions