Back to Devexpress

CRR0018 - Suspect assignment reversal

coderushforroslyn-118133-static-code-analysis-analyzers-library-crr0018-suspect-assignment-reversal.md

latest784 B
Original Source

CRR0018 - Suspect assignment reversal

  • Feb 28, 2025

This analyzer detects reassignment statements that never change the variable value. The code snippet below shows an example:

csharp
string t = name;
name = t; // CRR0018
vb
Dim t As String = name
name = t ' CRR0018

The second assignment statement is redundant, because the name variable does not change. Remove the second assignment statement to resolve this issue:

csharp
string t = name;
vb
Dim t As String = name

See Also

Suppress Analyzers