In VisualStudio 2012, creating a WPF solution, attempting to run stylecop on entire solution, the output reads
------ StyleCop 4.7 (build 4.7.59.0) started ------
Pass 1: testProject - \App.xaml.cs
Pass 1: testProject - \Modules\Administration\Models\DocumentClass.cs
Pass 1: testProject - \Modules\Administration\Models\DocumentType.cs
Pass 1: testProject - \Modules\Administration\Models\LetterGroup.cs
Pass 1: testProject - \Modules\Administration\Models\LetterType.cs
------ StyleCop cancelled ------
Why do I get this message? Did the process complete? where do I find the results?
StyleCop is no longer a Visual Studio plugin, it can be used outside Visual Studio too. For example, here?s the output of our project when built using the command-line command ?dotnet build?: See how our build succeeded, but the stylecop warnings are listed?
Configuring StyleCop is done in two optional steps. First, you can use rule set files to configure which rules are checked and how strongly you feel about them. Second, you can add a stylecop.json file to your project to fine-tune some rules.
Stylecop.json The stylecop.json file is a settings file to further configure StyleCop. The easiest way to add the file is to open a file that violates rule SA1633. This is the rule that requires a file header (e.g., a copyright notice).
StyleCop used to be a Visual Studio plugin and a NuGet package. You can still use this in Visual Studio 2019, but the current recommended way to use StyleCop is to use the Roslyn-based analyzers.
StyleCop will be cancelled if the warnings are over 1000. Another problem is the ErrorList by default is showing the error for "Build Only"
Below is the step to make the warning appear: (*** Please note that The example below is using VS2017)
1) “StyleCop cancelled” with no reason states in the Output message:
2) Open the [Error List] tab and you will see nothing if the [Show issue generated] combo-box is "Build Only"
3) Change the [Show issue generated] combo-box to "Build + Intellisense":
4) If you still see nothing, maybe the filter is on, click the "Clear All Filters" button to clear all filters:
5) And you should be able to see all of the warnings now:
6) You may want to reduce the warnings by removing the unwanted rules, right-click on the project and choose “Properties.” In the screen that just opened, select “Code Analysis”:
6) By default, the “Microsoft Managed Recommended Rules” will be selected. Click on “Open” and you’ll see a long list of rules you can select or deselect:
Take a look at the "Error List" tab. I'm pretty sure you'll find that there are 1000 warnings. If that number is reached, StyleCop stops. And I'm not aware that you can change that number.
Fix the style violations or disable the rules you don't want/need to get below 1000. Then StyleCop will run to the end.
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