Closed
Description
Description
NET7 String.Equals shows inconsistent behavior in differences of target platform bitness, and Release or Debug.
const String v1 = "鉄";
var v2 = v1;
Console.WriteLine($"{v1 == v2}, {v1.Equals(v2, StringComparison.Ordinal)}, {v1.Equals(v2,StringComparison.OrdinalIgnoreCase)}");
foreach (var _ in Array.Empty<Object>())
{
//Do nothing
}
dotnet run -r win-x86 --no-self-contained -c Release
False, False, True
dotnet run -r win-x64 --no-self-contained -c Release
True, True, True
dotnet run -r win-x86 --no-self-contained -c Debug
True, True, True
dotnet run -r win-x64 --no-self-contained -c Debug
True, True, True
In addition, if you just comment out foreach, output will change.
const String v1 = "鉄";
var v2 = v1;
Console.WriteLine($"{v1 == v2}, {v1.Equals(v2, StringComparison.Ordinal)}, {v1.Equals(v2,StringComparison.OrdinalIgnoreCase)}");
// foreach (var _ in Array.Empty<Object>())
{
//Do nothing
}
dotnet run -r win-x86 --no-self-contained -c Release
True, True, True
Configuration
SDK 7.0.100
x86
Same behavior in local windows machine, Azure App Service (Windows)