I am currently unsure if its really a roslyn bug or a c# bug or both.
Version Used:
Microsoft Visual Studio Enterprise 2022
Version 17.0.0
VisualStudio.17.Release/17.0.0+31903.59
Microsoft .NET Framework
Version 4.8.04084
dotnet 6 / C# 10
Steps to Reproduce:
Code:
var (isEdge, moreOnes) = (true, false);
char? expected_a = isEdge ? null : moreOnes ? '1' : '0';
char? expected_b = isEdge ? null : moreOnes ? '0' : '1';
(char? expected_a_01, char? expected_b_01) = isEdge ? default : moreOnes ? ((char?)'1', (char?)'0') : ('0', '1');
(char? expected_a_02, char? expected_b_02) = isEdge ? default : moreOnes ? ('1', '0') : ('0', '1');
Debug.Assert(expected_a == expected_a_01 && expected_a == expected_a_02);
Debug.Assert(expected_b == expected_b_01 && expected_b == expected_b_02);
Expected Behavior:
expected_a, expected_a_01 and expected_a_02 should be equal. (Namely, null)
The analyzer tells me, that both casts are redundant.
Actual Behavior:
expected_a_02 and expected_b_02 both have the value 0
I am currently unsure if its really a roslyn bug or a c# bug or both.
Version Used:
Steps to Reproduce:
Code:
Expected Behavior:
expected_a,expected_a_01andexpected_a_02should be equal. (Namely, null)The analyzer tells me, that both casts are redundant.
Actual Behavior:
expected_a_02andexpected_b_02both have the value0