Consider adding a rule to replace usages of StringComparison.InvariantCulture and StringComparison.InvariantCultureIgnoreCase with StringComparison.Ordinal and StringComparison.OrdinalIgnoreCase respectively. This aligns with the advice provided at that https://docs.microsoft.com/dotnet/standard/base-types/best-practices-strings:
Do not use string operations based on StringComparison.InvariantCulture in most cases. One of the few exceptions is when you are persisting linguistically meaningful but culturally agnostic data.
The same rule should also cover replacing usages of StringComparer.InvariantCulture and StringComparer.InvariantCultureIgnoreCase with StringComparer.Ordinal and StringComparer.OrdinalIgnoreCase respectively.
Using the InvariantCulture versions in almost all cases results in redundant operations that just add performance overhead.
Description
Consider adding a rule to replace usages of
StringComparison.InvariantCulture
andStringComparison.InvariantCultureIgnoreCase
withStringComparison.Ordinal
andStringComparison.OrdinalIgnoreCase
respectively. This aligns with the advice provided at that https://docs.microsoft.com/dotnet/standard/base-types/best-practices-strings:The same rule should also cover replacing usages of
StringComparer.InvariantCulture
andStringComparer.InvariantCultureIgnoreCase
withStringComparer.Ordinal
andStringComparer.OrdinalIgnoreCase
respectively.Using the
InvariantCulture
versions in almost all cases results in redundant operations that just add performance overhead.