roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

RCS1155 String Comparison Bug

Open VisualStudioHero opened this issue 3 years ago • 2 comments
trafficstars

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.

image

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;
  }

image

VisualStudioHero avatar Aug 18 '22 07:08 VisualStudioHero

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.

josefpihrt avatar Aug 22 '22 12:08 josefpihrt

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</>

VisualStudioHero avatar Aug 25 '22 12:08 VisualStudioHero