-
Notifications
You must be signed in to change notification settings - Fork 5k
[Analyzer] Using StartsWith instead of IndexOf == 0 #78608
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Tagging subscribers to this area: @dotnet/area-system-globalization Issue DetailsWe should write an analyzer that flags uses of IndexOf that's comparing the resulting index to 0, e.g.
|
Same with Contains and |
That already exists: |
CC @Youssef1313 |
The analyzer/fixer should identify both Category:Performance |
We should write an analyzer that flags uses of IndexOf that's comparing the resulting index to 0, e.g.
https://grep.app/search?q=%5C.IndexOf%5C%28.%2A%3F%5C%29%20%3D%3D%200®exp=true&case=true&filter[lang][0]=C%23
Such use would be much better off with StartsWith, as IndexOf will search the entire string vs StartsWith which will only compare at the beginning.
Performance rules Category
Severity = suggestion
The text was updated successfully, but these errors were encountered: