Reputation:
For example we don't want our developers to use string.Contains
; instead they should use string.IndexOf
.
Is it possible to mark string.Contains
obsolete?
Is it possible to hide the method from IntelliSense?
Is there any (visual studio) tool catching and preventing the use of a .net method?
Upvotes: 3
Views: 139
Reputation: 20571
There are a few approaches you can take.
string.IndexOf
is preferred.pull requests
to review code before merge to master (assuming you're using git
). If you want feedback whilst coding, you can implement Convention Tests or as suggested in the comments a Rosylyn Analyser.
I recently wrote a Rosylyn Analyser for my DateTimeProvider package - the analyser picks up usages of DateTime
and suggests DateTimeProvider
.
Upvotes: 4