SEC0001: Use String HasContent()
Cause
The code contains a !string.IsNullOrWhiteSpace(aString)
or string.IsNullOrWhiteSpace(aString) == false
Rule description
Replace !string.IsNullOrWhiteSpace(aString)
or string.IsNullOrWhiteSpace(aString) == false
with aString.HasContent()
for readability.
How to fix violations
- Add a using declaration for the
Stravaig.Extensions.Core
namespace. - Replace any instance of:
!string.IsNullOrWhiteSpace(aString)
withaString.HasContent()
string.IsNullOrWhiteSpace(aString) == false
withaString.HasContent()
When to suppress warnings
If you prefer the original style of string check.
Example of a violation
if (!string.IsNullOrWhiteSpace(aString))
{
// Do something conditional on the string having some content.
}