Share Your Source Code or Article

Do you have source code, articles, tutorials, web links, and books to share? You can write your own content here. You can even have your own blog.

Submit now...

Database Programming Made Easy

This tutorial will teach you step by step on how to connect and manipulate database. If you'd like to suggest a tutorial please write a comment at the bottom of this article.

Read more...

Hire Us to Do Your Work

Do you want a customized system? Do you want to setup your own website to do business? Then we are here to help you in your programming needs.

Read more...

Search

Conform with Standards using Microsoft FXCop, A Code Analysis Tool for .NET
arjay_nacion's picture


0
Your rating: None
Language: 

When you are already in a production environment, working 8 hours a day or so, developing applications for clients, you must be aware of guidelines and standards needed to be followed in order to assure that your program is robust and maintainable.

Microsoft FxCop is a code analysis tool that checks .NET managed code assemblies for conformance to the Microsoft .NET Framework Design Guidelines. It uses MSIL parsing, and callgraph analysis to inspect assemblies for more than 200 defects in the following areas:

Library design
Globalization
Naming conventions
Performance
Interoperability and portability
Security
Usage

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

Microsoft FX Cop

Microsoft FX Cop checks Naming Rules for example:

Visual Basic

  1. Dim StrWord as String

C#

  1. string StrWord;

Microsoft FxCop would complain and instruct you to use Camel Casing for these variables and to avoid abreviation such as "Str" as prefix. To fix this issue, you may change your declarations to something like this:

Visual Basic

  1. Dim wordEntered as String

C#

  1. string wordEntered;

For method names and properties, it is advised to use Pascal-Casing, that is capitalizing each letter of each word like:

Visual Basic

  1. Public Property ProductCode As String
  2. ...

C#

  1. public string ProductCode {
  2. get { ... }
  3. set { ... }
  4. }

Microsoft FXCop also checks for wrong implementations like when checking a string if it is null or empty, some might use this implementation:

C#

  1. if ( wordEntered.Equals(string.empty) ) { }

OR

C#

  1. if ( wordEntered.Equals("" ) { }

Microsoft FXCop recommends using the string.IsNullOrEmpty function to check for empty strings like this:

C#

  1. if ( string.IsNullOrEmpty(wordEntered)) { }

FXCop still has so many features such as checking for security holes in the code, code performance, localization etc.

To check the full functionalities of Microsoft FXCop, you can download it freely at Microsoft at this address:

http://www.microsoft.com/downloads/details.aspx?FamilyID=9aeaa970-f281-4...

Try Microsoft FXCop. It would really change your coding habits.
Happy Coding!

AttachmentSize
fxcop.jpg197.59 KB



Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <java>, <java5>, <javascript>, <mysql>, <php>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • Links to specified hosts will have a rel="nofollow" added to them.

  • You may insert videos with [video:URL]

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.

Relevant Content

Step by Step Java Tutorial

In this tutorial you will learn how to program with Java. It has a rich of information to be educated well with Java.

Read more...

Do You Have Question?

Do you have any question related to computer programming? Visit our forum and post new topic on the category you like. Be gentle when asking a question.

Ask now...

Point of Sale

Point of Sale is very useful especially for supermarkets or restaurants. I have included a barcode scanner in this program. Please check it out.

Read more...