From: Stephen Toub Date: Thu, 1 Aug 2019 21:07:40 +0000 (-0400) Subject: Add doc on adding analyzers to corefx build (dotnet/corefx#39960) X-Git-Tag: submit/tizen/20210909.063632~11031^2~791 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb4d480ed5a4d2df58f6c4395a4c4613de641d1c;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Add doc on adding analyzers to corefx build (dotnet/corefx#39960) * Add doc on adding analyzers to corefx build * Address PR feedback Commit migrated from https://github.com/dotnet/corefx/commit/6b21afcb486552ab6cc25e1f198de11502b6d8b6 --- diff --git a/docs/libraries/project-docs/analyzers.md b/docs/libraries/project-docs/analyzers.md new file mode 100644 index 0000000..5a3840c --- /dev/null +++ b/docs/libraries/project-docs/analyzers.md @@ -0,0 +1,27 @@ +## Adding new analyzers to the build + +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. + +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 `7.15.0.8572`. +2. Add a PackageReference entry to https://github.com/dotnet/corefx/blob/master/eng/Analyzers.props, e.g. +```XML + +``` +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/corefx/blob/master/src/CodeAnalysis.ruleset file, e.g. +```XML + + + + ... + +``` + +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 +```