Code Cleanup and StyleCop integration

We have semi-recently moved to ReSharper 2018.3.1 on Visual Studio 2017 and I’ve been working on integrating our StyleCop rules back into it. I’ve managed to get the StyleCop violations to show up in the editor through ReSharper and that works well. However, when I run the Code Cleanup, even with a configuration that includes "Fix StyleCop Violation", it does not consider our updated rules, which in turn cause the cleanup to make violations appear. For example, one of the rules we use states that each file must start with an XML header that includes copyright information. In the editor, I can easily see the warning and get an option to insert it that works fine. But if I run the cleanup, the header is instead removed.

 

In the previous version we used (8.2 on Visual Studio 2013, with the Stylecop 4.7.49 plugin), I would see a StyleCop section appear in the Code Cleanup configuration where I could edit the settings, but that does not appear to be the case in the newer version, or I have done something wrong with my installation. Running the Cleanup in that version would see the StyleCop formatting applied properly (in my example, it would insert the missing header).

 

Here’s what I tried so far :

- Install the StyleCop extension in Visual Studio (version 6.0.6902.2)

- Update the Settings.StyleCop file in the extension folder

- Install the Stylecop by JetBrains extension in ReSharper Ultimate

- Update the Settings.StyleCop file in both the Resharper installation folder and the plugins folder

- Enable StyleCop support under Code Editing -> General Formatter Style in ReSharper

- Enable Fix StyleCop Violations for the target configuration under Code Editing -> Code Cleanup in ReSharper

- Enable StyleCop plugins under the StyleCop menu in ReSharper and provide it with the location of the Visual Studio StyleCop extension location

 

My searches so far have not yieled any results. I was wondering if this is a limitation of the way StyleCop now integrates into ReSharper or if someone had managed to get it working and could point out where I went wrong in my configuration. Any help would be appreciated!

0
1 comment

Hello,

 

Sorry for the delay in responding.

To work with StyleCop rules in Resharper all you need is installing StyleCop by JetBrains plugin and checking correspondent option in ReSharper | Options | Code Editing | General Formatter Style, for detailed information please refer to the following blog post - https://blog.jetbrains.com/dotnet/2018/04/09/stylecop-code-style-settings-inspections/.

Seems that you've already made StyleCop work as you see StyleCop rules highlighted in the editor. 

We need to investigate why code cleanup doesn't apply "Fix StyleCop violations" option. Could you please provide Settings.StyleCop file and dotsettings from all layers (https://www.jetbrains.com/help/resharper/Sharing_Configuration_Options.html#managing). You can share all info using 'Submit a request' form.

Thank you.

1

Please sign in to leave a comment.