FxCop Spelling Rules


In addition to FxCop's Globalization rules, FxCop includes a number of spelling rules, shown in Table 13.1.

Table 13.1. FxCop Spelling Rules

Rule Name

Category

Check Id

Description

Identifiers should be spelled correctly

Microsoft.Naming

CA1704

The individual words that make up an identifier should not be abbreviated and should be spelled correctly.

Literals should be spelled correctly

Microsoft.Usage

CA2204

Literals should consist of correctly spelled words.

Resource strings should be spelled correctly

Microsoft.Naming

CA1703

The individual words that make up a resource string should not be abbreviated and should be spelled correctly.


FxCop's Spelling rules are available only in the stand-alone FxCop, not in the Visual Studio 2005 Team System FxCop, because it was not possible to provide these rules for all localized versions of Visual Studio 2005.


The rule that is most relevant to internationalization is the "Resource strings should be spelled correctly" rule. This rule checks the spelling of words in the fall-back resources. Say that you have a resource string called "TheUltimateAnswer" and it has the value "Noobdy writes jokes in base 13". FxCop reports:

 Correct the spelling of 'Noobdy' in 'TheUltimateAnswer' == 'Noobdy writes jokes in base 13' contained in resource stream 'FxCopTest1.Form1Resources.resources'. 


This is very useful, but there are a few things you should know. First, the spell checker requires Microsoft Office to be installed on the machine on which FxCop is running (at least one of the Office products must be version 2000 or later). If it is not installed, the rule doesn't perform any spell checking (but it doesn't cause FxCop to fail). Second, the "Resource strings should be spelled correctly rule" checks only the fallback assembly, not satellite assemblies. Third, you can add new words to the spell checker's dictionary by adding entries to CustomDictionary.xml. You can create a new CustomDictionary.xml in the same location as your FxCop project file to apply to a single FxCop project. This is the simplest option if your project is managed by a version-control system, and your FxCop project and CustomDictionary.xml are included in the version-control system. Alternatively, you can create a new CustomDictionary.xml in your user settings directory to apply to all projects for a single user. In addition, you can modify the CustomDictionary.xml in FxCop's directory to apply to all projects for all users.

You can change the dictionary that these rules use by opening FxCop.exe; selecting Project, Options...; selecting the Spelling & Analysis tab; and selecting a new language in the Dictionary Locale combo box. Note that the same language applies to all spelling rules. This represents a problem because often developers will write code using U.S. English (using U.S. English identifier names such as "color") but create fallback resources using a different language. This is even true in countries such as Australia, Canada, and the United Kingdom, where code is often written in U.S. English but fallback resources are in the countries' native English. In a future release of FxCop, it is expected that it will be possible to specify two locales for a single project (where words can match the dictionary for either locale to pass the rule) and also to specify one dictionary for code and a separate dictionary for resources. Until then, you will have to create two FxCop projects: The first would perform analysis on the code (using one dictionary), and the second would perform analysis on the resources (using the other dictionary).




.NET Internationalization(c) The Developer's Guide to Building Global Windows and Web Applications
.NET Internationalization: The Developers Guide to Building Global Windows and Web Applications
ISBN: 0321341384
EAN: 2147483647
Year: 2006
Pages: 213

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net