-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Description
There is a change in how a null valued decimal?
behaves in 8.0.5 compared to previous version of the sdk/runtime.
I'm seeing the result of nullDecimalVariable == 0.00m
to be equal to true
in 8.0.5 (SDK 8.0.300) but was false
in previous versions.
Reproduction Steps
I created a simple new console application using dotnet new console
and pasted the following code into it.
decimal? v = 0.00m;
Console.WriteLine(v == decimal.Zero); // True in both 8.0.205 and 8.0.300
v = null;
Console.WriteLine(v == decimal.Zero); // False in both 8.0.205 and 8.0.300
Console.WriteLine(v == 0.00m); // False in 8.0.205 and true in 8.0.300
I also added a global.json file to control which version of the dotnet SDK it was running against. I swapped between 8.0.205 and 8.0.300 which are the two versions of 8 I have installed. 8.0.205 was installed with visual studio, and I manually installed 8.0.300 via the SDK download to reproduce this bug.
I was only able to reproduce this using the command line dotnet run
. Running in visual studio did not reproduce this issue. It is not only occurring on my machine. We had a test failure with the same root cause as this minimal repo on our two different dedicated build machines.
Expected behavior
I expected null == 0.00m
to return false as shown in 8.0.205
Actual behavior
null == 0.00m
is returning true as shown in 8.0.300
Regression?
Yes. I tried on the previous SDK version of 8.0.205 and it works.
Known Workarounds
No response
Configuration
Dotnet 8.0.5 (SDK 8.0.300)
System Information:
Edition Windows 11 Pro
Version 23H2
Installed on 4/15/2024
OS build 22631.3447
Experience Windows Feature Experience Pack 1000.22688.1000.0
Other information
No response