Skip to content

Regression in double properties and NaN #11317

@bachratyg

Description

@bachratyg

Description

Throw helpers introduced in #8408 caused a behavioral regression thus some double properties no longer accept NaN as a value.

The original condition in net framework and up to net8 was value < 0, the new condition is double.IsNegative(value). The latter now causes an ArgumentOutOfRangeException. See dotnet/runtime#92834 (comment) on why these are not the same.

Reproduction Steps

// Get an existing visual
TextBox tb = ...
// Prepare some other text using the same parameters
FormattedText ft = new(...);
ft.LineHeight = tb.LineHeight;

Expected behavior

Property value is accepted

Actual behavior

ArgumentOutOfRangeException is thrown

Regression?

Yes. Works in .NET Framework and up to .NET 8

Known Workarounds

In the example above it's simple to fix as NaN is eventually treated as 0 (converted to int.MinValue here then ignored here) though this does not seem intentional.

Other properties may be more difficult to work around

Impact

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanted[up-for-grabs] Good issue for external contributorsregressionstatus: This issue is a regression from a previous build or release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions