Questions tagged [stylecop]

StyleCop analyzes C# source code to enforce a set of style and consistency rules.

643 questions
35
votes
9 answers

Can StyleCop automatically fix anything?

I've decided to start running StyleCop on a medium sized project and am getting over 1000 warnings. Is there a quick easy way to fix most of these warnings? Most of the warnings could easily have been automated to resolve and would save me a lot of…
Ben S
  • 68,394
  • 30
  • 171
  • 212
33
votes
1 answer

How to exclude private members from StyleCop rule SA1600

Does anyone know how to change the StyleCop rule SA1600 that says elements must be documented so that it only applies to properties and not to private members? Our ORM (DevExpress XPO) requires that you have private members for all public properties…
Steven Evers
  • 16,649
  • 19
  • 79
  • 126
31
votes
6 answers

Stop Visual Studio from putting using directives outside namespace

Is there a setting in Visual Studio (or ReSharper) that allows you to specify what namespaces should be default and which scope they are put in? The default for an MVC project for example is using System; using System.Collections.Generic; using…
dav_i
  • 27,509
  • 17
  • 104
  • 136
29
votes
3 answers

Where is the Stylecop configuration file?

I've installed Stylecop via NuGet. I wish to disable some rules, and I know this can be done via a configuration file from what I've read. However, I can't find the file anywhere, and there seems to be little documentation describing where to create…
user9993
  • 5,833
  • 11
  • 56
  • 117
28
votes
7 answers

StyleCop SA1124 DoNotUseRegions is reasonable?

SA1124 DoNotUseRegions suggest that region should not be used anywhere. Is it really reasonable? I think region is a way to group relative code together and make large class easy to read, for example, if you generate interface method for a class…
Yanhua
  • 541
  • 5
  • 9
27
votes
3 answers

StyleCop integration with Visual Studio 2015 RC

I want to integrate my instance of VS 2015 RC with StyleCop in the way that I have StyleCop menu options [Run StyleCop, Run StyleCop (Rescan All), StyleCop Settings] available when right clicking on project in Solution Explorer. Installing…
leszek
  • 271
  • 1
  • 3
  • 5
27
votes
2 answers

CodeMaid vs Stylecop usings organisation

I am using StyleCop for a quite a while (and I am used to it). Friend of mine recommended me to also try CodeMaid. First thing I've noticed is difference in usings organisation. Stylecop orders usings in alphabetical order where System usings are…
Kajiyama
  • 3,393
  • 8
  • 26
  • 38
27
votes
3 answers

How do I integrate StyleCop 4.7 with Visual Studio 2013?

I really want to use StyleCop with my Visual Studio 2013, but unfortunately it won't work. I've installed the 4.7 version from the official site, checking all options, both VS Studio integration and MSBuild integration, following the precise…
FerdieQO
  • 465
  • 1
  • 5
  • 11
26
votes
3 answers

Exclude file from StyleCop analysis: "auto-generated" tag is ignored

At the beginning of a C# file, I have added: //----------------------------------------------------------------------- // // Copyright © Some Company, 2011 // //
Daniel Daranas
  • 22,454
  • 9
  • 63
  • 116
25
votes
6 answers

CA1500 vs. SA1309 - Which one wins?

I'll prefix by saying that I understand that both Code Analysis and StyleCop are meant as guidelines, and many people chose to ignore these anyway. But having said that, I'd like to see what the general consensus is with regard to these two…
Jerad Rose
  • 15,235
  • 18
  • 82
  • 153
25
votes
1 answer

How to globally disable file headers documentation in ReSharper plugin for Visual Studio

Environment I am using Microsoft Visual Studio 2013 Update 4 with ReSharper 9.0 Update 1. I have ReSharper.StyleCop (for R# 9) (https://github.com/kubiix/ReSharper.StyleCop) ReSharper plugin installed version 4.7.50-beta3: The problem Operations…
23
votes
6 answers

At what point do Stylecop settings stop being useful and start becoming annoying?

I work in a team where we use extensive ruleset in StyleCop and I am wondering what are the thoughts on the general point where such a tool stops being useful and starts becomes annoying. We also use GhostDoc so code is riddled with XML comments…
Peter Kelly
  • 14,253
  • 6
  • 54
  • 63
22
votes
2 answers

How to get Visual Studio quick comments to add a space after the double slash to avoid SA1005?

In Visual Studio, I have a block of code. I highlight it and use Ctrl+k+c to comment out the block. That adds "//" at the start of every line I highlighted. I then try to submit my code... and I run into StyleCop rule "SA1005" that requires all //…
srm
  • 3,062
  • 16
  • 30
22
votes
5 answers

How can you force StyleCop to ignore a file?

I've included a 3rd party .cs file in my code. It doesn't comply with StyleCop's rules but I desperately need to be able to exclude it from StyleCop's checks but none of the methods I've found so far will work. Three methods are documented here:…
NickG
  • 9,315
  • 16
  • 75
  • 115
22
votes
6 answers

How to disable Style Cop visual studio extension?

How to disable the Style Cop visual studio extension? It's not listed in Tools / Extensions or in Tools / Add-in manager
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
1
2
3
42 43