Visual Studio Team System
How to: Customize the Code Analysis Dictionary

Code Analysis checks the spelling of identifiers in your code against a built-in dictionary. If it cannot find a word in its dictionary, it fires the following warning: Identifiers should be spelled correctly.

For example, suppose your code contained a class named DoorKnokker. Code Analysis would see the identifier as a compound of two words—door and knokker. It would then fire a warning that knokker was not spelled correctly.

However, you can add words to the Code Analysis dictionary by creating a custom dictionary XML file. Place the file in the project folder if you want the new words to be project-specific. However, if you want the new words to apply to all projects, put the file in the Visual Studio root folder and then restart Visual Studio.

To create a custom dictionary

  1. Create a file that is named CustomDictionary.xml.

  2. Define your custom words by using the following XML structure.

    <?xml version="1.0" encoding="utf-8"?>
    <Dictionary>
        <Words>
            <Recognized>
                <Word>knokker</Word>
            </Recognized>
        </Words>
    </Dictionary>
    

    The words defined in this structure are case insensitive. Therefore, both knokker and Knokker will be recognized.

  3. To use the custom dictionary with all projects, put the file in the Visual Studio root install folder and restart Visual Studio. For a project-specific custom dictionary, put the file in the project folder.

    Bb514188.alert_note(en-us,VS.90).gifNote:

    Do not add compound words, such as TextBox, to the custom dictionary.

Tags :


Community Content

Thomas Lee
Adding a custom dictionary to a project

To add a custom dictionary to a specific project:

  1. Create the CUSTOMDICTIONARY.XML
  2. Add the CUSTOMDICTIONARY.XML to the project
  3. Set the Build Action to CodeAnalysisDictionary
  4. Set Copy to Output Directory to Do not copy
Tags : xml

Thomas Lee
More Xml elements

<?xml version="1.0" encoding="utf-8" ?>
<Dictionary>
  <Words>
    <Unrecognized> 
        <Word>cb</Word>
    </Unrecognized>
    <Recognized>
       <Word>knokker</Word>
    </Recognized>
    <Deprecated>
        <!--<Term PreferredAlternate="EnterpriseServices">ComPlus</Term>-->
    </Deprecated>
  </Words>
  <Acronyms>
    <CasingExceptions>
     <!--<Acronym>CJK</Acronym>-->
       <Acronym>SHA</Acronym>
       <Acronym>MD5</Acronym>
    </CasingExceptions>
  </Acronyms>
</Dictionary>

Eli Thompson
You can use "add as link" to share a single dictionary across multiple projects
You can also have a common CustomDictionary.xml file for all projects in the solution by placing it in the solution root and then using "add as link" to include it in each of your projects. You must also set the Build Action property of the file (link) in each project to "CodeAnalysisDictionary". This allows you to check it into the source tree.

Adding it to the VS install root means it can't be under source code control which makes that option of limited utility in my book.

Ade
Tags :

Don.Frazier
Add CodeAnalysisDictionary Schema to Visual Studio
Also on MSDN, this tool gives instructions on how to add a schema to your Dictionary and hook it up so Visual Studio's intellisense will help you fill one out correctly.

http://code.msdn.microsoft.com/CADictionaryXSD

Page view tracker