Ten essential .NET development gadgets (5): FXCOP

zhaozj2021-02-16  62

Author:

James avery

translation:

Lucentoff

Source: http://msdn.microsoft.com/msdnmag/issues/04/07/musthavetools/default.aspx declaration: The copyright belongs to the original author, reproduced please indicate the source!

FXCOP

The function of .NET Framework is very powerful, which means that the potential to create an excellent application is huge, but there is also an opportunity to create a bad program. FXCOP is a tool that helps you create better applications, which enables you to check the assembly and verify compliance with some of the different rules. FXCOP has a set of rules created by Microsoft, but you can also create and include your own rules. For example, if you decide that all classes should have a default non-parameter constructor, you can write a rule to check the constructor for each class. In this way, no matter who to write code, there will be certain consistency. If you want to know more about creating custom rules, you can read John Robbins about this topic in June 2004, John Robbins about this topic "encountered bad code? FXCOP help "(Bugslayer: Bad code? FXCOP to the rescue).

Then let us use FXCOP to check the NUNITEXAMPLE assembly used in front to see what is wrong. After opening FXCOP, first create a FXCOP project, then join the assembly you want to test, press the "Analyze" button, FXCOP will perform check. The errors and warnings found in the NUNITEXAMPLE program are shown in Figure 6.

Figure 6 FXCOP check results

FXCOP found several issues in my assembly. You can find more information by double-clicking Error to view the details, including rule descriptions and where you can find more information. (You can check the package of .NET Framework with fxcop, see what the result is.)

FXCOP can help you create better consistent, but it can't make up for bad applications or programming. FXCOP is not an alternative tool for a code review, but it can capture a lot of errors before the code review, so you can use more time to use the key issue instead of going to worry about naming practices.

FXCOP is developed by Microsoft, downloaded URL: http://www.gotdotnet.com/team/fxcop.

转载请注明原文地址:https://www.9cbs.com/read-16680.html

New Post(0)