A .NET Standard project with a few analyzers and code fix providers.
- RequiredPropertyAnalyzer: An analyzer that reports non-nullable properties that are not required.
- OneOfSwitchExpressionAnalyzer: An analyzer that reports when a switch expression on a OneOf type is incomplete.
- Add the NuGet package to your project.
- ???
- Profit!
By default, all analyzers are configured with severity warning
.
If you have the msbuild property <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
set (which you should), then all analyzers will report error
.
If you want to change the severity of any analyzer (From this package or otherwise), you can do so in your project's .editorconfig
file.
In the following example, I will change the severity of the RequiredPropertyAnalyzer
which has the Analyzer Id of OXX0001
. (You can see all IDs provided by this package here)
# Set the severity to `none`. This will disable the analyzer and code fixers.
dotnet_diagnostic.OXX0001.severity = none
# Set the severity to `error`. This will cause the analyzer to report an error.
dotnet_diagnostic.OXX0001.severity = error
See here for more information, but be aware that not everything in that document is supported by Rider.
There aren't any 🤷🏻
If, after cloning this repository, you do not see the analyzer warnings in the IDE, you may need to build the project first.