Is there a way to cause using a certain type of Exception
to show as an error (or warning, or info) for .NET projects in Visual Studio?
I was thinking changing the .editorconfig file would do the trick, but even with the options available for code analysis I can't find a way to do this.
This is not a task for editorConfig alone, but requires StyleCop to be enabled as well. Rule CA1031 is designed for this task.
You can set in your .editorConfig
:
dotnet_code_quality.CA1031.disallowed_symbol_names = NullReferenceException
(If you don't want that people catch NullReferenceException
anywhere)
StyleCop is enabled on .NET 5.0 projects by default, for older projects, it must be enabled by including the appropriate nuget package.