Back to Devexpress

CRR0013 - The member always returns the same value

coderushforroslyn-401451-static-code-analysis-analyzers-library-crr0013-member-always-returns-the-same-value.md

latest1.2 KB
Original Source

CRR0013 - The member always returns the same value

  • Feb 28, 2025

This analyzer detects members which return the same value.

csharp
public bool Test(bool condition) {
    if (condition)
        return false;
    return false;
}
vb
Public Function Test(ByVal condition As Boolean) As Boolean
    If condition Then Return False
    Return False
End Function

How to Fix the Issue

Change the method’s return statement.

csharp
public bool Test(bool condition) {
    if (condition)
        return false;
    return true;
}
vb
Public Function Test(ByVal condition As Boolean) As Boolean
    If condition Then Return False
    Return True
End Function

How to Enable the Diagnostic

Choose the Member always returns the same value issue in the Editor | Language | Code Analysis | Code Issues Catalog options page and check the Enabled checkbox.

See Also

Suppress Analyzers