Back to Devexpress

CRR0025 - Unreachable conditional code block (the inversed condition is already satisfied)

coderushforroslyn-118235-static-code-analysis-analyzers-library-crr0025-unreachable-conditional-code-block-the-inversed-condition-is-already-satisfied.md

latest1.1 KB
Original Source

CRR0025 - Unreachable conditional code block (the inversed condition is already satisfied)

  • Feb 28, 2025

This analyzer detects conditional statements that always evaluate to false because of a conditional statement above. A possible example is shown in the code snippet below.

csharp
if(condition) {
    if(!condition) { // CRR0025
        DoSomething();
    }
}
vb
If condition Then
    If Not condition Then ' CRR0025
        DoSomething()
    End If
End If

In the example given above, the DoSomething() method will never be executed. To check this, apply the Combine/Split Conditional(s) refactoring to one of the if statements. The combined conditional expression condition && !condition will always be false, which means that the body of the conditional statement will never be executed.

See Also

Suppress Analyzers