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
5
votes
1 answer

private void Dispose(bool)?

In a couple of places, people have suggested to use private void Dispose(bool) for the IDisposable pattern. This seems outdated though (at least for unsealed classes), as the new suggested pattern (according to Microsoft) is protected virtual void…
Nate Diamond
  • 5,525
  • 2
  • 31
  • 57
5
votes
1 answer

Unable to execute FxCop rules with MSBuild SonarQube Runner

We are facing issues while analyzing .NET projects using SonarQube 5.1.1. Please note that FxCop rules are enabled at Quality profile level. We are using MSBuild SonarQube Runner to analyze the projects. But we are facing error which says…
5
votes
2 answers

Why does FxCop not report CA2000 for this trivial case of not-disposed class instance?

The following code produces a CA2000 ("Dispose objects before losing scope") violation for the first line of Main, but not the second. I would really like the CA2000 violation for the second line, because this is a (obviously simplified) pattern…
nick.beer
  • 143
  • 1
  • 7
5
votes
2 answers

Is there a .Net StyleCop rule which warns about lock(this), lock(typeof, lock(, etc.?

These 3 types of lock are apparently bad. What other type of locking is bad? Are there Stylecop / FxCop rules that would catch this? If not, then would you please help me with a custom rule implementation? They code for all of them must be similar,…
Hamish Grubijan
  • 10,562
  • 23
  • 99
  • 147
5
votes
4 answers

Should I suppress CA2204: Literals should be spelled correctly?

I've recently upgraded my project from Visual Studio 2008 to Visual Studio 2010. By enabling Code Analysis, I'm getting a lot of warnings resulted in rule CA2204: Literals should be spelled correctly. EDIT: Let's say I have a method called…
brickner
  • 6,595
  • 3
  • 41
  • 54
5
votes
4 answers

How does one implement FxCop / static analysis on an existing code base

What are some of the strategies that are used when implementing FxCop / static analysis on existing code bases with existing violations? How can one most effectively reduce the static analysis violations?
Sir Rippov the Maple
  • 7,491
  • 5
  • 42
  • 52
5
votes
3 answers

Compare two fxcop results

I'm going to analysis two different versions of the same dll with fxcop. I would like to display only the differences between these two reports. Does anyone know if this is possible ? Thanks for your time.
excepeiont32
  • 103
  • 5
5
votes
5 answers

Overriding Object.Equals() instance method in C#; now Code Analysis/FxCop warning CA2218: "should also redefine GetHashCode". Should I suppress this?

I've got a complex class in my C# project on which I want to be able to do equality tests. It is not a trivial class; it contains a variety of scalar properties as well as references to other objects and collections (e.g. IDictionary). For what…
Chris W. Rea
  • 5,430
  • 41
  • 58
5
votes
3 answers

Disable Code Analysis output MSBuild

I am building projects using a build definition. When this executes, Code Analysis is also performed. Code Analysis outputs various files including: ConsoleApplication2.exe.CodeAnalysisLog.xml ConsoleApplication2.exe.lastcodeanalysissucceeded Is…
Matthijs
  • 3,162
  • 4
  • 25
  • 46
5
votes
5 answers

Detect .NET Framework 3.5 SP1 Dependency (cmp. 3.5 w/o SP1)

I'm using 3.5 SP1 on my machine, while our customers currently use 3.5 without SP1. I don't know any way in VS2008 to target the solution or project to 3.5 without SP1, only the 3.5 with SP1 I have installed. If we use functions or constructors not…
L. Kolmodin
  • 476
  • 4
  • 13
5
votes
1 answer

Are there any tools to perform a security analysis against .net desktop assemblies and excutables?

Are there any tools to perform a security analysis against .net desktop assemblies and excutables? I used FXCOP and Gendarme but i think they are not sufficient.
Ahmed_A
  • 87
  • 8
5
votes
3 answers

fxcop custom rules - Avoid having more than one class per file

as fxcop is an assembly inspector, is it possible to create a custom rule that check if there's more than one class per file ? If yes, how to do that ? Thanks for your help
Tim
  • 2,887
  • 10
  • 33
  • 33
5
votes
2 answers

Have you ever heard about CA2151 - Fields with critical types should be security critical?

I've tried to compile .NET project and this CA appears, however I can't find any information about it on MSDN, do you know how to fix it?
Steve Macculan
  • 2,292
  • 5
  • 22
  • 32
5
votes
2 answers

How to specify CodeAnalysisRules in MSBuild via commandline

I want to be able to specify the Code AnalysisRules in commandline MSBuild (for Code Analysis / FXCOP). The project file would have something like this in…
5
votes
4 answers

FxCop indirect reference to System.Core version 2.0.5.0

I've got a project that uses Autofac, and the WebAPI integration We run FxCop over our solution, and on opening autofac, I get the following: The following indirectly-referenced assembly could not be found. This assembly is not required for…
Alex
  • 37,502
  • 51
  • 204
  • 332