Andrew Bezzub
Andrew Bezzub

Reputation: 16032

Specify path to CustomDictionary file for StyleCop spellchecking

Spell checking of the comments was added to the recent versions of StyleCop. It seems I can reuse my existing CustomDictionary file (that I created for FxCop) with StyleCop. SA1650 rule documentation does not say that it is possible. But in release notes for version 4.7.39 I see

Add support for specifying dictionary folders in the settings.StyleCop file.

How do I configure StyleCop to search for this file in the root folder of my solution?

Upvotes: 13

Views: 10914

Answers (4)

Marek Dzikiewicz
Marek Dzikiewicz

Reputation: 2884

In my case it worked when I specified the custom dictionary entries in the Settings.StyleCop file located next to the .csproj file.

<GlobalSettings>
  <StringProperty Name="MergeSettingsFiles">NoMerge</StringProperty>
  <CollectionProperty Name="RecognizedWords">
    <Value>word1</Value>
    <Value>word2</Value>
    ...
  </CollectionProperty>
</GlobalSettings>

Actually, the StyleCopSettingsEditor.exe utility created these settings for me. I opened it using the project's context menu in Visual Studio, using the "StyleCop Settings" menu item.

Upvotes: 7

Boinst
Boinst

Reputation: 3505

Add a file named Settings.StyleCop in your solution root directory with the following content:

<StyleCopSettings Version="105">
  <GlobalSettings>
    <CollectionProperty Name="DictionaryFolders">
      <Value>**my-dictionary-folder**</Value>
    </CollectionProperty>
  </GlobalSettings>
</StyleCopSettings>

Where you replace my-dictionary-folder with the relative path to the folder containing your CustomDictionary.xml file.

Upvotes: 6

Mightymuke
Mightymuke

Reputation: 5144

A similar question has been asked here http://stylecop.codeplex.com/workitem/7422 and there is an open ticket here http://stylecop.codeplex.com/workitem/7435 which I believe will provide what you're looking for if it gets done.

Upvotes: 0

Paul Hunt
Paul Hunt

Reputation: 3575

According to the StyleCop documentation for rule SA1650

The CustomDictionary.xml file should be placed in the same folder as the StyleCop.dll and the Rules. That folder (and all subfolders) are checked for the dictionary files. StyleCop loads CustomDictionary.xml, CustomDictionary.en-GB.xml and then CustomDictionary.en.xml (where en-GB is the culture specified in the Settings.StyleCop file). StyleCop also loads custom.dic, custom.en-GB.dic and then custom.en.dic (where en-GB is the culture specified in the Settings.StyleCop file). Recognized words can also be added to the Settings.StyleCop file using the Settings Editor on the spelling tab.

So it appears that you would have to put a copy of CustomDictionary.xml in that specific location rather than in the root of the solution folder.

Upvotes: 0

Related Questions