tags:

views:

268

answers:

3

I'm working on a project in C# .net and WPF. We're using StyleCop to help bring a consistent style to the project, and after disabling some rules we're quite satisfied with it. However, I've heard people talk about FxCop, and that this would bring value to the project too. From what I understand this is more on a code structure base..?

Could someone give me any specific reasons why we should start using FxCop? What are the most important things FxCop will ensure that we do correctly?

+3  A: 

It detects some useful conditions and can improve your coding style. By style I don't just mean bracket placement and so on. But issues such as abstract classes having public constructors and many other specalist cases. It's little things like this it picks up, and after a while you do them automatically.

Starting a new project with it is easy, using it with an existing project is harder as it will detect more issues. It's worth noting you will have to configure FxCop at first, as it will point out trivial things which may not be of concern.

Finglas
Are all rules active at first, and then you can disable those you don't want? Like StyleCop..?
stiank81
Yeah. You can disable them in code or the app itself.
Finglas
+1  A: 

FxCop works on compiled binaries, while StyleCop analyzes the source code directly.

Maybe you could to use it to check if a compiled assembly, as that you send to your QA/production environment, matches your company polices, if someone tries to bypass your StyleCop rules.

Rubens Farias
Are you saying it uses many of the same rules as StyleCop, but checks this on compiled binaries instead?
stiank81
I mean; I though FxCop did check some completely different rules too.
stiank81
Yes, because different information is available; while some rule set is common to both tools, you can get some information from source code, and other informations can only be get from assmblies.
Rubens Farias
+1  A: 

I use it, in combination with CC.NET. That means, every time CC.NET build my project, it also performs an FxCop analysis, which can be quite handy, as it:

  • detects unused variables
  • detects unused methods
  • gives you an indication whether you've mispelled a word
  • helps you remind that you should pass a formatprovider to a call to ToString() f.i.

In short: it helps you to improve the quality of your code.

Frederik Gheysels