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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With