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
2 answers

Code analysis rule CA1040: Avoid empty interfaces, complains on a non empty interface

I have an interface that declares events interface IMyInterface { event SomeHandler MyEvent1; event SomeHandler MyEvent2; ... } but when I enable the Code analysis rule CA1040: Avoid empty interfaces, it complains that my interface violates this…
Pablo Retyk
  • 5,690
  • 6
  • 44
  • 59
5
votes
4 answers

Warning: Can't find dll

I have a client program written in C# where one of the projects in the solution handles a case which the machine has SQL 2005 installed. I have added the relevant DLLs, but I get that warning: CA0060 : The indirectly-referenced assembly…
elirandav
  • 1,913
  • 19
  • 27
5
votes
2 answers

TeamCity FxCop runner: Specifying assemblies

My first thought is that is would be bad practice to list each dll individually. I want to avoid having to edit my TC configuration every time someone creates a new project/dll. Although with the traditional directory structure I can't find any…
user479911
5
votes
4 answers

FxCop can't resolve references

I'm working on project in C#. Now I've set up a Hudson server an I've installed the .Net 4 Framework and the Windows SDK 7.1 on the server. The project builds successfully but when I start FxCop with: "C:\Program Files (x86)\Microsoft FxCop…
CoolKiffings
  • 567
  • 1
  • 8
  • 16
4
votes
1 answer

Is there a tool which can automatically clean up GlobalSuppressions.cs?

I am using FxCop and StyleCop for my projects as well as GlobalSuppressions.cs to suppress some rules. Some projects have changed a lot and some exclusion I did in the past don't apply anymore. The GlobalSuppressions.cs haven't been cleaned up of…
Martin
  • 39,309
  • 62
  • 192
  • 278
4
votes
3 answers

FxCop says I should return a generic list inteface instead of a byte array. Should I?

I'm writing a library and instead of returning a byte array from an EventArgs derivation, it says I should return something like IList or ReadOnlyCollection instead. Normally I'd be all for this but most of the existing .NET Framework uses byte…
Ryan Peschel
  • 11,087
  • 19
  • 74
  • 136
4
votes
1 answer

How to add .NET 3.5 and .NET 4.0 assemblies to FxCop code analysis?

I want to analyze a solution that contains projects targeting .NET 3.5 SP1 and some other projects targeting .NET 4 with some dependencies to .NET 3.5 libraries. When I try to add both assemblies, one for .NET 3.5 and another for .NET 4, FxCop…
matthias.lukaszek
  • 2,200
  • 1
  • 23
  • 33
4
votes
1 answer

Avoiding code analysis CA2000 warning with chained constructors?

The normal pattern for avoiding the CA2000 warning about non-disposed locals is to use a temp variable that gets disposed if anything goes wrong, like: Foo f = null; try { f = new Foo(); Foo result = f; f = null; return…
Michael Edenfield
  • 28,070
  • 4
  • 86
  • 117
4
votes
3 answers

FxCop is it as valuable on VB.NET as it is on C#

I have been looking at a few of our VB.NET dll's using FxCop and all of the errors relate to DLL setup (i.e. Strong Names, Culture Info) and the case of Variables methods. Looking at a few examples of FxCop examining a C# Dll, it appears to offer a…
Dean
  • 5,896
  • 12
  • 58
  • 95
4
votes
2 answers

Run code analysis rule set with FxCop 10 GUI

I'm using code analysis in .NET 4, where I have a custom rule set included in the project file for my project. I would like to run FxCop 10 GUI on the project output, using the same rules as in the custom rule set. Is this possible with FxCop GUI…
Ole Lynge
  • 4,457
  • 8
  • 43
  • 57
4
votes
2 answers

What issues does static call graph analysis decipher?

What issues would one hope to find using static call graph analysis on a program? FxCop uses static call graph analysis, what issues does it find using this…
CODe
  • 2,253
  • 6
  • 36
  • 65
4
votes
1 answer

CA2202 Warning for ForEach loop

The fxcop analysis gives the CA2202 warning for the following method body over the foreach line: public void LogAnalysis(IEnumerable steps, bool append = false) { if (steps != null) { StringBuilder sb = new StringBuilder(); …
mcy
  • 1,209
  • 6
  • 25
  • 37
4
votes
2 answers

How can I run FxCop on an entire solution in Visual Studio 2008

There must be simple way, I do not want to run Code Analysis separately on each project.
Peter
  • 3,563
  • 5
  • 30
  • 43
4
votes
2 answers

FxCop Suppression

I have a control on an Asp.Net page, on that page is a control with the name "PaReq" that violates the rule: CA1704:IdentifiersShouldBeSpelledCorrectly I've used suppression before I'm not sure how to suppress this error since it is defined in…
TWith2Sugars
  • 3,384
  • 2
  • 26
  • 43
4
votes
0 answers

How to write output from Roslyn FxCopAnalyzers to disk using MSBuild?

I have a .NET Core 2.0 project for which I would like to perform code analysis from the command line and write the output to disk. Per the discussion here, I have referenced the Microsoft.CodeAnalysis.FxCopAnalyzers Nuget package (enabled for both…
ket
  • 728
  • 7
  • 22