-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Globalization.PreferStringComparisonOverrideRule(git)
Assembly: Gendarme.Rules.Globalization
Version: git
This rule detects calls to method that could be changed to call an override accepting an extra System.StringComparison parameter. Using the override makes the code easier to maintain since it makes the intent clear on how the string needs to be compared. It is even more important since the default string comparison rules have changed between .NET 2.0 and .NET 4.0.
Bad example:
public bool Check (string name)
{
// it's not clear if the string comparison should be culture sensitive or not
return (String.Compare (name, "Software") == 0);
}
Good example:
public bool Check (string name)
{
return (String.Compare (name, "Software", StringComparison.CurrentCulture) == 0);
}
You can browse the latest source code of this rule on github.com
Note that this page was autogenerated (3/17/2011 1:55:44 PM) based on the xmldoc
comments inside the rules source code and cannot be edited from this wiki.
Please report any documentation errors, typos or suggestions to the
Gendarme Mailing List. Thanks!