Roslyn Analyzer can be used to detect patterns in your code and report them. It can also provide code fixes to automatically fix the issues.