How to: Configure FxCop in SPCAF Ruleset

FxCop is one of the 3rd party analyzer s that can be integrated in SPCAF via ruleThe rule will be executed only if the tool FxCop is installed locally. If the tool is not be found the rule will throw an exception. 

Important: Not all FxCop rules are applied.
The analysis uses a subset of FxCop rules which are the same as MSOCAF (Microsoft SharePoint Online Code Analysis Framework) to provide similar behavior. You can override the used ruleset file by using the configuration parameter 'FxCopRuleSets' in the SPCAF ruleset file.

Once you have installed FxCop and have enabled the ruleset you will then need to configure some parameters with FxCop, below is a list of the configurable parameters to be used:

Name Description
FxCopExecutable Absolute or relative path to FxCop executable FxCopCmd.exe. By default SPCAF searches for FxCopCmd.exe at the typical installation locations of FxCop.
FxCopDirectories List of directories (separated by ';') in which FxCop searches for referenced assemblies.
FxCopRuleSets List of FxCop rule set files (separated by ';'). By default SPCAF uses the MSOCAF.ruleset to limit the number of applied rules to a recommended set for SharePoint.
FxCopIgnoreGeneratedCode Set to true, if generated code should be ignored for the analysis.

In order to utilize these parameters you will need to either add them via the SPCAF Setting editor and the "Configuration and Details" section adding the key and value as detailed above, as shown below:SPCAF-RuleEditor-FxCopConfig_1124x800.png

Or, via adding the value and key's to the ruleset directly via an .xml editor, as shown below:

<RuleGroups>
    <RuleGroup Name="SPCAF.Integration.FxCop.FxCop">
      <Rules>
        <Rule Name="FXC350201">
          <Properties>
            <Property Key="FxCopExecutable" Value="directory" />
            <Property Key="FXCopDirectories" Value="directory1;directory2;directory3..." />
            <Property Key="FxCopRuleset" Value="directory1;directory2;directory3..." />
            <Property Key="FxCopIgnoreGeneratedCode" Value="True" />
          </Properties>
        </Rule>
      </Rules>
    </RuleGroup>
</RuleGroups>
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.