Questions tagged [stylecop]

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

643 questions
2386
votes
15 answers

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 instead of outside the namespace?
benPearce
  • 37,735
  • 14
  • 62
  • 96
260
votes
23 answers

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 'Refactor > Rename'. But shorcut Ctrl+R does nothing. I…
Julia Meshcheryakova
  • 3,162
  • 3
  • 22
  • 42
99
votes
5 answers

Stylecop vs FXcop

Has Stylecop superseded FXcop? Which product should we be using with Visual Studio 2008?
JL.
  • 78,954
  • 126
  • 311
  • 459
81
votes
3 answers

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
  • 32,054
  • 48
  • 155
  • 243
73
votes
3 answers

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 analyses some of the rules of both FxCop and…
Jader Dias
  • 88,211
  • 155
  • 421
  • 625
70
votes
9 answers

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 one rule which puzzles me, because I haven't seen…
Mathias
  • 15,191
  • 9
  • 60
  • 92
66
votes
3 answers

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 different versions of stylecop were intermittently…
Jon Rea
  • 9,337
  • 4
  • 32
  • 35
65
votes
7 answers

TemporaryGeneratedFile_[guid] in /obj/debug breaking build

I have 3 temporary files being created in…
NikolaiDante
  • 18,469
  • 14
  • 77
  • 117
61
votes
12 answers

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 but still not sure how to do the suppressing. For…
Nam G VU
  • 33,193
  • 69
  • 233
  • 372
60
votes
7 answers

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
  • 2,284
  • 4
  • 23
  • 28
42
votes
2 answers

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

What's the proper way to comment this? /// /// Initializes a new instance of the class. /// /// The unit of work. public Repository(IUnitOfWork unitOfWork) { …
mservidio
  • 12,817
  • 9
  • 58
  • 84
41
votes
2 answers

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. If I do a simple code cleanup on a C# source…
user2324540
40
votes
6 answers

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 C# types, but does not use the built-in alias for…
binball
  • 2,255
  • 4
  • 30
  • 34
38
votes
2 answers

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 before the namespace. I have resharper 6.0 and…
MoXplod
  • 3,813
  • 6
  • 36
  • 46
38
votes
6 answers

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 // in the beginning of the file to make StyleCop ignore it. However, I don't want to ignore the rules for the whole…
stiank81
  • 25,418
  • 43
  • 131
  • 202
1
2 3
42 43