Skip to content

Skip execution of analyzers reporting info and hidden diagnostics dur…#43546

Merged
mavasani merged 7 commits intodotnet:masterfrom
mavasani:SkipAnalyzersOnBuild
Apr 24, 2020
Merged

Skip execution of analyzers reporting info and hidden diagnostics dur…#43546
mavasani merged 7 commits intodotnet:masterfrom
mavasani:SkipAnalyzersOnBuild

Conversation

@mavasani
Copy link
Contributor

@mavasani mavasani commented Apr 21, 2020

…ing build

Closes #42166. Implements the design from #42166 (comment).

This PR is aimed towards improving the build performance in presence of analyzers that report Info (Suggestion) and/or Hidden diagnostics. Hidden diagnostics are never reported in build and Info diagnostics are only officially supported in presence of /errorlog, we will retain this support. The command line compilers do report Info diagnostics on command line today, but these are filtered away by MSBuild and are effectively never visible to users. This makes this a non-breaking scenario in .NET core build environment and an extreme corner case breaking change on desktop (clients relying on info diagnostics from raw csc/vbc output). Note that such clients would still have a workaround to get the prior behavior by enabling /errorlog. This change has been discussed with Jared and Andy, who are fine with the new semantics.

This optimization should improve build performance when users install the new IDE CodeStyle NuGet package (mostly hidden diagnostics) and the upcoming .NET5 analyzers package (has large number of info/hidden diagnostics).

Copy link
Contributor Author

@mavasani mavasani Apr 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All members moved to AnalyzerOptionsExtensions.cs

Copy link
Contributor Author

@mavasani mavasani Apr 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All deleted code here is moved to a shared extension method on AnalyzerOptions in AnalyzerOptionsExtensions.cs

…ing build

Closes dotnet#42166

This PR is aimed towards improving the build performance in presence of analyzers that report Info (Suggestion) and/or Hidden diagnostics. Hidden diagnostics are never reported in build and Info diagnostics are only officially supported in presence of /errorlog, we will retain this support. The command line compilers do report Info diagnostics on command line today, but these are filtered away by MSBuild and are effectively never visible to users. This makes this a non-breaking scenario in .NET core build environment and an extreme corner case breaking change on desktop (clients relying on info diagnostics from raw csc/vbc output). Note that such clients would still have a workaround to get the prior behavior by enabling /errorlog.

This optimization should improve build performance when users install the new IDE CodeStyle NuGet package (mostly hidden diagnostics) and the upcoming .NET5 analyzers package (has large number of info/hidden diagnostics).
@mavasani mavasani force-pushed the SkipAnalyzersOnBuild branch from cc9d220 to ffa7ab4 Compare April 21, 2020 22:16
@mavasani mavasani marked this pull request as ready for review April 21, 2020 23:57
@mavasani mavasani requested a review from a team as a code owner April 21, 2020 23:57
mavasani added a commit to mavasani/roslyn-analyzers that referenced this pull request Apr 22, 2020
1. Do not generate different global analyzer config files for build and live analysis. dotnet/roslyn#43546 will ensure that we do not need special logic in each analyzer package to disable hidden/suggestion analyzers in build - this will be baked into the compiler.
2. Update the contents of generated targets and editorconfig file as per the new design for global analyzer config: Everything for global analyzer config files will match regular analyzer config files (file name should be .editorconfig, existing MSBuild property "EditorConfigFiles" will be used, etc.), except for a special entry "is_global = true" to indicate global analyzer config.
@mavasani
Copy link
Contributor Author

FYI: 021468a Adds unit tests to explicitly guard the core performance optimization in this PR

@mavasani
Copy link
Contributor Author

Thanks @jaredpar. @dotnet/roslyn-compiler for an additional review.

@cston
Copy link
Contributor

cston commented Apr 23, 2020

            var isSuppressed = !diag.IsEnabledByDefault;

Can be moved into else.


Refers to: src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerManager.cs:320 in 021468a. [](commit_id = 021468a, deletion_comment = False)

@mavasani
Copy link
Contributor Author

var isSuppressed = !diag.IsEnabledByDefault;
Can be moved into else.

@cston I avoided that change to retain the ordering of comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support analyzers that are disabled by default in command line build but enabled in other hosts

4 participants