-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add a new command line switch to skip analyzer execution #46669
Conversation
Fixes dotnet#40926 This support was added to `Microsoft.CodeAnalysis.targets` (ships with VS) in VS2019 16.5: https://docs.microsoft.com/en-us/visualstudio/code-quality/disable-code-analysis?view=vs-2019. However, the MSBuild property is not respected from 'dotnet' builds where this targets file is not imported (see dotnet#40926 (comment) for details). This change moves the skip analyzers logic down to `Microsoft.Managed.Core.targets` and core compiler layer so it is respected for all builds. As per offline discussions with Jared and Chris, we can no longer skip analyzer execution from MSBuild by removing the "Analyzer" items as these can include source generators, which should never be skipped (at least there are no current scenarios where we want to skip generators). Hence, we are adding a new command line compiler switch `/skipAnalyzers`, optionally followed by a `+` or `-`, to allow skipping analyzers. I verified the end-to-end functionality works fine by locally building `Microsoft.Net.Compilers.Toolset.Package` NuGet package and referencing it in a project.
@chsienki is added to the review. #Closed |
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.
@@ -50,6 +50,28 @@ | |||
</PropertyGroup> | |||
</Target> | |||
|
|||
<Target Name="_ComputeSkipAnalyzers" BeforeTargets="CoreCompile"> | |||
<!-- First, force clear non-user facing property '_SkipAnalyzers'. --> |
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.
Thanks for the quick reviews! |
Hello @mavasani! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
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.
Auto-approval
Fixes #40926
This support was added to
Microsoft.CodeAnalysis.targets
(ships with VS) in VS2019 16.5:https://docs.microsoft.com/en-us/visualstudio/code-quality/disable-code-analysis?view=vs-2019.
However, the MSBuild property is not respected from 'dotnet' builds where this targets file is not imported (see #40926 (comment) for details).
This change moves the skip analyzers logic down to
Microsoft.Managed.Core.targets
and core compiler layer so it is respected for all builds. As per offline discussions with Jared and Chris, we can no longer skip analyzer execution from MSBuild by removing the "Analyzer" items as these can include source generators, which should never be skipped (at least there are no current scenarios where we want to skip generators). Hence, we are adding a new command line compiler switch/skipAnalyzers
, optionally followed by a+
or-
, to allow skipping analyzers.I verified the end-to-end functionality works fine by locally building
Microsoft.Net.Compilers.Toolset.Package
NuGet package and referencing it in a project.