An open API service indexing awesome lists of open source software.

https://github.com/cezarypiatek/dotnetcodeanalysisessentialsetup

A quick guideline how to setup static code analysis for dotnet project with a list of essential analyzer packages.
https://github.com/cezarypiatek/dotnetcodeanalysisessentialsetup

Last synced: 7 months ago
JSON representation

A quick guideline how to setup static code analysis for dotnet project with a list of essential analyzer packages.

Awesome Lists containing this project

README

          

# Dotnet code analysis essential setup
A quick guideline how to setup static code analysis for dotnet project with a list of essential analyzer packages.

[Overview of .NET source code analysis](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview?tabs=net-7)

## How to enable built-in static code analysis

Add [Directory.Build.props](https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2022) file with the content as below in the same directory as solution file:

```xml



true

true

Recommended




all
runtime; build; native; contentfiles; analyzers





```

## How to setup severity for a particular rule

### Using dedicated editor for .editorconfig

![](setup_editorconfig.jpg)

### Using solution explorer

![](setup_solution_explorer.jpg)

### Directly from code editor

![](setup_code_editor.jpg)

### Manually edit `.editorconfig` file

If you are not using VisualStudio then you can configure specific analyzer by manually changing content of `.editorconfig` file

```editorconfig
[*.cs]

# CA1012: Abstract types should not have public constructors
dotnet_diagnostic.CA1012.severity = error
```