Custom static code analysis rules in FxCop or StyleCop?
Asked Answered
D

2

6

If writing my own static code analysis rules (for C# code), what are the pros and cons of using StyleCop vs FxCop?

Is one more appropriate for certain type of analysis than the other? Or is the difference between the two that one runs on the source code and the other on the compiled assembly?

Dardani answered 28/1, 2010 at 23:50 Comment(0)
D
8

A key difference is that StyleCop analyzes C# source code. FxCop analyzes .NET assemblies after they are compiled, it works for any language. Accordingly, StyleCop is picky about how your source code looks. FxCop is picky about how you use the .NET framework classes. They complement each other.

Duotone answered 29/1, 2010 at 1:8 Comment(0)
S
2

They are different tools. StyleCop is focused on code style. You can check doc. comments, naming convention, spacing, etc. Altough it can do almost the same things as StyleCop, FxCop is focused on the Microsoft Design Guidelines. It will analyze your code looking for possible performance and security issues, among other things.

I never wrote rules for any of them, but I believe that you should go for the one that does exactly what you want (if just coding standards, go with StyleCop, otherwise, go with FxCop). This way, you'll probably feel more confortable with the API.

Check these Wikipedia links:

Sermonize answered 29/1, 2010 at 0:54 Comment(1)
isn't entire true: blogs.msdn.com/sourceanalysis/archive/2008/05/23/…Byword

© 2022 - 2024 — McMap. All rights reserved.