User Tools

Site Tools


notes:tools:resharper

ReSharper

Refactoring: Ctrl+Shift+R

Alt+Enter shows code assistance options:

While the menu is shown you can start typing an action name and ReSharper will show all related commands.

Search & Navigation

Command Keyboard Shortcut Remarks
Select a symbol and then:
Navigate > Go to Declaration
F12 - Navigates to the declaration of the selected symbol
- Navigates to partial classes and decompiled sources
- Navigates to base symbols or derived symbols of overridden members.
Navigate > Go to Everything / Type Ctrl+T - Also navigates to filenames.
- Allows you to include types from libraries.
- Supports camel humps search.
- Supports jumping to a specified line in source code.
- Double Ctrl+T allows you to search just the types (no filenames, no members, etc.).
Navigate > Go to Symbol Shift+Alt+T Navigates to a class as well as any class member.
Navigate > Go to File Member Alt+\ Navigates to members is the current file.
Navigate > Go to Text Ctrl+T Ctrl+T Ctrl+T Includes text in comments.
Navigate > Go to Action Ctrl+Shift+A - Searches ReSharper own functionality.
- Shows where the actions are in the menu.
- Shows keyboard shortcuts.

Navigate down and up the class hierarchy:

Command Keyboard Shortcut Remarks
Navigate > Derived Symbols
(after selecting an interface or a base class name)
Alt+End Shows derived classes from the selected interface or the base class.
Also shows the classes that derive indirectly (transitive relationships).
Navigate > Base Symbols Alt+Home You can also navigate to the base symbol by clicking an icon on the left gutter.
Inspect > Hierarchies Ctrl+E,H - Visualizes inheritance hierarchy.
- Brings architecture explorer (diagram).

You can also go up and down on the hierarchy of members such as overridden properties and methods.

Alt+` shows Navigate To menu. It shows any possible navigation option available for the selected symbol.

Numbered bookmarks, for example '1':

  • Toggle a bookmark: Ctrl+Shift+1
  • Go to a bookmark: Ctrl+1
  • Delete a bookmark: Del in the Bookmark menu
Command Keyboard Shortcut Remarks
Navigate > Bookmarks > Bookmarks Ctrl+` Shows the list of bookmarks (numbered and anonymous).

Find all locations a selected symbol is used:

  • Navigate > Usages of Symbol (Shift+Alt+F12) - shows usages
  • Find > Find Usages (Shift+F12) - shows a separate window with preview code

Find locations where a class is returned from a method or a property:

  • Navigate > Navigate To (Alt+`) > Exposing APIs

Find extensions methods which are defined on a selected class:

  • Navigate > Navigate To (Alt+`) > Extension Methods

Coding Assistance

Code Analysis

  • show available coding assistence options: put cursor over a symbol, Alt+Enter
  • Marker Bar

Usings and References

  • Import a missing using statement: Alt+Enter. It also creates a reference if needed.
  • You can also use the ReSharper NuGet browser.

Typing Experience

  • Duplicate a line of code or a selection: Ctrl+D
  • Extend selection: Ctrl+Alt+RightArrow
  • Rearrange code (mode a line of code up and down): Ctrl+Shift+Alt+UpArrow, Ctrl+Shift+Alt+DownArrow

Code Completion

  • Complete Statement (adding a semicolor, missing parentheses, scope brackets, etc.): Ctrl+Shift+Enter
  • Camel humps in IntelliSense code completion.
  • Double basic code completion: 2 x Ctrl+Space
  • Smart Code Completion (shows only relevant members in IntelliSense, for example, the ones that return an int): Ctrl+Alt+Space
  • Multi-level smart code completion shows indirect members: Ctrl+Alt+Space multiple times.
  • Generative completion examples: ctorf (a ctor that initializes all fields), ctorp (a ctor that initializes all properties), overrides (type a method name e.g., ToString and then press Tab).

Code Generation:

  • Open Generate Code menu: Alt+Insert

Postfix completion:

Postfix Templates

Encapsulating property generation:

Templates

Live Templates (Tools > Templates Explorer) include:

  • Templates imported from Visual Studio
  • Templates shipped with ReSharper e.g., cw generates Console.WriteLine
  • Custom templates

Create a new Live Template:

  • Click the button New Template from the toolbar
  • Provide body for the template
    • Template parameters:
      • $NAME$, example: public class $NAME$
      • $END$ - specifies where the cursor is located after the template is fully expanded
      • Parameters may be editable which means when the template is expanded, the user can type something
      • Parameters may use macros - a macro will expand in place of the parameter. Examples of macros: Clipboard content.
  • Define a shortcut for the template.
  • You can check the Reformat checkbox - the template will be automatically reformatted.
  • You can shorted qualified references. For example, System.IDisposable will become IDisposable
  • Save your template: File > Save Selected Items -or- Ctrl+S

Surround Templates (Tools > Templates Explorer) include:

  • Templates imported from Visual Studio
  • The $SELECTION$ template parameter specifies whatever we need to surround

Show built-in surround templates:

  • Edit > Surround With Template
  • Shortcut: Ctrl+E+U
  • Select a mnemonic from 0 to 9

Options

Access ReSharper options in Visual Studio:

  • Tools > Options > ReSharper Ultimate > [Options]
  • -or-
  • ReSharper > Options

Some options:

  • Environment > IntelliSense > General:
    • ReSharper
    • Visual Studio
    • Custom - allows you to specify which languages should use ReSharper or Visual Studio IntelliSense
  • Environment > IntelliSense > Autopopup - allows you to choose where IntelliSense should show up (per language).
  • Code Inspection > Code Annotations > [Copy C# implementation to clipboard] - copies the implementation of JetBrains.Annotations (such as CanBeNullAttribute or StringFormatMethodAttribute) to clipboard.
  • Code Editing > General Formatter Style - formatting styles applicable to all languages.
  • Code Editing > Members Generation - allows you to specify a default body of a new member, a new property, or documentation.
  • Code Editing > C#:
    • Naming (camel or Pascal)
    • Formatting (BSD or K&R, code preview), Blank Lines (how many blank lines and where), Line Breaks, Wrapping, Spaces (before parentheses, within parentheses, around brackets, etc)
    • File Layout (Public Delegates, Public Enums, Static Fields and Constants, Fields, …)
    • Namespace Imports: Namespaces that should never be removed, Namespaces that should always be imported
    • Code Style: styles for C#-features (var, this, using, etc.)
    • Null checking: Throw expression, Classic, etc.
  • Tools: Unit Testing, Debugger, NuGet, To-do Explorer, Stack Trace Explorer, etc.
  • Additional products: dotMemory, dotTrace, etc.

Configure what happens when you Go To Declaration:

Troubleshooting

You may be able to fix some problems with ReSharper by:

  • Suspending and resuming ReSharper: Tools > Options > ReSharper Ultimate > [Suspend Now]
  • Clearing the solution caches: ReSharper > Options > Environment > General > [Clear caches]
notes/tools/resharper.txt · Last modified: 2019/03/29 by leszek