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

Nested using statements and Microsoft code Analyses

Recently I switched on additional code analyses rules. To my surprise I saw a violation in a place I was always considering as the best practice. If I have two nested disposables I am putting two using statements like this: using (StringReader…
George Mamaladze
  • 7,593
  • 2
  • 36
  • 52
25
votes
3 answers

Are there any good workarounds for FxCop warning CA1006?

I am having trouble with FxCop warning CA1006, Microsoft.Design "DoNotNestGenericTypesInMemberSignatures". Specifically, I am designing a ReportCollection class that inherits from ReadOnlyCollection>, and its public constructor takes an…
Bruce Johnston
  • 8,344
  • 3
  • 32
  • 42
25
votes
6 answers

CA1500 vs. SA1309 - Which one wins?

I'll prefix by saying that I understand that both Code Analysis and StyleCop are meant as guidelines, and many people chose to ignore these anyway. But having said that, I'd like to see what the general consensus is with regard to these two…
Jerad Rose
  • 15,235
  • 18
  • 82
  • 153
25
votes
4 answers

How to enable Code Analysis in Visual Studio 2010 Professional?

I can see that we can enable code analysis in Visual Studio Team Systems. But i am using Visual Studio 2010 Professional. Do we have any option to enable code analysis in this version or can we integrate any tools like FxCop and StyleCop with this…
kiran826
  • 331
  • 1
  • 4
  • 10
24
votes
6 answers

Why does FxCop think initializing fields to the default value is bad?

When assigning a default default-value to a field (here false to a bool), FxCop says: Resolution : "'Bar.Bar()' initializes field 'Bar.foo' of type 'bool' to false. Remove this initialization because it will be done…
Peter
  • 47,963
  • 46
  • 132
  • 181
24
votes
5 answers

Why is Microsoft.CodeAnalysis published with ASP.NET Core website?

I'm publishing an ASP.NET Core MVC 3.0 website and the output folder contains lots of reference in many language to Microsoft.CodeAnalysis librairies, someone knows why? Of course the FxCopAnalyzers Nuget package is installed on the project, but it…
Jonathan
  • 1,276
  • 10
  • 35
24
votes
9 answers

What's the proper naming convention for a property 'ID' : ID or Id?

Pretty simple question: When i have a persistable object, it usually has a property called ID (for abstract classes). So .. is the naming convention ID or Id? eg. public int ID { get; set; } or public int Id { get; set; } cheers :) PS. This is for…
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
23
votes
4 answers

Exclude complete namespace from FxCop code analysis?

Is it possible to exclude a complete namespace from all FxCop analysis while still analyzing the rest of the assembly using the SuppressMessageAttribute? In my current case, I have a bunch of classes generated by LINQ to SQL which cause a lot of…
hangy
  • 10,765
  • 6
  • 43
  • 63
23
votes
3 answers

Error in FxCop Phoenix analysis engine

So I'm trying to run a bunch of rules which are defined in a RuleSet. The RuleSet file is actually generated using Sonarqube - I've selected absolutely all rules in there, including the FxCop, ReSharper and StyleCop rules. I'm kicking off FxCop like…
Trayek
  • 4,410
  • 3
  • 24
  • 39
20
votes
2 answers

Code Analysis Warning CA2213 - Call Dispose() on IDisposable backing field

Wanted to post this, even though I figured it out as I was writing the question. Will post answer below. Getting the following warning with VS Code Analysis: Warning CA2213 'DBConn' contains field 'DBConn.k__BackingField' that is of IDisposable…
dashnick
  • 2,020
  • 19
  • 34
20
votes
3 answers

Using Microsoft.Bcl.Async with Code Analysis causes errors

I'm trying to use Microsoft.Bcl.Async and Code Analysis, but when I run Code Analysis I get one or more errors. I'm using Visual Studio 2012 with Update 2. This is easy for me to reproduce: Create a new default Console App that targets .Net…
Matthew Watson
  • 104,400
  • 10
  • 158
  • 276
19
votes
4 answers

Is FxCop Dead? Can it be used with VS2015?

I was browsing through Stack Overflow and Google for information about automatic coding style practice tools and found FxCop. But I haven't found recent articles from Microsoft about FxCop. So, I was wondering if FxCop is dead. Can FxCop be used…
Venkataramana Madugula
  • 13,199
  • 2
  • 18
  • 22
19
votes
3 answers

Excluding Code Analysis rule in source

In a project I'm working on FxCop shows me lots of (and I mean more than 400) errors on the InitializeComponent() methods generated by the Windows Forms designer. Most of those errors are just the assignment of the Text property of labels. I'd like…
19
votes
3 answers

CA1026 (all parameters should have default values) and extension methods

Premise When using code analysis (or fxCop) with C# optional parameters you can get a warning of CA1026. The short reason1 for this is not suppling all parameters with a default value. The declaration below rightly generates this warning public…
Robert MacLean
  • 38,975
  • 25
  • 98
  • 152
19
votes
4 answers

FxCop 1.36 is gone

I just wanted to download FxCop 1.36 but I can't find it in the internet. A few days ago FxCop 10 came out for Windows 7 but I need the old Version. The file is gone on the MS server and everybody linked it. Anyone has the old install routine?
user375280
  • 201
  • 2
  • 4
1
2
3
49 50