Questions tagged [fxcop]

Microsoft's free static analysis tool for analyzing .NET managed code assemblies.

FxCop can be used to find coding design issues quickly and early, comes with switchable rulesets, and supports the creation of custom rules.

Available with certain versions of Visual Studio and as part of the Windows 7 SDK, available here.

749 questions
12
votes
8 answers

FxCop/StyleCop for Delphi?

Does anyone know of an equivalent to FxCop/StyleCop for Delphi? I would really like to get the automatic checking of style, etc. into Continuous Integration.
mmmm
  • 2,431
  • 2
  • 35
  • 56
12
votes
3 answers

CA1704 - Microsoft seems to be blocking the word 'Multi'?

public class MultiSomething { } //CA1704:IdentifiersShouldBeSpelledCorrectly When I run Code Analysis, I get an error because the Microsoft does not recognize the word 'Multi' (go figure they use it in IMultiValueConverter). So, what I did to…
myermian
  • 31,823
  • 24
  • 123
  • 215
12
votes
2 answers

How to implement dispose pattern with close method correctly (CA1063)

The Framework Design Guidelines (2nd Ed., page 327) say: CONSIDER providing method Close(), in addition to the Dispose(), if close is standard terminology in the area. When doing so, it is important that you make the Close implementation identical…
dtb
  • 213,145
  • 36
  • 401
  • 431
12
votes
6 answers

Should we start using FxCop and/or StyleCop in a mature project?

We have 3 years old solution (.sln) with about 20 projects (.csproj). It is reasonable to start using FxCop and/or StyleCop? Maybe we should use it for several small projects first but not for whole solution? It would be good to see some experienced…
Vasyl Boroviak
  • 5,959
  • 5
  • 51
  • 70
12
votes
4 answers

Do not declare read only mutable reference types - why not?

I have been reading this question and a few other answers and whilst I get the difference between changing the reference and changing the state of the current instance I'm not certain why this means that I shouldn't mark it readonly. Is this…
Sam Holder
  • 32,535
  • 13
  • 101
  • 181
12
votes
2 answers

Code Analysis rule CA1062 behaviour

I have following extension method for strings: public static bool IsNullOrEmpty(this string target) { return string.IsNullOrEmpty(target); } ... and in the code I use it as follows: public static string DoSomethingOnString(this string…
Anil
  • 1,079
  • 1
  • 13
  • 23
11
votes
2 answers

CA1303, DoNotPassLiteralsAsLocalizedParameters, but I'm actually not

My code gets the CA1303 warning from Microsoft.Globalization, "Do not pass literals as localized parameters", but my code is not actually passing a literal: private void MyForm_Load(object sender, EventArgs e) { UpdateTitle(); } private void…
Camilo Martin
  • 37,236
  • 20
  • 111
  • 154
11
votes
3 answers

FxCop folder missing

What is the issue? I am trying to install FxCop 10. To install that, Microsoft Windows SDK 7.1 is required. I installed the SDK. Now, to install FxCop, I have to run FxCopSetup.exe, which is supposed to be located in the folder…
pnvn
  • 488
  • 1
  • 5
  • 11
11
votes
3 answers

StyleCop/FxCop 10 - How do you properly suppress a message only on a namespace level?

FxCop 10 is complaining about the following: using XYZ.Blah; //CA1709 - "XYZ" using Xyz.Blah; //No complaint. using XylophoneSuperDuperLongFullName.Blah; //I don't want to have a long full name for my company name. The problem is... I want my…
michael
  • 14,844
  • 28
  • 89
  • 177
11
votes
1 answer

Get FxCop to suppress warnings for a whole type?

How can I suppress FxCop warnings for a whole type? namespace ConsoleApplication1 { public static class Serializer { public static string Serialize(T obj) { return string.Empty; } public…
shatl
  • 911
  • 16
  • 21
11
votes
2 answers

Why do I get Code Analysis CA1062 on an out parameter in this code?

I have a very simple code (simplified from the original code - so I know it's not a very clever code) that when I compile in Visual Studio 2010 with Code Analysis gives me warning CA1062: Validate arguments of public methods. public class Foo { …
brickner
  • 6,595
  • 3
  • 41
  • 54
11
votes
6 answers

ASP.NET MVC4 solution fails to build after installing KB2993928

We have an ASP.NET MVC 4 solution with a couple of references that has been building without problems for about 2 years now. However, after installing KB2993928 and KB2993937 this morning, we cannot run FxCop on this solution on our Windows 7…
Olaf Keijsers
  • 566
  • 4
  • 16
11
votes
1 answer

Visual Studio Code Analysis Error CA 1006

Code analysis throws error CA1006: Do not nest generic types in member signatures whenever we define custom definitions in the interface contract. What is the best way of handling this so called design issue. Any deep thoughts on this. Thanks for…
10
votes
6 answers

How to fix FxCop error code 512?

While refactoring, moving around some assemblies around, etc. I compiled a solution in Visual Studio and got back a single error message: "FxCop exited with error code 512". The build seems fine other than this one error. Anyone know what this…
Nick W.
  • 1,050
  • 2
  • 9
  • 21
10
votes
3 answers

How to prevent FxCop from analyzing auto-generated code?

FxCop (tool for static code analysis) gives me an error while checking code behind of .edmx model. How to prevent FxCop from analyzing auto-generated code (or at least Entity Framework generated classes)?
jwaliszko
  • 16,942
  • 22
  • 92
  • 158