How to customize FxCopCmd.exe and Metrics.exe behavior

FxCop Integrator supports to customize FxCopCmd.exe and Metrics.exe behavior. For example, you can choose whether FxCopCmd.exe ignores generated code or not.

Procedure

  • Step 1
Right click on the solution/project and select [Context Menu] > [More Tasks...] > [Configure Code Analysis].
Configure code analysis
  • Step 2
Edit options.
Edit options
  • Step 3
Click [Save] button to save option values and to close window.

About Each Option

General

General options
  • Search Global Assembly Cache for missing references
Whether or not to search GAC for missing reference assemblies.
  • Suppress analysis results against generated code
Whether or not to analyze generated code.
  • Timeout for analysis deadlock detection
Timeout for analysis deadlock detection. Analysis will be aborted when analysis of a single item by a single rule exceeds the specified amount of time. Specify a value of 0 to disable deadlock detection.
  • Analyze code with RuleSet
RuleSet to enable/disable rules. FxCop Integrator passes the selected RuleSet to FxCopCmd when you execute code analysis. If you want to use custom RuleSet, click {[Browse]} button and select your custom RuleSet. Note that this option is ignored if you use FxCop 1.36, because FxCop 1.36 doesn't support RuleSet.
  • Enable Code Analysis (This option is only shown project configuration)
Whether or not to analyze your code. This option allow you to disable code analysis against specific projects (e.g. unit test projects).
  • Override ... (This option is only shown project configuration)
Whether or not to replace an option value that is defined in the solution configuration or the default value if the solution configuration isn't defined.

Build (This tab is only shown project configuration)

Build options
  • Enable code inspection on build
Whether or not to analyze your code automatically when you build it.
Note that you have to install FxCop Integrator MSBuild Tasks if you want to use this feature.
  • Enable code analysis on build
Whether or not to analyze your code automatically when you build it.
Note that this is the obsolete feature and will be removed in the future release. Please use the 'Enable code inspection on build' feature instead.

Filter

Filter options
  • Filter Pattern
A regular expression pattern of file name to filter out code inspection or code metrics calculation result.
  • Override Mode
This option represents the override mode of filter pattern.
Inherit: Inherits filter patterns that is defined in the solution configuration or use default patterns if the solution configuration isn't defined.
Merge: Merges filter patterns of the solution configuration and the project configuration.
Replace: Replaces filter patterns of the solution configuration with the project configuration.
By default, following filter patterns are defined:
^.+\.[Dd]esigner\.[^\.]+$
^.+\.[Gg]enerated\.[^\.]+$
^.+\.g\.[^\.]+$
^.+\.g\.i\.[^\.]+$

Solution Configuration and Project Configuration

FxCop Integrator supports Solution Configuration and Project Configuration.
  • Solution Configuration is used to customize FxCopCmd behavior for all projects in the solution. For example, if you set RuleSet option to "Microsoft Minimum Recommended Rules" in Solution Configuration, FxCop Integrator use the specified RuleSet to analyze each project, even if you analyze a specific project only.
  • Project Configuration is a setting for a specific project. The principal use of it is to override option values of Solution Configuration.

Each configuration file is located to following.

Name File
Solution Configuration $(SolutionDir)\CodeAnalysis\CodeAnalysisConfiguration.xml
Project Configuration $(ProjectDir)\CodeAnalysis\CodeAnalysisConfiguration.xml

Older version

Last edited Dec 4, 2011 at 1:42 PM by sasaminn, version 4

Comments

No comments yet.