Skip to content

Commit 1b22d37

Browse files
Update analyzers.md (#79768)
* Update analyzers.md * Apply suggestions from code review * Update analyzers.md * Apply suggestions from code review Co-authored-by: Stephen Toub <[email protected]> * Apply suggestions from code review --------- Co-authored-by: Stephen Toub <[email protected]>
1 parent e713885 commit 1b22d37

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

docs/project/analyzers.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
## Adding new analyzers to the build
22

3-
This repo relies on [.NET Compiler Platform analyzers](https://docs.microsoft.com/en-us/visualstudio/code-quality/roslyn-analyzers-overview?view=vs-2019) to help validate the correctness, performance, and maintainability of the code. Several existing analyzer packages are wired into the build, but it is easy to augment the utilized packages in order to experiment with additional analyzers.
3+
This repo relies on [.NET Compiler Platform analyzers](https://learn.microsoft.com/visualstudio/code-quality/roslyn-analyzers-overview) to help validate the correctness, performance, and maintainability of the code. Several existing analyzer packages are wired into the build, but it is easy to augment the utilized packages in order to experiment with additional analyzers.
44

55
To add an analyzer package to the build:
6-
1. Select a package you want to employ, for example https://www.nuget.org/packages/SonarAnalyzer.CSharp/. This analyzer package's name is `SonarAnalyzer.CSharp` and the latest version as of this edit is `7.15.0.8572`.
7-
2. Add a PackageReference entry to https://github.com/dotnet/runtime/blob/main/eng/Analyzers.props, e.g.
8-
```XML
9-
<PackageReference Include="SonarAnalyzer.CSharp" Version="7.15.0.8572" />
10-
```
11-
3. After that point, all builds will employ all rules in that analyzer package that are enabled by default. Rules can be disabled by adding entries to the https://github.com/dotnet/runtime/blob/main/src/libraries/CodeAnalysis.ruleset file, e.g.
12-
```XML
13-
<Rules AnalyzerId="SonarAnalyzer.CSharp" RuleNamespace="SonarAnalyzer.CSharp">
14-
<Rule Id="S1006" Action="None" />
15-
<Rule Id="S1075" Action="None" />
16-
...
17-
</Rules>
18-
```
6+
1. Select a package you want to employ, for example https://www.nuget.org/packages/SonarAnalyzer.CSharp/. This analyzer package's name is `SonarAnalyzer.CSharp` and the latest version as of this edit is `8.50.0.58025`.
7+
2. Add a `PackageReference` entry to <https://github.com/dotnet/runtime/blob/main/eng/Analyzers.props>, e.g.
8+
```XML
9+
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.50.0.58025" PrivateAssets="all" />
10+
```
11+
3. After that point, all builds will employ all rules in that analyzer package that are enabled by default. You can change the severity for rules by adding entries to the globalconfig files [CodeAnalysis.src.globalconfig](https://github.com/dotnet/runtime/blob/main/eng/CodeAnalysis.src.globalconfig) or [CodeAnalysis.test.globalconfig](https://github.com/dotnet/runtime/blob/main/eng/CodeAnalysis.test.globalconfig).
1912

20-
The build system in this repo defaults to treating all warnings as errors. It can be helpful when enabling a new rule to temporarily allow warnings to be warnings rather than errors, while you proceed to fix all of them across the repo. Instead of building from the root of the repo with:
13+
The build system in this repo defaults to treating all warnings as errors. It can be helpful when enabling a new rule to temporarily allow warnings to be warnings rather than errors, while you proceed to fix all of them across the repo. Instead of building from the root of the repo with:
2114
```
2215
build.cmd
2316
```

0 commit comments

Comments
 (0)