Version Used:
Visual Studio 2026 v18.4.1
.NET 9
Steps to Reproduce:
- Use the following minimal code sample:
public static void Test(string? text)
{
text = text switch
{
"test" => "tesuto",
_ => text
};
if (text?.Length > 2) // CA1508
{
Console.WriteLine("Yay!");
}
}
Diagnostic Id:
CA1508: Avoid dead conditional code
Expected Behavior:
CA1508 should not get raised incorrectly
Actual Behavior:
CA1508 is being raised incorrectly
Version Used:
Visual Studio 2026 v18.4.1
.NET 9
Steps to Reproduce:
Diagnostic Id:
CA1508: Avoid dead conditional code
Expected Behavior:
CA1508 should not get raised incorrectly
Actual Behavior:
CA1508 is being raised incorrectly