1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-08 03:27:04 +09:00
Satori/docs/project/analyzers.md
Sven Boemer 56c427bb4d
Don't enable ILLink analyzers for unsupported TFMs (#87071)
* Don't enable ILLink analyzers for unsupported TFMs

This adds a condition to EnableSingleFileAnalyzer to prevent it from requiring
the ILLink pack that is only supported on netcoreapp3.0 and above.

Adding a condition on the TFM requires moving the setting into a targets file.

Also consolidates more of the analyzer logic into this file.

---------

Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
2023-06-08 10:10:58 -07:00

1.7 KiB

Adding new analyzers to the build

This repo relies on .NET Compiler Platform analyzers 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.

To add an analyzer package to the build:

  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.
  2. Add a PackageReference entry to https://github.com/dotnet/runtime/blob/main/eng/Analyzers.targets, e.g.
    <PackageReference Include="SonarAnalyzer.CSharp" Version="8.50.0.58025" PrivateAssets="all" />
    
  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 or CodeAnalysis.test.globalconfig.

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:

build.cmd

(or ./build.sh on Unix), warnings-as-errors can be disabled with:

build.cmd -warnAsError 0