SEC0011: String can be compared with .IsBefore()
Cause
The code contains an expression like string.Compare(a, b, comparison) < 0
Rule description
Replace string.Compare(a, b, comparison) < 0
with a.IsBefore(b, comparison)
How to fix violations
- Add a using declaration for the
Stravaig.Extensions.Core
namespace if it does not already exist. - Replace any instance of
string.Compare(a, b, comparison) < 0
witha.IsBefore(b, comparison)
When to suppress warnings
If you prefer the original style of string check.
Example of a violation
if (string.Compare(a, b, StringComparison.OrdinalIgnoreCase) < 0)
{
// Perform work required when a is before b.
}