We're using ReSharper 6.0 with StyleCop for ReSharper.
Although we use the StyleCop rule that members must have documentation headers, we don't want ReSharper's code cleanup facility to generate documentation headers for us, because they're inevitably rubbish. Bad doc headers are worse than none at all because they're less likely to be updated than added in the first place.
We tried turning off the setting 'Insert text into documentation and file headers' in ReSharper => Options => Tools => StyleCop but it bloody resets itself when you restart visual studio.
Any ideas how we can stop Code Cleanup creating documentation headers for us?
ReSharper -> Options -> Tools section -> Code Cleanup -> select StyleCop profile -> Documentation section -> untick 1600.
Will prevent default documentation headers being created but StyleCop will still enforce that they should be there.
The second step, after blocking code generation is Removing the rubbish.
I used a regex Search/Replace through visual studio.
Regex is for header :
// ---.*\r\n\/\/.*\r\n\/\/.*\r\n\/\/.*\r\n\/\/.*\r\n\/\/.*\r\n.*\r\n\/\/.-{116}
Regex to remove Generated summaries
\s{4}\/\/\/\s<summary>(.*)\r\n.*\r\n.*</summary>
Caution : it will remove ALL summaries, even the good ones, so check the replacement scope before launching it. (git checkout might be your friend...)
Related
Update: Using StyleCop for ReSharper Plugin did the trick for code analysis inside VS. But unfortunately it seems that ReSharper plugins don't work in ReSharper command line inspections.
Is there a way to make ReSharper check for correct file headers just like classic StyleCop did. I'm aware that there is a way to define file headers to be inserted in new files, but we are using Resharper command line inspections to check a rather big legacy codebase. So it would be helpful if there was an automatic check for correct file headers.
I'm referring to StyleCop rules SA1633 up to SA1649.
This isn't exacly an answer to your question but you can use editorconfig to increase the error level during build.
Refer to roslyn editorconfig
My understanding is that running StyleCop as a ReSharper extension uses the Analyzer technology built into VS 2015 and, in this way, it differs from downloading and installing StyleCop as a standalone program. When I previously installed StyleCop as a standalone program, I had access to a StyleCop .Settings file that let me use the StyleCop dialog box for selecting certain options. Among those options was a Company Information tab, into which you can place Company Name and a Copyright notice:
StyleCop Settings Documentation for the Company Information Tab
When ReSharper shows a StyleCop rule that needs attention and it has to do with adding a XML summary comment to the top of my class, ReSharper places the comment text for me. However, there is a space for Company Name and that value is always blank. This means that I must modify it manually, and that's tedious.
Question:
How do I tell ReSharper to populate the Company Name field with a certain value? Can I do that on a solution basis or does that Company Name field get defined globally?
Thank you.
If you're using StyleCop for ReSharper, it's actually using the same StyleCop parser that the command line uses, and not the VS2015 analyzers (unless you're actually using StyleCopAnalyzers). However, inserting comments and rewriting code is all ReSharper code. The plugin will still use your existing stylecop.settings files, and the company name comes from there. You can edit the file with the settings editor from the normal install of StyleCop.
is it possible to only enable resharper for javascript and css files? I don't want it inspecting my c# files as it's driving me nuts with it's styling and and at times somewhat controversial recommendations. I haven't got time to set each individual setting, I'm just looking for a "don't inspect c# files" check box, if there isn't one I think my resharper trial will be officially over.
If you really want to disable ReSharper for C#, try going to ReSharper | Options -> Code Inspection | Settings -> Edit Items to Skip and add a file mask to skip *.cs.
But better way would be to disable those ReSharper warnings that you don't like. To do this, click Alt-Enter on the suggestion that you don't like, go to Options submenu, select Configure inspection severity and then Do not show. This is for ReSharper 8.0, in 7.1 it should be pretty similar.
I noticed a strange behaviour in my VS2012 installation. I use VS2012 Pro and ReSharper 7. Intellisense is just not showing code suggestions anymore. I found a few related questions in my research but they always had a slightly different setup going and none could solve my problem:
Intellisense is working but, it's not showing the tooltip about selected member functions/Properties anymore.
If I take a look at the C# Text Editor Settings in
Tools -> Options -> Text Editor -> C# -> General
Most of the times the two necessary boxes Auto List Members and Parameter Information are selected. However, code suggestions in Intellisense don't work. Sometimes, when I look at the described settings, they are unselected.
Selecting them will make code suggestions work as in VS2010 but, only once. When I check the settings afterwards, they are most likely still selected, but code suggestions are not working anymore.
Some people suggested deleting the %AppData%\Roaming\Microsoft\VisualStudio\11.0 Folder, which did not work for me. I also tried to reset all changes, which also didn't help at all.
Tools -> Import and Export Settings -> Reset
What in the world could make Visual Studio to just forget its settings and trigger such an irrational behavior?
-edit-
I display the code suggestions by pressing CTRL+Alt+Space. However, I have to press that shortcut every time I want to see the suggestions. It has to be possible to automatically display them every time, when possible?
I was having a similar problem, but I kept overlooking one small ReSharper Intellisense setting. I would double check that you have Symbol completion on in
ReSharper | Options | Intellisense | Completion Characters
Check out the answer with screenshots.
Thanks for all the tips, I figured out what I had missing:
I had to enable "Completion Appearance" -> "Show Summary".
I also accepted Anthonys answer because he linked to a detailed post with screenshots that shows all steps necessary. (Although the thing I had missing is not mentioned there)
ReSharper uses it's own code suggestions that override Visual Studio ones, that could be the reason why the ones in the Visual Studio settings may be disabled. Please check ReSharper options at ReSharper -> Options -> Environment -> IntelliSense. Maybe they are turned off there. If your ReSharper options are turned on but you still have no intellisense, then please ReSharper's support at http://www.jetbrains.com/support/
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.
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
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