-
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
Importing Microsoft.CodeAnalysis.targets costs ~3.5% of evaluation time of solution-wide design-time buld #22111
Comments
Not sure if this is compiler or FxCop targets... |
@tmeschter I know that for the legacy project system there are at least 2 places where we need the default ruleset and ruleset directory being set by this targets file:
We do not have the Code Analysis property page in the new project system (correct me if this has changed recently), but we do have the Analyzers dependencies node. Does the latter need the default ruleset? If so, we would still need to import this targets file. |
@mavasani The Analyzers node shouldn't care about whether or not the CodeAnalysisRuleSet property is defined. Mostly it cares about the settings from the file so we can update the Solution Explorer icons and Properties pane to reflect the effective severity, but it doesn't get those directly from the file. It gets them from the compiler layer, which is responsible for reading the rule set file (if any) and combining it with project-specific settings. The only time the Analyzers node looks at the file itself is when the user changes a diagnostic severity, but we can't modify the rule set because the project is using one of the defaults. In that case we copy the file to the project, and then apply the modification. I previously hardened this path to handle the possibility that no default rule set was specified, in which case we generate an empty project-local rule set file. I see two problems with not importing Microsoft.CodeAnalysis.targets, or importing it conditionally:
|
Do we support the CodeAnalysis property page in the new project system? I thought we did not.
The default ruleset only affects two scenarios:
|
Why does the commandline not have a default ruleset? I thought that was exactly what these targets provide? |
The value of the |
@Pilchie Yes, you are correct. I got confused that this targets was imported only in VS, but that is not the case. However, with the FxCop analyzers, now we have an option of packaging the default ruleset(s) along with the VSIX/NuGet and set the default in props. |
Can you expand on this? When we implemented analyzers we discussed this and decided that VSIX/NuGet packages should never include a .ruleset file because there is no way to compose them. Since they're specified through an MSBuild property only one can win, and the others will be ignored. Default severity should be set in the diagnostic itself, or if for some reason that can't be done, then by updating the |
@tmeschter - yes we would need the ruleset composition feature for it. |
See: dotnet/sdk#1586
3.5% of evaluation time (0.2% of just evaluating the import statement itself) is spent evaluating Microsoft.CodeAnalysis.targets inclusively:
<Import Project="$(CodeAnalysisTargets)" Condition="Exists('$(CodeAnalysisTargets)')" />
Every single project pays for this import regardless of whether they support or use CodeAnalysis (.NET Core for example, doesn't).
Note: that ~1.3% of this is being tracked by: #22110.
The text was updated successfully, but these errors were encountered: