Feature request: New analyzer and fix: Replace String.Compare(.......) == 0 with String.Equals
Open
Area-Analyzers
Feature Request
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 294
- Avg merge
- 2h 30m
- Merged PRs (30d)
- 4
Description
In some case the `String.Compare` where the result is checked for equality to zero could be replaced with `String.Equals`. At least the variants that take `string, string`:
```
String.Compare(a, b) == 0;
String.Equals(a, b, StringComparison.CurrentCulture);
```
And `string, string, bool`:
```
String.Compare(a, b, true) == 0;
String.Equals(a, b, StringComparison.CurrentCultureIgnoreCase);
```
I'm not really sure about the other overloads of `String.Compare` though.
It would be handy to have an analyzer that reports these cases and also a fix for these.
Contributor guide
Assessment
This issue has not been assessed yet.