CustomDictionary.xml in project without Settings.StyleCop

Oct 1, 2012 at 8:03 PM

We use a standard StyleCop setup and don't have a need to include a Settings.StyleCop file with each project.  However, we would like to have a project-specific CustomDictionary.xml file (which we're already using for FxCop/Code Analysis).  However, it doesn't look like StyleCop is picking up on that file.  Is it possible for it to use that project-level file, or do the CustomDictionary.xml files always need to be with a Settings.StyleCop file?

Coordinator
Oct 2, 2012 at 11:47 AM
Edited Oct 2, 2012 at 11:47 AM

From 4.7.39.0 you can specify folders to search for CustomDictionary.xml files like:

 <GlobalSettings>
    <CollectionProperty Name="DictionaryFolders">
      <Value>c:\bob\dave</Value>
      <Value>%USERPROFILE%\MyDictionaries</Value>
    </CollectionProperty>
  </GlobalSettings>
Oct 2, 2012 at 2:18 PM

Can you have relative paths in there?  It still makes it hard to include in a project if you have to put the full path (or if it has to be in the global settings file)...

Coordinator
Oct 2, 2012 at 2:27 PM

Environment variables are expanded if that helps. It also looks in the same folder as the cs file its analysing already.

I'll add relative paths to the next build.

Oct 2, 2012 at 2:34 PM

I'm still getting a warning when I add a CustomDictionary.xml to the directory of the cs file. Anything I might be missing?

What I'd really prefer is for StyleCop to look in the root of the project, like FxCop does (not sure if FxCop does directory traversal, or just looks in the root).  Is that something that might be on the table as an option in the future?

Coordinator
Oct 2, 2012 at 2:39 PM

No, that should work fine. I'll add the root of the project too.

Coordinator
Oct 2, 2012 at 2:39 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Oct 2, 2012 at 2:42 PM

Great, thanks a bunch.

Oct 5, 2012 at 3:10 PM

Awesome, just upgraded to 4.7.41 and it's working perfectly.  Thanks again!

Developer
Oct 16, 2012 at 1:23 AM

What is a relative path relative to? The stylecop settings file?

For example, can I do this to check for a CustomDictionary.xml in the same folder as the settings file?

<GlobalSettings>
    <CollectionProperty Name="DictionaryFolders">
        <Value>.</Value>
    </CollectionProperty>
</GlobalSettings>