Disable Automatic File Header Creation (ReSharper and StyleCop)
Asked Answered
L

2

10

I recently installed R# 6.1 (C# version, not Full) with StyleCop 4.7.34.0 (with the R# plugin). When adding a new class to a project, the file header information is automatically added. How do you disable this?

I've turned off the checkbox for "Insert text into documentation and file headers" within the R# options for StyleCop (Options > Tools > StyleCop > Headers section).... but still no luck.

I've also turned off StyleCop rules SA1633 to SA1640 that requires the header documentation.

I found this related post that suggests:

ReSharper -> Options -> Tools section -> Code Cleanup -> select StyleCop profile -> Documentation section -> untick 1600

but I don't have a "Code Cleanup" node in my tools section. Not sure if the fact that I'm using a "C#" version of R# has something to do with it.

Loess answered 11/7, 2012 at 22:48 Comment(2)
Did you end up finding a solution? or did the one below ever end up working for you?Fireguard
No, never found a solution. Just ended up deleting the header manually when creating new classes.Loess
F
1

The problem is actually because of this: http://stylecop.codeplex.com/discussions/348351/

When you try to uncheck the StyleCop settings under Code Cleanup (Options > Code Editing > Code Cleanup > StyleCop > 1600 and 1633-1641) and click Save it does not actually save the changes! This seems to be a bug in ReSharper.

The only workaround i've found is to make a new profile (Add) and immediately uncheck 1600 then click Save. This will have to be set as the Profile to use on silent cleanup. Good luck


EDIT: here are the settings for my profile that is set as the 'silent cleanup' one. It does not add the headers. hope that helps ReSharper Code Cleanup Profile

Fireguard answered 11/7, 2012 at 23:13 Comment(3)
I added the new profile, unchecked 1600 and saved (with profile set for silent cleanup)... but no luck. When I create a new class the file header is still added.Loess
Thanks for including the screenshot. I matched the settings but no change. I do notice that if I add a new class to a class library project it has the header automatically added while added a new class to a web project in the same solution doesn't have the header (as desired).Loess
well if adding a class immediately results in headers at the top before saving .. thats just because that is what the 'Class' template has. These resharper options would only effect whether it's added upon saving each time.Fireguard
M
0

I had this problem and found that the issue was not ReSharpers global StyleCop settings (arserbin3s answer); but the project specific ones.

Right click on your existing project and select "StyleCop Settings". First step

From there deselect "Documentation Rules" (or the specific rules you desire). Second step

Finally, I had to close and open Visual Studio. This prevented Resharper refactors from writing the headers and documentation.

You may have different context menu options to me. Either way, the key is that StyleCop can be project specific.

stylecop.codeplex.com/wikipage?title=Managing%20StyleCop%20Project%20Settings

Maletta answered 19/5, 2016 at 14:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.