-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Skip executing analyzers by default on local builds for solutions in the repo #44047
Skip executing analyzers by default on local builds for solutions in the repo #44047
Conversation
2a9722d
to
142a84f
Compare
This change skips executing analyzers by default on explicit builds (both inside VS and on command line prompt). This should speed up the overall build time of Roslyn.sln when building locally. The only time a developer would want analyzers to run locally outside the typing scenario is to compute the exact set of warnings for a specific project/solution before pushing your local changes to CI. They can now perform the following steps to achieve this: 1. On command line: Build with `/p:UseRoslynAnalyzers=true` or `/p:RunCodeAnalysis=true` 2. Inside VS: 1. Start VS with `%RoslynEnforceCodeStyle% = true`, all builds in VS should execute analyzers 2. Use `Run Code Analysis` command from `Analyze` menu on selected project/solution
142a84f
to
71716fd
Compare
@@ -103,7 +103,6 @@ stages: | |||
-officialSourceBranchName $(SourceBranchName) | |||
-officialIbcSourceBranchName $(IbcSourceBranchName) | |||
-officialIbcDropId $(IbcDropId) | |||
-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.
Analyzer execution has been switched from opt-out mode to opt-in mode in build scripts.
skipAnalyzers
flag has been replaced with runAnalyzers
flag, which defaults to false
. It is only explicitly set to true
for build-correctness
test leg.
… CI failure" This reverts commit 71716fd.
|
Thanks. I believe those are the only remaining references in scripts. I am not sure how to test the changes in |
Ah, case sensitive search tricked me! Fixing.. |
@mavasani Could you please prioritize getting required sign-offs and merging this PR ASAP? Thanks! |
Otherwise, default to 'true'. | ||
--> | ||
<PropertyGroup Condition="'$(UseRoslynAnalyzers)' == ''"> | ||
<UseRoslynAnalyzers Condition="'$(DesignTimeBuild)' != 'true' AND '$(ContinuousIntegrationBuild)' != 'true' AND !('$(RoslynEnforceCodeStyle)' == 'true' OR '$(RunCodeAnalysis)' == 'true')">false</UseRoslynAnalyzers> |
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.
When does $(RunCodeAnalysis)
get set to true
? Not familiar with the workflows that enable that property.
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 property is set to true when you execute "Run Code Analysis" context command in Visual Studio, either from top level "Analyze" menu OR from solution explorer context menu for project/solution: https://docs.microsoft.com/en-us/visualstudio/code-quality/how-to-run-code-analysis-manually-for-managed-code?view=vs-2019. Starting VS2019 16.5, this command force completes all the applicable analyzers on the selected project/solution.
I have merged the PR and will address any further feedback with a follow-up PR. Thanks! |
LGTM |
Overview
This change skips executing analyzers by default on explicit builds of solutions in this repo (both inside VS and on command line prompt). We will continue running analyzers for the following:
Correctness
leg to catch build breaking analyzer warnings. This is the core scenario where we need to execute analyzers for build time analyzer enforcement.This change should speed up the local build time of Roslyn.sln by ~2X.
Running analyzers locally after this change
The only time a developer would want to run analyzers locally, outside the IDE typing scenario, is to compute the exact set of warnings for a specific project/solution before pushing local changes to CI. They can now perform the following steps to achieve this:
build -runAnalyzers
at the root of the repo./p:UseRoslynAnalyzers=true
or/p:RunCodeAnalysis=true
.%RoslynEnforceCodeStyle% = true
, all builds in VS should execute analyzersRun Code Analysis
command fromAnalyze
menu on selected project/solutionPerf testing - build time measurements
Steps
restore
taskkill /F /IM MSBuild.exe
taskkill /F /IM VBCSCompiler.exe
msbuild /m /v:m /t:rebuild Roslyn.sln
msbuild /m /v:m /t:rebuild Roslyn.sln
Measurements
Master branch (commit 27654b0)
This PR branch
Functional testing
build.cmd
does not run analyzers.build.cmd -runAnalyzers
runs analyzers.msbuild Roslyn.sln
does not run analyzers.msbuild Roslyn.sln /p:UseRoslynAnalyzers=true
andmsbuild Roslyn.sln /p:RunCodeAnalysis=true
runs analyzersBuild
andRebuild
menu commands do not run analyzers.Run Code Analysis
command on individual projects force completes all applicable analyzers and diagnostics are populated in error list (NOTE: Solution level command seems to be causing a ServiceHub exception right now, I'll file a bug).build-correctness
test leg to fail with this warning treated as error./p:UseRoslynAnalyzers= false
was used.