DotNetAnalyzers / StyleCopAnalyzers

An implementation of StyleCop rules using the .NET Compiler Platform
MIT License
2.66k stars 507 forks source link

Best way to work with TreatWarningsAsErrors? #2906

Open yhvicey opened 5 years ago

yhvicey commented 5 years ago

When using StyleCop with TreatWarningsAsErrors, it will always treat StyleCop's warning as error. Is there anyway to make all stylecop's warning not been treated as error without changing TreatWarningsAsErrors to false?

Maybe WarningsNotAsErrors property would help resolve this - For example, StyleCop provides a full list of its warnings for users to append, or provide a switch to control if it should append the list to the property.

E.g.

<!-- In StyleCop nuget package -->
<PropertyGroup>
  <StyleCopWarningList>SA1000,SA1001,...</StyleCopWarningList>
</PropertyGroup>
<!-- In user code -->
<PropertyGroup>
  <WarningsNotAsErrors>$(WarningsNotAsErrors);$(StyleCopWarningList)</StyleCopWarningList>
</PropertyGroup>
vweijsters commented 5 years ago

You can change the severity of the StyleCop.Analyzers diagnostics to info using a custom rule set.

There is really not a lot that we can do about it, as the severity stuff is handled by Roslyn / Visual Studio.