ReSharper, StyleCop and Custom Dictionary

Feb 5, 2013 at 10:52 AM
Hello,

My team is using ReSharper and StyleCop as a way to detect style errors.

We have a global Solution.DotSettings file that contains all the rules we want to apply. This file is saved in the repository. During the build the file is then copied (hard link) and renamed to each folder that contains a solution.

MySolution.sln
MySolution.sln.DotSettings (hard link to Solution.DotSettings)

This idea works very well for us because the only thing we need to do is to maintain the global Solution.DotSettings file.
<wpf:ResourceDictionary xml:space="preserve" ...>
    ...
  <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1650/@EntryIndexedValue">WARNING</s:String>
</wpf:ResourceDictionary>
For the rule SA1650 however we need to find a way to use a custom dictionary in a centralized way like we do for the rules.

Is there a way to add words in the Solution.DotSettings file?

Probably not.

I know that it is possible to add words in the file CustomDictionary.xml in the C:\Program Files (x86)\StyleCop 4.7 directory. I tried that and works. However it is not acceptable for us.

We want a custom dictionary saved in the repository and automatically used across all the team without requiring manual effort.

I looked around in the various discussions and tried a lot of things but I can't find a solution to this problem.

An idea was to save the StyleCop folder in the repository and add an entry in the Solution.DotSettings file pointing to the StyleCop.dll file in it.

<s:String x:Key="/Default/StyleCopOptions/SpecifiedAssemblyPath/@EntryValue">c:\devroots\WIServices\Athena1\external\StyleCop 4.7\StyleCop.dll</s:String>

If I do that, in the Visual Studio StyleCop tab I see that the "StyleCop location" is not "Automatically detect location" but the custom path I specified. Unfortunately it seems that it is still used the CustomDictionary in ProgramFiles.

I also tried to add a Settings.StyleCop file in the root of our project together with a CustomDictionary.xml file with the custom words but it does not work.

Any idea how to solve this problem?

Thanks
Feb 25, 2013 at 2:58 PM
Anyone on this?

Please ask me if you need clarification or the question is not clear.
Developer
Mar 4, 2013 at 2:34 AM
I believe you're heading in the right direction. Try putting the words directly in the StyleCop settings file. Here is the official documentation http://www.stylecop.com/docs/SA1650.html and here is a discussion that may help http://stylecop.codeplex.com/discussions/395755
Mar 4, 2013 at 9:01 AM
Hello,

Thank for you answer.

I know how to add custom words in the global StyleCop settings file. This obviously works. However, the problem is how to do it without using the global settings and integrating it in the Solution.DotSetting for ReSharper.

Please, look at my post carefully and tell me if something is not clear to you.

I am stuck with it.

I can try experimenting a little bit more, but I would like to have a suggestion that actually works from the StyleCop team on this.
All my tentative were a failure except changing directly the global StyleCop settings file but that is not acceptable for us.

Andrea
Developer
Mar 4, 2013 at 9:14 AM
Hi, I'm not sure that you read my comment correctly. I didn't say to put it in the global settings file - put it into your project stylecop settings file. If you're not sure how to do this, take a look at the documentation.

You can't put it in your resharper settings file - there is no support for that.

As I'm not a member of the StyleCop team, feel free to ignore my advice.

Cheers