Erroneous SonarCSharp_S3256

My offending code:
nameof(MyEnum.MyEnumValue).Equals(stringVariable, StringComparison.InvariantCultureIgnoreCase)

nameof(MyEnum.MyEnumValue) is "MyEnumValue"

Neither of these strings are null or empty, so the recommendation to use string.IsNullOrEmpty is not correct.

Hi @jasondentler!

Not all patterns work for all repos / use cases. As this pattern is giving you false positives you can either ignore the issues or just disable the pattern so it stops giving you the false positives. You can find the steps to do this here

2 Likes