Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top