Questions tagged [stylecop]

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

stylecop
Filter by
Sorted by
Tagged with
2406 votes
15 answers
280k views

Should 'using' directives be inside or outside the namespace in C#?

I have been running StyleCop over some C# code, and it keeps reporting that my using directives should be inside the namespace. Is there a technical reason for putting the using directives inside ...
benPearce's user avatar
  • 38.1k
262 votes
23 answers
147k views

Keyboard shortcuts are not active in Visual Studio with Resharper installed

I have Visual Studio 2012 + Resharper 7.1.1000.900 + StyleCop 4.7.44 installed. The problem is that no shortcuts are active since Resharper was installed. For example: I can still rename via '...
Julia Meshcheryakova's user avatar
101 votes
5 answers
37k views

Stylecop vs FXcop

Has Stylecop superseded FXcop? Which product should we be using with Visual Studio 2008?
JL.'s user avatar
  • 80.2k
81 votes
3 answers
49k views

Disabling StyleCop rules

I'm using StyleCop. But there a couple of rules I want to ignore, for instance using this. in front of class members. How do I turn off a StyleCop rule. I've looked but can't find how to do it.
AJM's user avatar
  • 32.3k
73 votes
3 answers
43k views

Visual Studio Code Analysis vs StyleCop + FxCop

I used previously StyleCop + FxCop on my Visual Studio's projects. But now I am testing Visual Studio Code Analysis tool, which is easier to integrate into MSBuild, and I have found that this tools ...
Jader Dias's user avatar
  • 89.3k
71 votes
9 answers
24k views

Why does StyleCop recommend prefixing method or property calls with "this"?

I have been trying to follow StyleCop's guidelines on a project, to see if the resulting code was better in the end. Most rules are reasonable or a matter of opinion on coding standard, but there is ...
Mathias's user avatar
  • 15.3k
66 votes
3 answers
20k views

The mystery of stuck inactive msbuild.exe processes, locked Stylecop.dll, Nuget AccessViolationException and CI builds clashing with each other

Observations: On our Jenkins build server, we were seeing lots of msbuild.exe processes (~100) hanging around after job completion with around 20mb memory usage and 0% CPU activity. Builds using ...
Jon Rea's user avatar
  • 9,397
65 votes
7 answers
28k views

TemporaryGeneratedFile_[guid] in /obj/debug breaking build

I have 3 temporary files being created in obj/debug: E.g. TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs ...
NikolaiDante's user avatar
  • 18.6k
61 votes
12 answers
63k views

How to suppress a StyleCop warning?

I'm using StyleCop and want to suppress some warning which does not suit my style. I prefer to have solution for 1) in-line code suppressing 2) global setting suppressing I've searched the internet ...
Nam G VU's user avatar
  • 34.1k
60 votes
7 answers
18k views

Transfer all ReSharper Settings between PCs

I was wondering if there is a way to copy ALL my settings from ReSharper (including the StyleCop for ReSharper settings and the keyboard bindings I have set for ReSharper) from one PC to another?
Chris Watts's user avatar
  • 2,314
42 votes
2 answers
6k views

Resharper indenting the XML documentation text on code cleanup?

I am using Resharper 7.1 with the StyleCop plugin. I am not sure if this is a bug, but, I am confused because the code cleanup behaves differently when text is selected prior to the cleanup operation....
user avatar
42 votes
2 answers
28k views

What's the proper way to comment a constructor in a generic class?

What's the proper way to comment this? /// <summary> /// Initializes a new instance of the <see cref="Repository"/> class. /// </summary> /// <param name="...
mservidio's user avatar
  • 12.9k
41 votes
6 answers
15k views

C# - StyleCop - SA1121: UseBuiltInTypeAlias - Readability Rules

Not found it in StyleCop Help Manual, on SO and Google so here it is ;) During StyleCop use I have a warning: SA1121 - UseBuiltInTypeAlias - Readability Rules The code uses one of the basic ...
binball's user avatar
  • 2,315
38 votes
2 answers
11k views

Code Cleanup - tool to move all using statements inside namespace in all cs files in my solution?

After writing a whole bunch of code - i am finally waking up to adding CA and StyleCop to my solution. By default all files (a lot of them) in my solution have using statements at the top of the file ...
MoXplod's user avatar
  • 3,823
38 votes
6 answers
19k views

Disable StyleCop for specific lines

We're using StyleCop in our C# projects. In some cases we'd like to avoid the rules though. I know you can add // <auto-generated /> in the beginning of the file to make StyleCop ignore it. ...
stiank81's user avatar
  • 25.6k
36 votes
9 answers
19k views

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 ...
Ben S's user avatar
  • 68.8k
33 votes
1 answer
12k views

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 ...
Steven Evers's user avatar
  • 16.9k
31 votes
6 answers
19k views

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 ...
dav_i's user avatar
  • 27.8k
29 votes
3 answers
35k views

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 ...
user9993's user avatar
  • 6,001
28 votes
7 answers
9k views

StyleCop SA1124 DoNotUseRegions is reasonable? [closed]

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 ...
Yanhua's user avatar
  • 541
27 votes
2 answers
8k views

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 ...
Kajiyama's user avatar
  • 3,433
27 votes
3 answers
26k views

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 ...
leszek's user avatar
  • 271
27 votes
3 answers
28k views

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 ...
FerdieQO's user avatar
  • 477
27 votes
3 answers
22k views

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

At the beginning of a C# file, I have added: //----------------------------------------------------------------------- // <copyright company="SomeCompany" file="MyFile.cs"> // Copyright © Some ...
Daniel Daranas's user avatar
26 votes
6 answers
6k views

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 ...
Jerad Rose's user avatar
  • 15.3k
25 votes
5 answers
18k views

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 ...
NickG's user avatar
  • 9,615
25 votes
1 answer
1k views

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 ...
Nikolay Kostov's user avatar
23 votes
6 answers
6k views

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 ...
23 votes
7 answers
28k views

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 ...
Nathan W's user avatar
  • 55k
23 votes
3 answers
23k views

Is sa1200 All using directives must be placed inside the namespace (StyleCop) purely cosmetic? [duplicate]

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 ...
Matt's user avatar
  • 26.5k
22 votes
6 answers
14k views

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's user avatar
22 votes
4 answers
2k views

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, ...
Jodrell's user avatar
  • 35.4k
22 votes
2 answers
8k views

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 ...
srm's user avatar
  • 3,102
22 votes
2 answers
5k views

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 ...
jlembke's user avatar
  • 13.3k
21 votes
2 answers
4k views

"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 ...
Metomorphose's user avatar
21 votes
2 answers
11k views

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 ...
Habaabiai's user avatar
  • 725
21 votes
2 answers
6k views

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 ...
MicroMan's user avatar
  • 2,008
20 votes
4 answers
17k views

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 ...
demoncodemonkey's user avatar
20 votes
2 answers
6k views

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 ...
Daniel Fortunov's user avatar
20 votes
1 answer
27k views

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's user avatar
  • 4,192
19 votes
5 answers
3k views

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, ...
Arseni Mourzenko's user avatar
19 votes
1 answer
9k views

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 [...
iroel's user avatar
  • 1,779
19 votes
4 answers
11k views

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 ...
lysergic-acid's user avatar
19 votes
5 answers
25k views

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 ...
Chris G.'s user avatar
  • 24.9k
18 votes
1 answer
14k views

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 ...
ptkvsk's user avatar
  • 2,162
17 votes
7 answers
10k views

Is there a way to enforce using tabs instead of spaces?

StyleCop offers to check for consistent use of spaces, but sadly lacks the opposite idea: Force source code to use tabs. Is there some way to add this functionality? It does not have to be StyleCop, ...
mafu's user avatar
  • 32.2k
17 votes
2 answers
11k views

CA1014 Mark 'some.dll' with CLSCompliant(true) error message with StyleCop of VS2010

When I run StyleCop, I got this error message saying that I need to Mark the dll with CLSCompliant(true). What is this? How can I set the Mark the dll with CLSCompliant(true)? Error 4 CA1014 : ...
prosseek's user avatar
  • 186k
17 votes
3 answers
29k views

how to properly install stylecop?

Well i downloaded the newest version, then installed, checked to instal entire files on local drive. I restarted VS2010 and rerun it. Unfortunatelly i can't find in menu > tools anything with should ...
deadfish's user avatar
  • 12.2k
17 votes
3 answers
6k views

StyleCop SA1600 rule and interfaces realisation

StyleCop rule SA1600 demands that every type member has it's own documentation header. I think it's quite reasonable and I like this rule. But suppose we have the following hierarchy: /// <summary&...
Dmitrii Lobanov's user avatar
17 votes
2 answers
3k views

Namespace naming convention when [CompanyName] starts with a lower case "i"

My company name starts with a lower case "i". For example: iWare (this is not the real company name, but it demonstrates the purposes). Because of this I find that I am constantly having to fight ...
gregpakes's user avatar
  • 4,505

1
2 3 4 5
13