9

I have a large high quality c# framework codebase that I nevertheless want to try to improve.

  1. Is fxcop an effective tool for improving .NET frameworks? I know Microsoft uses the tool internally, but how do external users find it? Worthwhile?

  2. I already have a zillion lines of code and a well established style, can it be adapted to our style and still provide good guidance?

  3. Roughly, how long will it take to set up? Hours, days, weeks? Will I learn something useful sooner that later?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Paul
  • 5,376
  • 1
  • 20
  • 19

5 Answers5

16
  1. Yes FxCop is a very effective tool for improving .Net code bases. In addition to finding many different types of bugs (globalization, pinvoke, security, performance) it will also warn you of various style issues that violate conventions. And point out the occasional spelling error.
  2. FxCop is highly customizable. You could for instance turn off all style recomendations and enable only bug checking. That would give you immediate benefits without having to change your style at all.
  3. Really depends on how much of FxCop you enable and how big your code base is. I find that in my personal projects it rarely takes more than an hour to set up. But for a large project I would schedule a day or 2
JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
  • 1
    re point 3, it may help to allow a day or two in terms of effort, but to spread this over a week or so of real time, it is quite hard to just sit down and get it right for a team first time. – Mark Dickinson Dec 08 '09 at 16:02
  • Thanks JaredPar and everybody else. Looks like we'll give this tool a try. We are just post release so I have some time for things like this. – Paul Dec 08 '09 at 16:09
  • BTW the code base has hundreds of classes, so it's pretty sizable. – Paul Dec 08 '09 at 16:10
4

Yes absolutely. I used it for a year and a half. It spots all kinds of problems and gotchas and it's taught me a thing or two. Microsoft knows best in many cases.

Setting up is just a question of ticking a few boxes and modifying a few build scripts, well worth the effort. You will learn a lot from it if you research decisions it makes that you don't understand and remain open-minded.

Joe
  • 46,419
  • 33
  • 155
  • 245
2
  1. Its Useful most of the time, not always! (you need to take it seriously only for some core issues, leaving out issues that are very particular to developing code in microsoft's style).

  2. Some of the guidance given by it is independent of style and is dependent on whether you are following good programming practices or not, so yes you can get some guidance from it.

  3. I don't think setup will take you much time, it should be couple of hours at max.

Thanks

Mahesh Velaga
  • 21,633
  • 5
  • 37
  • 59
1

I find fxCop to be a good tool to enforce a coding standard. If you already have your own standard and you follow it consistently I don't see much reason to change, even more for so many lines of code. Setting up is pretty easy, running and fixing everything is something else.

Otávio Décio
  • 73,752
  • 17
  • 161
  • 228
0

An alternative to FxCop rules would be to use the tool NDepend. This tool lets write Code Rules over C# LINQ Queries what we call CQLinq. Disclaimer: I am one of the developers of the tool

1) More than 200 code rules are proposed by default. They make the tool effective since they cover a wide-range of check (code quality, .NET Fx usage, structure, design, evolution, breaking changes, deadcode, naming conventions...)

2) Customizing existing rules or creating your own rules is straightforward thanks to the well-known C# LINQ syntax.

3) Rules can be verified live in Visual Studio and at Build Process time, in a generated HTML+javascript report. This is straightforward to setup, a few hours maximum.

3) bis Will I learn something useful sooner that later?

Let's quote this tweet by Hakan Tuncer: It's amazing to see how much you can learn just by reading the ‪#NDepend‬ rules.Rule descriptions even contain references to blog links.

Patrick from NDepend team
  • 13,237
  • 6
  • 61
  • 92