Sort "usings" directive by ReSharper Clean-up - resharper

How to setup ReSharper to call "Sort usings" in class?

I will answer for my question.
Using shortcut from Resharper it's not best solution. Nice tool is CodeMaid it makes few nice cleanup's when saving file like with no shortcut key press:
sorting usings alphabetically and remove unused
deleting empty lines
This tool is complement for Resharper.

Resharper (9) will sort usings if you run Code Cleanup, via menus or keyboard shortcut CTRL+E, CTRL+C

Try using the Stylecop Resharper Plugin
Stylecop Rule SA1210: Using directives must be sorted alphabetically by the namespaces will allow you to use a quick fix to sort them by pressing ALT+ENTER.
Using Stylecop is good at helping you write clean code, but you may want to turn off some of the rules.

You don't need ReSharper to do this. By Default the shortcut CTRL+E, R will remove (unused) and sort the using statements.
If you only want sorting or the shortcut isn't set on your instance of Visual Studio, go to:
Tools-> Options.
Environment -> Keyboard
Search for "Editor.ContextMenus.CodeWindow.OrganizeUsings".
There are a few options there to play with.

This question already covers this:
Remove unused Usings across entire assembly
The feature is in ReSharper 4.5. If you right click on the solution,
there's a Cleanup Code... item, which allows you to apply a cleanup
profile to the solution. You can create a new cleanup profile from the
Code Cleanup node within ReSharper options, if you want a profile to
just adjust the using directives.

Related

Is there a way to make ReSharper check for correct file headers

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

resharper disable for c# .cs files

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.

How to get resharper to skip generated files

Resharper really complains about files such as reference.cs that is generated by things like WCF service reference. How do I get Resharper to skip such files entirely?
menu ReSharper -> Options
Code inspection -> Settings item
button Edit items to skip
I got this to work by entering Referen?e.cs into the ReSharper Generated file masks list. Apparently the presence of the ? wildcard tricked it into applying to all Reference.cs files (well, remember that it will get files named Referente.cs too, but I can live with that.

Ctrl-W stopped working

I have Resharper installed and somehow CtrlW no longer "extends the selection". I tried assigning it to Global / Resharper.ExtendSelection in Tools -> Options -> Keyboard but it still only selects one word.
I have found the resolutions. Go to ReSharper -> Options -> Visual Studio Integration -> Keybord Shortcuts --> ReSharper or IntelliJ IDEA.Next time when you press CtrlW, Visual studio will ask you about shortcuts. You will choice ReSharper shortcuts and that is it.
A solution i found was to reconfigure keys at the Text Editor level (they are defined at Global level and for some (annoying) reason Resharper overrides this.
So: (Tools->Options->Environment->Keyboard), set Use new shortcut to Text Editor and redefine your shortcuts.
Tip: Look for your CtrlW favorites by writing view. at Show commands containing.
I needed View.ErrorList (CtrlW, CtrlE), View.Output (CtrlW, CtrlO) & View.SolutionExplorer (CtrlW, CtrlS)
HTH
p.s.
I even disabled Resharper and it still won't work...
A question and a suggestion:
Does Resharper | Edit | Extend Selection work?
Reapply VS integration via Resharper | Options | Visual Studio Integration | Apply Scheme
For me the reason was a silly one:
My C# file was removed from the project accidentally, so resharper no longer regarded it as C# code and so there were no syntactical elements to extend the selection to. In other files it worked ok.
In my case (Visual 2019)
go to Tools\Options\Environment\Keyboard
set Apply the following additional keyboard mapping scheme to Resharper (Visual Studio)
I had the silliest reason.
after the resharper installation I didn't apply my license or started the evaluation.

How do I get Resharper to ignore the Designer file when navigating to a class?

In Resharper, if you ctrl-click the name of a class to naviate to its definition and that has a designer fie, Resharper will ask if I want to go to the X.cs or X.Designer.cs because the class is partial.
Does anyone know how to disable this annoyance so that it just goes to X.cs and ignores designer files?
A workaround I use is Ctrl-Shift-N (ReSharper classic bindings) or Ctrl-T (Visual Studio bindings) and start typing the class name. If you have your classes in files with the same name, you'll then be able to choose the correct one from the dropdown list.
This is a good question. Whenever I have a question like this, I file a suggestion at the ReSharper JIRA site. I'd recommend you do the same.
http://www.jetbrains.net/jira/browse/RSRP
I don't believe you can do what you want at the moment, even with the latest nightly build.
your best bet is to download the nightly build
i have no idea if they addressed this, although i think this is a feature, not an issue.
Nightly Builds

Resources