[Buildrelease]. Net code static detection fxcop

Source: Internet
Author: User

1 fxcop & fxcopcmd

Fxcop is an application that analyzes managed code assemblies (code that targets. net Framework Common Language Runtime) and reports information about the assemblies, such as possible design, localization, performance, and security improvements. generation 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. net Framework.

Fxcop is intended for class library developers. however, anyone creating applications that shocould comply with. NET framework best practices will benefit. fxcop is also useful as an educational tool for people who are new to. NET framework or who are unfamiliar with. 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 automation 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 shoshould 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 automatic environment but it does not support creating or sorting 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 implements strate 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
    • Download the Microsoft Windows SDK for Windows 7 and. NET Framework 4 Version 7.1
    • Using elevated privileges execute fxcopsetup.exe from the % ProgramFiles % \ microsoft sdks \ windows \ v7.1 \ bin \ fxcop folder.

If you require fxcop 1.36 Please download and install the Windows SDK version 7.0.

 

Reference: fxcop Design Rules

Complete!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.