Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stylecop vs FXcop

Tags:

stylecop

fxcop

Has Stylecop superseded FXcop? Which product should we be using with Visual Studio 2008?

like image 755
JL. Avatar asked Dec 10 '09 22:12

JL.


2 Answers

Stylecop is a style analysis tool that works at the source code level. It exists primarily to provide a single common style that managed projects can use to remain consistent within the larger world of managed software. It makes decisions regarding style primarily to avoid holy wars (after all, style is almost always an inherently subjective thing). I don't think I've ever met someone who liked all of StyleCop's rules, but that's ok. It means that StyleCop is a generally good compromise amongst the vast set of style guidelines that exist. (If stylecop's rules were highly customizable, beyond simply enabling/disabling them, it would defeat the entire purpose of the tool.)

FxCop, on the other hand, is a static analysis tool that works on the level of the managed assembly. It can be given directions via attributes because it can see attributes on code elements, e.g.. It detects problems that can be seen on the "binary" level (as it were) as opposed to the syntactic level.

To answer your question, StyleCop doesn't supercede FxCop, and FxCop doesn't supercede stylecop. They're two different tools with two different purposes that can both provide a real benefit for your code.

(AKA, I run with both. :) )


A couple examples of the things one might detect vs. things the other might detect:

StyleCop violations might include warnings related to: Whitespace, Formatting, Public method documentation via xml-comments, order of method definition within a class.

FxCop violations might include warning related to: Globalization, tight coupling, cyclomatic complexity, potential null dereferences.

like image 184
Greg D Avatar answered Oct 07 '22 03:10

Greg D


stylecop works on your C# source code. fxcop looks at your compiled code from any .net language.

like image 45
No Refunds No Returns Avatar answered Oct 07 '22 04:10

No Refunds No Returns