How-To's

Export EditorConfig Code Style, Optimize References for SDK Projects, and More ReSharper 2019.1 EAP Updates

The latest ReSharper 2019.1 Early Access Preview (EAP) and Rider 2019.1 EAP builds come with a number of improvements to formatting and code cleanup. ReSharper can export code style settings to EditorConfig. In the editor, pressing backspace returns to the proper indent position in the editor. Analyze/optimize references now works for SDK projects and helps us remove unused package references. And there are a few more things, such as a new built-in code cleanup profile for applying code style settings. Let’s have a look, shall we?

DOWNLOAD ReSharper 2019.1 EAP

Export EditorConfig from ReSharper code style settings

Many teams are using EditorConfig to customize code style settings across IDEs and editors. From the ReSharper settings, under Code Editing | General Formatter Style, we can now export ReSharper’s code style settings to EditorConfig. We can export cross-editor options, as well as properties that are only supported by ReSharper/Rider.

Export .editorconfig from ReSharper code styles

Combined with the Format Selection | Configure… context action (Alt+Enter), we can visually update formatting rules and then export them as EditorConfig.

Edit formatting visually in editor

Typing assist for unindent on backspace

To help with indenting/unindenting code, we’ve added a new typing assist when pressing Backspace. Instead of moving the caret back one position at a time, pressing Backspace returns the caret to the proper indent position.

Backspace indents to proper position

We can change the behavior of this typing assist in ReSharper’s settings (under Environment | Editor | Editor Behavior):

Configure backspace indent typing assist

The following options are available:

  • To proper indent position (default) – When the caret is to the right of the proper indent, Backspace deletes the space to the proper indent. Otherwise, Backspace deletes the whole indent and moves to the previous line. This means that maximum 2 Backspaces are required to move to the previous line.
  • To nearest indent position – Backspace moves to the previous indent position.
  • Disabled – Speaks for itself, doesn’t it? ;-)

Analyze/optimize references for SDK projects

Code bases evolve. Over time, we add new references and install NuGet packages into our projects. Removing those that are not in use is often more difficult. ReSharper 2019.1 comes with improvements to analyzing and optimizing references in our projects!

Next to analyzing project and assembly references, ReSharper now also checks for unused package references in SDK projects! Using the Optimize References… context menu for a project (Ctrl+Alt+Y), we can analyze and optimize references. When our project does not contain any code that uses a given reference, it will show as unused. We can easily uninstall unused packages and keep our project’s dependency tree clean!

Analyze and optimize package references

The Mark reference as used at runtime context menu can be used to inform ReSharper of references that are used implicitly (only at runtime). Even if there are no direct code dependencies on them, ReSharper will mark these references as being in use.

Other updates to formatting & code cleanup

In ReSharper 2018.3, we made customizing code style easier and faster, by detecting formatting and naming settings from existing code. In 2019.1, this detection now runs in the background, allowing you to continue coding while detection is running.

We have added a new option Place ‘System.*’ and ‘Windows.*’ namespaces first when sorting ‘using’ directives (find it in the ReSharper settings, under Code Editing | C# | Code Style | Reference Qualification and ‘using’ Directives). By default, ReSharper and Rider will place these namespaces first when ordering namespaces. When this option is disabled, namespaces will be ordered alphabetically. Namespace ordering is now also compatible with Visual Studio and StyleCop.

Another new formatting option helps inserting blank lines before or after a case <x>: statement (under Code Editing | C# | Formatting Style | Blank Lines).

Want to update your code to match code styles? A new built-in code cleanup (Ctrl+E, C) profile is now available for that: Reformat & Apply code styles.

Reformat and apply code styles with code cleanup

Give ReSharper 2019.1 EAP a go, or try these features in Rider 2019.1 EAP! We’d love to hear your feedback.

image description