-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
There's a significant amount of code that's apparently trying to perform case-insensitive comparisons by first lower-casing and then comparing against a lowercased string, e.g.
https://grep.app/search?q=.ToLower%28%29.Contains&filter[lang][0]=C%23
https://grep.app/search?q=.ToLower%28%29.IndexOf&filter[lang][0]=C%23
https://grep.app/search?q=.ToLower%28%29.StartsWith&filter[lang][0]=C%23
Less but still many for ToUpper with upper-case, e.g.
https://grep.app/search?q=.ToUpper%28%29.Contains&filter[lang][0]=C%23
https://grep.app/search?q=.ToUpper%28%29.IndexOf&filter[lang][0]=C%23
https://grep.app/search?q=.ToUpper%28%29.StartsWith&filter[lang][0]=C%23
and with the Invariant variations, e.g.
https://grep.app/search?q=.ToLowerInvariant%28%29.Contains&filter[lang][0]=C%23
We should write an analyzer that flags these patterns and recommends comparisons using a StringComparison instead.
Such analyzers will help avoid the allocations caused by ToLower/ToUpper calls.