New for Visual Studio 2008 - Custom Dictionaries
Once you turn on the new spelling rules that we've added to Visual Studio 2008, you will want to start to customize the words that it fires on; this is where the new custom dictionary support comes in. A custom dictionary in its basic form, similar to the concept in Microsoft Word, allows you to silence the spell checker over the words that are not in the standard dictionary, such as company and product names.
Adding a custom dictionary to a project
To add a custom dictionary to a C# and Visual Basic project is simple:
In Solution Explorer, right-click on the project and choose Add -> New Item...
Under Templates, select XML File, enter a name for the dictionary, such as CodeAnalysisDictionary.xml and click Add
In Solution Explorer, right-click on the XML file and choose Properties
In the Properties tool window, under Build Action choose CodeAnalysisDictionary
In Solution Explorer, double-click on the newly created dictionary to open it
In the XML editor, paste the following, replacing [productname] and [companyname] with your team's equivalents:
<?xml version="1.0" encoding="utf-8" ?>
<Dictionary>
<Words>
<Recognized>
<Word> [productname] </Word>
<Word> [companyname] </Word>
</Recognized>
</Words>
</Dictionary>
You are now ready to start entering your own custom words. Simply add a new <Word> element for each word in your project that does not exist in the dictionary. Each word is case-insensitive, so any casing of the word will be recognized. Code Analysis will automatically pick up the custom dictionary the next time it is run.
Sharing a custom dictionary between projects
Once you have worked through the above steps, the following will be added automatically to your MSBuild-based project (ie csproj or vbproj):
<ItemGroup>
<CodeAnalysisDictionary Include="CodeAnalysisDictionary.xml" />
</ItemGroup>
This means that similar to other Code Analysis properties and items, this information can be placed a common targets file to be shared by multiple projects.
If you do not want to have all projects share a common MSBuild targets file, you can instead do the following:
- Place the custom dictionary file created above in a shared location, such as alongside the solution
- In Solution Explorer, right-click on a project and choose Add Item...
- Browse to and click the custom dictionary to select it
- On the Add button, click the down arrow to drop a menu and choose Add As Link
- In Solution Explorer, right-click on the custom dictionary and choose Properties
- In the Properties tool window, under Build Action choose CodeAnalysisDictionary
- Repeat steps 2 - 6 for each project you want to share the custom dictionary
Advanced usage of a custom dictionary
I have shown you above basic usage of the new dictionary support the Code Analysis team has added to Visual Studio 2008. Those that have previously used custom dictionaries with FxCop, will realize that there are more things that you can add to these files that will customize other naming-based rules. However, for now I will leave you with the above and talk about advanced usage of a custom dictionary in future posts.
Comments
Anonymous
August 20, 2007
PingBack from http://www.universityupdate.com/Technology/Visual-Basic/4674787.aspxAnonymous
August 22, 2007
The Teams WIT Tools Blog on Rosario: Filtering link types on a work item form and What is a Team...Anonymous
August 22, 2007
Great!!!!! I talked about adding this with Noah Coad in my Orcas TAP meetings :o))))Anonymous
August 22, 2007
Al fin!!!!!!!!, algo que ya había comentado como parte de mi participación en el TAP de Orcas, es laAnonymous
August 22, 2007
Al fin!!!!!!!!, algo que ya había comentado como parte de mi participación en el TAP de Orcas, es laAnonymous
August 23, 2007
Time for another weekly roundup of news that focuses on .NET and general development related contentAnonymous
October 11, 2007
Since I started to move some of my projects to Visual Studio 2008, I suddenly got a lot more warningsAnonymous
November 22, 2007
In previous posts about Code Metrics and Code Reviews , I explored some metrics and techniques that IAnonymous
November 25, 2007
In previous posts about Code Metrics and Code Reviews , I explored some metrics and techniques that IAnonymous
December 19, 2007
FxCop 1.35 Spell Checking Uses Office 2003Anonymous
February 18, 2009
Solo algunos breves comentarios para los que están programando objetos, o están empezando a programarlos