I'm trying to work with a large opensource project that has a handful of Roslyn Code Analyzers. When I open the solution Visual Studio uses ~35% CPU for about 15 minutes. Using PerfView I've figured out that the code analyzers being run on the solution are bogging down Visual Studio.
I know it's possible to disable analyzers on a per-project basis but this solution contains over 100 projects so I'd rather not do this one-by-one.
My question(s):
To open this page, right-click the project node in Solution Explorer and select Properties. Select the Code Analysis tab. To disable source analysis at build time, uncheck the Run on build option. To disable live source analysis, uncheck the Run on live analysis option.
Right click on your project node in Solution Explorer, choose Properties. There is a Code Analysis tab near the bottom. Click that and uncheck "Enable Code Analysis on Build".
. NET Compiler Platform (Roslyn) Analyzers inspect your C# or Visual Basic code for style, quality, maintainability, design, and other issues. This inspection or analysis happens during design time in all open files. Analyzers are divided into the following groups: Code style analyzers are built into Visual Studio.
Roslyn is a collection of open-source compilers, code analysis and refactoring tools which work with C# and Visual Basic source codes. This set of compilers and tools can be used to create full-fledged compilers, including, first and foremost, source code analysis tools.
You can disable analyzers on a per-project basis.
To do it, right click on Project>References>Analyzers in the Solution Explorer and hit Open Active Rule Set
You can disable individual analyzers or entire bundles of analyzers.
This creates a <ProjectName>.ruleset
file and modifies the <ProjectName>.csproj
, which means that you will share this configuration with your team unless you exclude these changes from source control.
Note: Changes are applied after you close and re-open the solution.
Changes to the .csproj
:
<Project ...> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <CodeAnalysisRuleSet>Example.ruleset</CodeAnalysisRuleSet>
Example.ruleset
file:
<?xml version="1.0" encoding="utf-8"?> <RuleSet Name="Rules for WpfApplication1" Description="Code analysis rules for WpfApplication1.csproj." ToolsVersion="14.0"> <Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp" RuleNamespace="Microsoft.CodeAnalysis.CSharp"> <Rule Id="AD0001" Action="None" /> <Rule Id="CS0028" Action="None" /> ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With