Confusions regarding stylecop, stylecop for resharper, stylecop by jetbrains.



Some confusions/issues regarding stylecop I encounter, costing me quite some time, rather annoying:

A) Some time ago we had resharper, stylecop, and stylecop for resharper, each having its own function and purpose.

Now we seem to have 'StyleCop by JetBrains' as resharper extension available thru the extension manager.

What is 'StyleCop by Resharper' exactly, is it 'stylecop' or 'stylecop for resharper' or an updated combination of the two?

Because when you click in the extension manager at 'StyleCop by JetBrains' on 'More info' you are referred to an article which is heading 'StyleCop for Resharper'. ?????? So you have to install StyleCop separately from the CodePlex site?

B) VS2013 or VS2017 with ReSharper 2017.1.1 and 'StyleCop by JetBrains 2017.1.1' installed. StyleCop SA1633. When I click on first line of the source file and click on the stylecop 'lamp' and click 'Insert/replace header...' then stylecop inserts header text without companyname and copyright text. Formerly you rightclicked on project and clicked 'StyleCop Settings' and got a form with tabs where you could fill in the company name and copyright text. Where did the form go? I expected it be be somewhere in the ReSharper UI now, together with other StyleCop settings that ARE there. I saw some posts regarding this matter before but no clear and definite answers/solutions. Settings.StyleCop file settings seem to work but this is history now isn't it? Because the settings are now in the StyleCop.DotSettings file. I specified the file header text in StyleCop.DotSettings: that does not work. Is this then a bug? I mean this is becoming a mess, mostly because, at least as I experience it, there is NO CLEAR COMMUNICATION by JetBrains regarding the EVOLUTION of these tools during the last 1 - 2 years. Honestly, I searched through the web but after a lot of time I still ended up confused...

I hope somebody can shed some light on these matters...

Thanks in advance!




Official comment

Hi Henk. "StyleCop by JetBrains" is our version of the StyleCop plugin for ReSharper. "StyleCop for ReSharper" is just the title of the readme in the GitHub repository.

The confusion is due to StyleCop itself not being under active development for about 18 months, and only recently restarting development. During the time it wasn't being developed, there was an unofficial version of the plugin published on ReSharper's plugin gallery that was buggy. The developer of this version didn't respond to emails, and we (JetBrains) were getting support requests, so we created a fork of StyleCop on GitHub, cleaned up the plugin and published it as "StyleCop by JetBrains". It's the official version of the plugin, confirmed since development of StyleCop itself restarted.

The status of the plugin is that we (JetBrains) are maintaining it, but not adding new features. We'll support it for new versions of ReSharper, and we'll happily support any developers in the community who wish to contribute to it. We'll also likely upgrade it to the newer versions of StyleCop that are currently in development.

The plugin does not ship with the settings editor - you have to edit the settings.stylecop files as XML. This is because this is a plugin to ReSharper, and there is no way to associate the settings.stylecop files with the editor - this requires registration with Visual Studio. You can always *also* install the StyleCop Visual Studio plugin, and this will register the editor for the files.

The other main difference between these two plugins is that the ReSharper plugin gives you highlighting in the editor for rule violations, as you type, while the Visual Studio plugin will run and display everything in the output window.

There is no user-editable StyleCop.DotSettings file. The plugin does ship this file, but it is intended to be readonly, and contains the default settings that configure ReSharper to match StyleCop's defaults. The ReSharper StyleCop plugin will use settings.stylecop files to control StyleCop behaviour.

I hope this clears things up: tl;dr - "StyleCop by JetBrains" is the one and only StyleCop plugin for ReSharper. Settings are stored in settings.stylecop, and you have to either edit as XML, or install the Visual Studio StyleCop plugin to get the editor registered.

Thanks Matt, for your quick response.



You wrote: "Settings are stored in settings.stylecop" (last alinea). I ran some tests with ReSharper options dialog. It contains a StyleCop settings section, as shown below:


The settings look very similar to the StyleCop settings editor. Changing settings DOES influence stylecop behaviour (as you might expect) but the changes are NOT stored in the StyleCop.Settings file, but in a GlobalSettingsStorage.DotSettings file. So my conclusion is that StyleCop behaviour is determined by both settings files, right? So it seems that the stylecop settings editor UI is partly included in the ReSharper UI, but not completely, e.g. not the parameters for the file header and you cannot make a difference between public and private members as regards to documentation rules, which I experience as confusing and frustrating.

I would suggest to do one of the two:

  1. Include all stylecop settings in the ReSharper UI (to be shown only if 'StyleCop by Jetbrains' has been installed).

  2. Include the stylecop settings editor as part of the installation of 'StyleCop by JetBrains'.



Those are inspection severity settings, rather than StyleCop settings - they control only how the results are presented, rather than what results are generated and how. In other words, the only settings that get saved are whether a particular rule violation is shown as a warning (default), or suggestion, hint or error.

These settings don't control whether a rule is run, or the behaviour of a rule. While it is possible to change the severity to "Do not show", the rule is still being run, and if you run the command line version of StyleCop, violations of that rule would still be displayed. If I could, I'd remove both the "Do not show" and the checkbox here, as these don't affect the running of the rules, just the display of the results.

I wouldn't want to put any rule enable/disable flags into ReSharper's settings, as that introduces a new source of truth for the settings, and would cause more confusion if the command line version of StyleCop was run, for example on a continuous integration server.

The StyleCop settings are unfortunately incompatible with the ReSharper UI - StyleCop's setting files can be rather complicated with both hierarchical and linked files, and there is no good way to represent that in ReSharper. There is also no way to hook into writing a stylecop.settings file from ReSharper's settings dialog (and which file in the hierarchy would you write to?).

And while the ReSharper extension could ship the settings file, there is no good way to invoke it - a ReSharper extension cannot register a new editor for a file type, so double clicking the file wouldn't be able to start the editor.


I got it Matt, thanks for the data.


Hi Matt,

We'll also likely upgrade it to the newer versions of StyleCop that are currently in development.


Regarding the above comment, can you please give some clue when it will be done?



Please sign in to leave a comment.