Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using FXCop in your project [closed]

Tags:

.net

fxcop

Are there a lot of IT shops utilizing FxCop for writing production code? If so, what was/is your overall experience implementing it in terms of culture shift, pain points, and tangible benefits?

I am in an environment that is somewhat chaotic and looking for tools to help us standardize our development efforts and get us home at a decent hour. I want to avoid egg on my face for pushing a static analysis tool only to have it fail because it’s “not practical”. <- (Anticipated management response)

like image 817
Zaffiro Avatar asked Jun 19 '09 13:06

Zaffiro


People also ask

What is FxCop tool used for?

FxCop provides a tool to help developers to follow their company's coding standards. FxCop does code analysis to check whether the new code is compliant with the coding standards and naming conventions followed by the company. FxCop will ensure that the specified rules are used in the source code.

How do I stop live code analysis?

To open this page, right-click the project node in Solution Explorer and select Properties. Select the Code Analysis tab. To disable source analysis at build time, uncheck the Run on build option. To disable live source analysis, uncheck the Run on live analysis option.

What is FxCop and StyleCop?

StyleCop is a source code analysis tool that provides developers with an effective way to follow C# coding standards. FxCop runs against the compiled binaries as a way to understand and enforce the.NET Framework Guidelines for managed code assemblies.


2 Answers

Note that FxCop is very customisable with regards to the rules you wish to apply. You may find it works best by incrementally introducing it; only for a certain set of rules for a certain set of files, or even excluding all legacy files initially.

There are bound to be rules that you may never activate because they just do not suit your problem domain. And remember that if a piece of code 'breaks a rule' for a specific purpose, there is an attribute to mark such code as acceptable, although I would instate a rule that all such overrides must use the Justification property on the attribute to indicate why.

Finally, as much as the built-in rules will help a lot with improving code quality, the really big wins are to be had in custom rules that will allow you to check for company conventions. If you do not automate your 'peer review' in this fashion, then you cannot really guarantee compliance.

I use FxCop as an integrated part of the build system at work, and our common libraries currently get released with all rules enabled with minimal attribute overrides, and it has been worthwhile in more than a few places.

like image 53
jerryjvl Avatar answered Oct 18 '22 19:10

jerryjvl


I'd say there aren't that many places really using FxCop. We have it turned on, but most of the dev staff ignores the warnings produced.

Also, Dev Management here hasn't been interested in really pushing cleaning up the warnings, in part because FxCop really dislikes the conventions (variable names, etc) that management wants us to follow...

On projects where I've been the lead, I've mandated its use because I think it helps us be better programmers. But you have to have by in at the top in order to get all the dev's to follow it.

like image 27
NotMe Avatar answered Oct 18 '22 21:10

NotMe