-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix regression in CodeAnalysisTreatWarningsAsErrors when set to false #6450
Fix regression in CodeAnalysisTreatWarningsAsErrors when set to false #6450
Conversation
Fixes [AB#1726853](https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1726853) dotnet#6427 re-implemented CodeAnalysisTreatWarningsAsErrors support using global config files instead of appending CA rule IDs to WarningsAsErrors and WarningsNotAsErrors properties. However, this new implementation only works as expected for `CodeAnalysisTreatWarningsAsErrors = true` case, but doesn't prevent escalating CA warnings to errors for `CodeAnalysisTreatWarningsAsErrors = false` and `TreatWarningsAsErrors = true` case. I am restoring the WarningsNotAsErrors logic deleted from dotnet#6427 to fix this case. I am also planning to file a separate tracking issue in Roslyn to see if we can implement this whole CodeAnalysisTreatWarningsAsErrors functionality in the compiler layer itself, instead of the current hybrid implementations in this repo, which seems to be quite a bit fragile.
<!-- | ||
Design-time target to handle 'CodeAnalysisTreatWarningsAsErrors = false' for the CA rule ids implemented in this package. | ||
Note that a similar 'WarningsNotAsErrors' property group is present in the generated props file to ensure this functionality on command line builds. | ||
--> | ||
<Target Name=""_CodeAnalysisTreatWarningsAsErrors"" BeforeTargets=""CoreCompile"" Condition=""'$(DesignTimeBuild)' == 'true' OR '$(BuildingProject)' != 'true'""> | ||
<PropertyGroup> | ||
<EffectiveCodeAnalysisTreatWarningsAsErrors Condition=""'$(EffectiveCodeAnalysisTreatWarningsAsErrors)' == ''"">$(CodeAnalysisTreatWarningsAsErrors)</EffectiveCodeAnalysisTreatWarningsAsErrors> | ||
<WarningsNotAsErrors Condition=""'$(EffectiveCodeAnalysisTreatWarningsAsErrors)' == 'false' and '$(TreatWarningsAsErrors)' == 'true'"">$(WarningsNotAsErrors);$(CodeAnalysisRuleIds)</WarningsNotAsErrors> | ||
</PropertyGroup> | ||
</Target> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same logic as in props? I'm not quite sure what is the need to wrap it in a target that runs only for design-time builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added earlier to account for a regression. I am just restoring the old functionality here for WarningsNotAsErrors
. Either way, I personally don't like any of the current CodeAnalysisTreatWarningsAsErrors
implementations. I am going to drive implementing this in the core analyzer driver in Roslyn and delete all the code we have in this repo related to CodeAnalysisTreatWarningsAsErrors
.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6450 +/- ##
==========================================
- Coverage 96.15% 96.14% -0.01%
==========================================
Files 1365 1365
Lines 317523 317523
Branches 10269 10269
==========================================
- Hits 305301 305296 -5
- Misses 9786 9789 +3
- Partials 2436 2438 +2 |
Fixes AB#1726853
#6427 re-implemented CodeAnalysisTreatWarningsAsErrors support using global config files instead of appending CA rule IDs to WarningsAsErrors and WarningsNotAsErrors properties. However, this new implementation only works as expected for
CodeAnalysisTreatWarningsAsErrors = true
case, but doesn't prevent escalating CA warnings to errors forCodeAnalysisTreatWarningsAsErrors = false
andTreatWarningsAsErrors = true
case. I am restoring the WarningsNotAsErrors logic deleted from #6427 to fix this case.I am also planning to file a separate tracking issue in Roslyn to see if we can implement this whole CodeAnalysisTreatWarningsAsErrors functionality in the compiler layer itself, instead of the current hybrid implementations in this repo, which seems to be quite a bit fragile.