Back to Devexpress

CRR0052 - String interpolation can be used

coderushforroslyn-401178-static-code-analysis-analyzers-library-crr0052-string-interpolation-can-be-used.md

latest1.2 KB
Original Source

CRR0052 - String interpolation can be used

  • Feb 28, 2025

This analyzer identifies composed string expressions which can be converted to interpolated strings. Interpolated strings are easier to read than formatted strings.

csharp
return "Found record at the position " + i;
vb
Return "Found record at the position " & i

To fix this issue, use the interpolated string instead of the composed string expression.

csharp
return $"Found record at the position {i}";
vb
Return $"Found record at the position {i}"

Call the Convert to String Interpolation refactoring to replace the composed string with an interpolated string. To do it in different places at once, use the Code Cleanup feature with the Convert to String Interpolation rule enabled.

See Also

Suppress Analyzers