roslynator
roslynator copied to clipboard
RCS1155 String Comparison Bug
Product and Version Used: Roslynator 4.1.1 Visual Studio 17.3.1
Steps to Reproduce: I have installed Roslynator from the visual studio marketplace for Visual Studio 2022 and have configured the .editorconfig for RCS1155 string comparison analyzer.

Issue/Bug: The following code snippet should show a warning in the Error List to use StringComparison when comparing strings however this is not happening.
if (example == "hi")
{
return false;
}

Hi,
RCS1155 is meant to be used for cases that are in this file.
I think that convert
a == b
into
string.Equals(a, b, StringComparison.Ordinal)
is also possible but I don't think that is should enabled by default. It could be different analyzer or it could be configured with editorconfig option.
I have also tried the code below in Visual Studio which did not work.
var a = 1
var b = 2
if(a == b)
I have tried RCS1155 in a later version of Rider however i noticed that once i updated Rider to the latest version (22.2.2) it has stopped working despite having the code below in the csproj.
<TreatWarningsAsErrors>;RCS1155</>