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

Get percent code coverage with FxCop

I am currently trying to write a unit test library for a code base in C#. I want to view the percent code coverage my tests are achieving. I am using VS2010 which does not have any build in code analysis tools. I have downloaded FxCop and included…
4
votes
0 answers

sonar issue auto closed and reopen

Here is the context, I use Sonar 5.6.1 C# plugin 5.4.0.464 StyleCop plugin 1.1 We have many issues that are automatically closed and reopen during a Sonar analysis. This problem arrive even if the analyzed file has not been modified. In each of…
4
votes
1 answer

Which is the most important code analysis rule and why?

A large set of code analysis rules is defined within Visual Studio and FxCop but which one do you find to be the most important and most critical to conform and why? Retrospectively, could any of the rules have saved you a lot of time/money if you…
Simon Fischer
  • 3,816
  • 3
  • 23
  • 32
4
votes
3 answers

Suppress Error in Suppression file gives error : The Selected Message Could not be suppressed

I am Using Visual Studio 2015, FxCop 14.0. with Custom rules, and trying to suppress message in GlobalSuppressions.cs. I have set path of the Global Suppression in Project file
Avinash patil
  • 1,689
  • 4
  • 17
  • 39
4
votes
2 answers

What is the static analysis rule to warn about unused using statements?

Is there any FxCop or StyleCop that warns when there is an using statement that is no longer referenced by any object in the file?
4
votes
1 answer

FxCop is not respecting my excludes

I am trying to incorporate FxCop directly into my build. I am using the MSBuild Community Tasks. I have a targets file like this:
justin.m.chase
  • 13,061
  • 8
  • 52
  • 100
4
votes
3 answers

Creating a custom rule in FxCop

I want to create extra rules in FXCop. Custom Rules to help ensure specific best practices like checking against inline sql. I'm really looking for good resources and examples. Thanks!
Brig Lamoreaux
4
votes
1 answer

How to detect null comparisons with non-nullable variable types

Is there any way to detect this code snippet? DateTime dt = DateTime.Now; if (dt == null) { MessageBox.Show("Imposible with datetime!!!"); } In our project we have detected that in Release compilation, the whole if gets removed because a…
Victor Sanchez
  • 583
  • 9
  • 28
4
votes
1 answer

Removing C6054 error with scanf functions

I am using Code Analysis (aka FxCop) on VS2012 and I have a few functions of the form void ReadTable(FILE *fd) { char label[32]; /* ... */ fscanf(fd, "%s", label); /* ... */ if (strcmp(label, "TEST") == 0) { /* ...…
Wasabi
  • 2,879
  • 3
  • 26
  • 48
4
votes
2 answers

Code Analysis tool errors with "The given key was not present in the dictionary."

I get the following unhelpful error while building my .NET project when Code Analysis runs. It happens both in Visual Studio and building from the command line with MSBuild. * 1 total analysis engine exceptions. MSBUILD : error : CA0001 : The…
John Mills
  • 10,020
  • 12
  • 74
  • 121
4
votes
1 answer

Visual Studio's Rule Set Editor does not open

I am trying to edit a custom ruleset file for FxCop. When I open a ruleset file I receive this message: Width of the image strip must be a positive multiple of ImageSize.Width Parameter name: value It looks like the file is already open, because…
Tonatio
  • 4,026
  • 35
  • 24
4
votes
2 answers

How to detect an auto-implemented property in a custom FxCop rule?

I'm trying to write a rule for DTOs, that only allows auto-implemented properties. How do you detect that a property is auto-implemented using the FxCop API?
Roman Dvoskin
  • 384
  • 4
  • 16
4
votes
4 answers

Too many false positives when using FxCop

We are using FxCop and it generates too many false positives to our liking. For instance, if a private method is invoked using reflection, then this method is reported as potentially unused - understandable and we suppress this warning explicitly…
mark
  • 59,016
  • 79
  • 296
  • 580
4
votes
0 answers

How to disable rules for Roslyn FxCopAnalyzer?

the pre-release package of FxCopAnalyzer for Roslyn lets you disable rules in FxCop to avoid duplications, but how to disable the ones coming with FxCopAnalyzer?
Jorge Alvarado
  • 2,664
  • 22
  • 33
4
votes
1 answer

What is transparent class or transparent method in C#?`

I have C# code and when I run FXCop against it, it yields a strange error which I tried to understand but I couldn't. The error says Transparent Methods Must Not Satisfy Link Demands. Here what I don't understand is what is a transparent method?…
Rana
  • 457
  • 1
  • 3
  • 9