StyleCop analyzes C# source code to enforce a set of style and consistency rules.
Questions tagged [stylecop]
643 questions
22
votes
7 answers
The field must have a documentation header - Style Cop - Code smell?
I was just running style cop against some of my code and got a few:
SA1600: The field must have a documentation header.
Now don't get me wrong I like style cop, it's great when you work on a project with more then one person but this rule seems a…

Nathan W
- 54,475
- 27
- 99
- 146
22
votes
3 answers
Is sa1200 All using directives must be placed inside the namespace (StyleCop) purely cosmetic?
Possible Duplicate:
Should Usings be inside or outside the namespace
sa1200 All using directives must be placed inside the namespace (StyleCop)
Is this just for code readibility or is there any actual advantage to doing so?
Does it help the GC…

Matt
- 25,943
- 66
- 198
- 303
22
votes
2 answers
Get Resharper to Consume StyleCop configuration
Our project already has a StyleCop configuration. I am using ReSharper and I would like to be able to have R# use the StyleCop settings.
I know that you can use StyleCopForResharper to build the settings in Resharper and export them as a StyleCop…

jlembke
- 13,217
- 11
- 42
- 56
21
votes
2 answers
Interpolate string c# 6.0 and Stylecop
I am using Stylecop version : 4.7.49.0
Has anyone used the latest interpolate string functionality in c# 6.0
example
var totalUnits = GetUnitsGetTotalIssuedShares(myId);
var testString = $"Test Units :{totalUnits}, have been shipped.";
When I…

MicroMan
- 1,988
- 4
- 32
- 58
21
votes
3 answers
StyleCop vs ReSharper and general coding-style questions
Just found StyleCop, looks like something worth using for my projects. Then I found out you could use it with ReSharper (a tool I've also never used). So I downloaded ReSharper, as well as StyleCop for ReSharper. I'm just a bit confused about it,…

Habaabiai
- 725
- 2
- 8
- 11
20
votes
2 answers
Is there a standard ReSharper code style definition that matches all the StyleCop requirements?
The ReSharper reformat code feature is very handy and flexible, particularly with the new code layout templating flexibility JetBrains have added in version 3.0.
Is there a standard set of code style settings for ReSharper which match the rules…

Daniel Fortunov
- 43,309
- 26
- 81
- 106
20
votes
4 answers
How can I configure Roslyn Analyzers in many projects?
I want to enforce code quality and consistent styling in my organization.
To do this I plan to add Roslyn Analyzers and StyleCop to my projects.
In order to meet with our agreed coding standards, these analyzers will need additional configuration.…

Jodrell
- 34,946
- 5
- 87
- 124
20
votes
4 answers
Warnings as Errors - does not apply to Stylecop warnings
I want to treat Stylecop warnings as errors, but it's not working for me.
My projects are configured to treat warnings as errors, and if I build with a real "compiler warning" it does indeed display a compiler error. But with a "Stylecop warning" it…

demoncodemonkey
- 11,730
- 10
- 61
- 103
20
votes
1 answer
StyleCop XML Documentation Header - Using 3 /// instead of 2 //
I am using XML documentation headers on my c# files to pass the StyleCop rule SA1633.
Currently, I have to use the 2 slash commenting rule to allow StyleCop to recognize the header. for example:
//

Adam Jenkin
- 4,142
- 6
- 25
- 31
19
votes
4 answers
How to use StyleCop with TeamCity
Has anyone had any success with running StyleCop from TeamCity?
I know StyleCop supports a command line mode, however i am not sure how this will integrate into the report output by TeamCity.
I've checked out this plugin found here:…

lysergic-acid
- 19,570
- 21
- 109
- 218
19
votes
2 answers
"CS8700: Multiple analyzer config files cannot be in the same directory" but only one StyleCop file
I'm trying to learn to use StyleCop on a personal project. It's not a very big one, and the solution structure is below:
- MySolution (2 of 2 projects)
- Solution Items
- .editorconfig
- .gitignore
- CODEOWNERS
-…

Metomorphose
- 434
- 3
- 14
19
votes
5 answers
Is it wrong to use braces for variable scope purposes?
I sometimes use braces to isolate a block of code to avoid using by mistake a variable later. For example, when I put several SqlCommands in the same method, I frequently copy-paste blocks of code, ending by mixing the names and executing twice some…

Arseni Mourzenko
- 50,338
- 35
- 112
- 199
19
votes
1 answer
Set ReSharper to put the 'using' import outside the namespace
I've ReSharper v9.0 installed on my VS. I also use StyleCop. I've disabled SA1200, so when I put the using statements outside the namespace, I don't get warned again. But when I add a reference via [alt]+[enter], which isn't available in using…

iroel
- 1,760
- 1
- 18
- 27
19
votes
5 answers
Visual Studio: temporarily disable StyleCop
Can you disable styleCop in VS?
Scenario:
Press "Disable StyleCop" button
Run/debug some test code
The button automatically, enable StyleCop again. Therefore you have to actively disable it again it you want to run without StyleCop.

Chris G.
- 23,930
- 48
- 177
- 302
18
votes
1 answer
Force ReSharper to use StyleCop settings for code cleanup
I saw similar questions but was unable to find the answer, even though some of them were marked as answered. I'm using ReSharper 6.1.1 and StyleCop 4.7.11.0. I put Settings.StyleCop file in the my solution's root folder. I unchecked documentation…

ptkvsk
- 2,096
- 1
- 25
- 47