Open AnthonyMastrean opened 1 week ago
Diagnostic ID: CA1508: Avoid dead conditional code
Avoid dead conditional code
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 5.0.100
The analyzer warns on the below code despite no condition that would indicate value is not null.
value
static class Ca1508FalsePositive { static void Example(string? value) { _ = value switch { _ => value?.Trim(), }; } }
No warning!
Warning!
'value' is never 'null'. Remove or refactor the condition(s) to avoid dead code.
Might be related to #6893
Analyzer
Diagnostic ID: CA1508:
Avoid dead conditional code
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 5.0.100
Describe the bug
The analyzer warns on the below code despite no condition that would indicate
value
is not null.Steps To Reproduce
Expected behavior
No warning!
Actual behavior
Warning!
Additional context
Might be related to #6893