Stylecopanalyzers: Feature Request: Treat Warnings as Errors in certain configurations

Created on 14 Dec 2017  路  2Comments  路  Source: DotNetAnalyzers/StyleCopAnalyzers

We are currently switching from StyleCop Classic to Analyzers.
With StyleCop classic, we configured our projects, so that StyleCop issues were displayed as warnings during debug, and as errors during release builds. That way, we could work a bit easiering while developing and still could enforce the rules in the release build.
We would like some similiar setting for StyleCop Analyzers. Is anything like that planned?

question resolved

All 2 comments

That would be outside the scope of the project, but you could achieve this in two ways:

  • Enable the "Treat warnings as errors" within the project settings for release builds.
  • Use specific (custom) rule sets, where the debug rule set would contain warnings and the release rule set would contain errors.

For this project, we treat warnings as errors for command line builds, which automatically includes all the builds that run for GitHub pull requests. Here is the configuration section that triggers this behavior:

https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/709833993ef27ad0361487f02470023ba797c032/StyleCop.Analyzers/Directory.Build.props#L25-L28

Was this page helpful?
0 / 5 - 0 ratings