Setting StyleCop rules

Answered

Hi folks,

I try to use this configuration:

VS2015 Pro. Update 1

Re# Ult v. 10.0.1

StyleCop by Jetbrains extension v. 4.8.0

Coming from this: 

VS2013

Re# 8.2

(Original) StyleCop 4.7.49.0

The new configuration ignores our StyleCop settings file.

As I understand I need to write the configuration settings again (any import available?). However I cannot find the place to turn the settings on and off. I was hoping to see something like this:

http://stackoverflow.com/a/11442901

But cannot find the "StyleCop" node under the "Xml" node in my config.

 

 

Any ideas how to transfer our settings to the new tools?

3 comments
Official comment

Hi Andrius. It shouldn't be ignoring the settings file. Can you give an indication of what's being ignored, please? (It will ignore the default settings file in the Program Files folder from the old standalone install. If you've edited that, then it will be ignored.)

As for setting up the code cleanup, the StyleCop settings live under C#, as they only affect C# code. The settings have also changed since that StackOverflow post - there are now only two options "Fix StyleCop violations" and "Generate XML Doc stubs". Before, there was a setting for each rule, now, it will just fix any rule that's been violated (that it has a fix for). The idea here is that if you disable a rule in the settings file, it also disables it from code cleanup. And if you've got the rule enabled, then ReSharper should fix it for you - why would you want to leave the violation? Generating XML Doc stubs are a separate option - generating the stubs fixes the violation, but they're only stubs, and not very useful without further editing. You're possibly better off manually using alt+enter to create the stub, and then edit.

Hi Matt,

 

thx for the quick reply!

I didn't create the settings file back then. So am trying to learn which settings are Re# specific and which are StyleCop specific.

What I do miss so far is the automatic file header generation defined in the StyleCop settings file. I do get a SA1633 warning and can generate the header "manually" but on silent cleanup (CTRL+E,F) the file header is not written.

Also there is a setting where all [Import] attributes are grouped into an Import-region and all [Export] attributes are grouped into an Export-region. On silent cleanup those properties are not regrouped unfortunately.

And btw: I do not want to leave the violation of course. I expect all violations to be cleaned up silently if possible.

1

 Hi all,

Nice job, I cannot live without StyleCop for R# :-) A few suggestions if I may :

Andrius> You can edit the Settings.Stylecop using the UI from StyleCop standalone application (download it on CodePlex). After installation there is a windows shell extension that allows you to "open" the settings file with the StyleCop UI (a treeview gizmo with checkboxes for each and every SA rule)

Matt> I noticed that hitting CTRL-E-C is a lot faster that it was using previous version (anyway I used StyleCop for R# plugin with R# 8.2, so its hard to say what is the exact reason for this gain). At this time most of the behaviors are identical to what I was used to, but one that is bugging me a bit. Code regions have disappeared, whenever I reformat a cs file, the only region remaining is the one for usings, previously I had several regions regrouping parts of the same code (Constructors, Public Properties, Fields, etc ...), I found them to be quite useful for readability. Is it on purpose ?

Matt> A nice to have would also be to be able to handle several files at the same time (as far I can see it's a 1-thread operation), when you want to reformat a whole project or a whole solution, taking all the available cores is of some use (I took 20 minutes for a whole solution I my today tests, 186 projets). A Parallel.ForEach should do the trick :>

 

1

Please sign in to leave a comment.