Code Analyzer Rules

The code analyzer in the spell checker extension is used to spell check identifiers in source code. Only C# is supported right now but future support for Visual Basic and, if possible, F# are planned. Code analyzer spell checking differs from the string and comments spell checker implemented using the tagger in the editor. Identifiers are always split up into separate words on capital letters and other separators such as the underscore. In addition, there are some extra options related to visibility and placement that can control when spell checking of identifiers occurs. See the Code Analyzer Options configuration category topic for details. Due to the way code analyzers work, there are some limitations. See the Known Issues and Limitations topic for more information.

The code analyzer contains two rules: VSSpell001 used to flag misspelled words in identifiers and offer suggested fixes and VSSpell002 used to offer an option to add the misspelling to an Ignore Spelling directive comment in the source code file. The first rule defaults to a warning and will show the usual warning underline on the misspellings. The second rule is hidden by default and only appears on the smart tag when it is opened.

Place the mouse over the misspelled identifier and click the down arrow on the smart tag to see the available options. Alternately, you can place the cursor anywhere in the identifier and press Ctrl+. or Shift+Alt+F10 depending on your version of Visual Studio to show the smart tag options. Note that if an identifier consists of multiple words and more than one is misspelled, each misspelled part is flagged and corrected separately.

Select the "Correct spelling of 'XXX'" option to see the suggested replacements. If the misspelling represents only a part of the identifier, you will see the rest of the identifier in each suggestion. Select a suggestion to get a preview of the changes that will occur if it is selected. To add the misspelling to an Ignore spelling directive comment in the file, select the "Ignore word 'XXX'" option and a preview of the directive will be displayed. The directive comments is placed at the top of the file below any header comments and above the first directive, using statement, or namespace declaration. If a directive comment already exists in that location, the new ignored word will be added to it.

See Also