• [BuildRelease].NET代码静态检测FxCop


     

    1 FxCop & FxCopCmd

    FxCop is an application that analyzes managed code assemblies (code that targets the .NET Framework common language runtime) and reports information about the assemblies, such as possible design, localization, performance, and security improvements. Many of the issues concern violations of the programming and design rules set forth in the Design Guidelines, which are the Microsoft guidelines for writing robust and easily maintainable code by using the .NET Framework.

    FxCop is intended for class library developers. However, anyone creating applications that should comply with the .NET Framework best practices will benefit. FxCop is also useful as an educational tool for people who are new to the .NET Framework or who are unfamiliar with the .NET Framework Design Guidelines.

    FxCop is designed to be fully integrated into the software development cycle and is distributed as both a fully featured application that has a graphical user interface (FxCop.exe) for interactive work, and a command-line tool (FxCopCmd.exe) suited for use as part of automated build processes or integrated with Microsoft Visual Studio® .NET as an external tool.


    2 FxCop Workflow

    The following sequence of steps describes the general procedure for using FxCop:

    To create a new project

        Compile the assemblies.

        Start the FxCop application.

        Add the targets (assemblies) to be analyzed to the project.

        Review the rules automatically loaded by FxCop and clear the selection of any rules that should not be applied to the targets during analysis.


    To analyze the assemblies and review messages

        Analyze the assemblies.

        Review the reported messages and determine the disposition for each:

            Code defect – fix the source code.

            Message is reporting an intentional variance from the rule - exclude the message.

            Rule is generating a false positive - exclude the message.

        Exclude items as appropriate.

        Correct any code defects detected by FxCop.

        Rebuild your assemblies.


    To add FxCopCmd to the build process

        Save the project.

        In your build script, call FxCopCmd using the /project option.

        Review the analysis report output.

        If new messages need to be excluded, or other changes to the project are required, use the FxCop application to update your project and save your changes.

        Correct any code defects detected by FxCopCmd.


    3 Quick Start Guide to FxCopCmd

    This document provides a brief overview of FxCopCmd, which is the command-line companion to the FxCop application. For a complete description of FxCopCmd, see Using FxCopCmd.

    FxCopCmd is useful for analyzing assemblies in an automated environment but it does not support creating or configuring projects, or excluding messages. Although individual types and rules can be directly specified with the command-line options, the FxCop application provides easier and more finely detailed control.

    Command-line options are used to specify the assemblies to be analyzed, the rules used to analyze the assemblies, and the location of the output file.

    To specify the assemblies and rules, use one of the following:

        The /project option, which uses a project saved from the FxCop application.

        The /file and /rule options, which directly specify the assemblies and rules, respectively.

    To specify the location of the output file, use one of the following:

        The /out option, which saves the results of an analysis in an XML file.

        The /console option, which displays the results in a console window or, if integrated with Visual Studio, in the Output window.

    The following examples illustrate a minimum command line:

        FxCopCmd /p:SomeProject.FxCop /c

        FxCopCmd /f:SomeAssembly.dll /r:"C:\Rules Directory\SomeRules.dll" /o:OutputFile.xml

    4 FxCop download

    Version 10.0 of FxCop is the version that ships with Visual Studio 2010 Premium. FxCop 10.0 is part of Version 7.1 of the Microsoft Windows SDK for Windows 7 and .NET Framework 4.

    Instructions

    If you require FxCop 1.36 please download and install the Windows SDK version 7.0.

    完!
  • 相关阅读:
    例解 Linux 下 Make 命令
    linux使用bin文件安装jdk
    Linux查看及设置系统字符集
    FTP的两种主动模式和被动模式
    Mongodb之主从复制
    Nginx配置认证登录
    AWK
    Redis+Keepalived实现高可用
    Redis哨兵配置
    Keepalived指定文件接收日志
  • 原文地址:https://www.cnblogs.com/itech/p/2174794.html
Copyright © 2020-2023  润新知