What’s New in ReSharper C++

ReSharper C++ 2020.1 both introduces new features and upgrades some that already exist. The most notable improvements are the updates to C++20 support, the improved code completion, and a new set of code inspections with quick-fixes. New coding assistance features like Rearrange Code and Complete Statement help you write and change your code efficiently. For game developers, ReSharper C++ introduces initial support for HLSL and better aligns with the Unreal Engine guidelines.

Download

Free 30-day trial

C++20

The C++20 standard has almost been signed off on, and ReSharper C++ introduces support for one more set of its features.

Using enum

Using enum

ReSharper C++ 2020.1 adds support for using enum declarations, which let you bring specific enumerators from a scoped enumeration into the local scope. A new refactoring, Introduce Using Enum, is available to help you add using enum declarations to existing code.

Concepts

C++20's Concepts

For C++20's Concepts, ReSharper C++ supports the new syntax for constrained type placeholders and abbreviated function templates. Improved error messages about unsatisfied constraints help you understand what went wrong during template substitution.

Using enum

Template syntax for lambdas

ReSharper C++ also suggests a quick-fix for using template syntax for lambdas when doing so helps you avoid errors or unify your use of lambdas and functions.

Unreal Engine

Unreal Engine

ReSharper C++ 2020.1 improves the Rename refactoring in Unreal Engine projects. Now it updates the corresponding *.generated.h include directive and related files with the A, F, E, T, S, and U prefixes.

When ReSharper C++ detects an Unreal Engine project, it tweaks the default settings to stop suggesting Use auto to better align with the Unreal Engine guidelines. Also, ReSharper C++ 2020.1 includes updated naming rules for console variables and log categories. You can now navigate to namespaces that contain an enumeration in the Unreal Engine style from Search Everywhere/Go to.

Finally, ReSharper C++ now also supports USF files with virtual file paths and SpatialOS GDK. Learn more.

HLSL Experimental

HLSL

ReSharper C++ 2020.1 now provides initial support for HLSL, the High-Level Shading Language. ReSharper C++ highlights HLSL code according to your default color scheme and displays inlay hints and tooltips for code elements with type information and documentation. You can also search for and quickly navigate to structs, functions, or parameters in your entire solution, referenced files, and standard libraries. And to perfect the HLSL experience, ReSharper C++ offers you smart code completion, auto-inserting matching delimiters, and more.

Code analysis

Code analysis

Several new inspections are available for the following issues, with corresponding quick-fixes that help you resolve them:

  • Unused lambda capture.
  • Lambda can be rewritten to use explicit template parameters.
  • Functional-style cast used instead of a C++ cast.
  • reinterpret_cast used instead of a static_cast when casting to void*.
Code analysis

Two more features help you adopt the C++17 maybe_unused attribute:

  • A quick-fix to add [[maybe_unused]] to an unused parameter or variable.
  • A context action to replace UNREFERENCED_PARAMETER and Q_UNUSED annotations with [[maybe_unused]].

The bundled Clang-Tidy binary has been updated to Clang 10, adding more than 70 new checks and compiler diagnostics from the latest LLVM release.

Code completion

The completion list now suggests label names, standard C++ attributes, the new std::forward postfix template, and arguments for calls to a base function. Additionally, ReSharper C++ now provides code completion in macro bodies.

Coding assistance

Coding assistance

Two well-known features from ReSharper for .NET have finally come to ReSharper C++:

  • Rearrange Code quickly moves code elements around, expands or shrinks the current scope, and more.
  • Complete Statement inserts the required syntax elements to finish the current statement and puts the caret in the right place.

With improved typing assistance, you can now select any piece of code and type a parenthesis, brace, bracket, or quote to surround the selection with the corresponding characters. The code readability helpers – parameter name hints and type hints – are now available in dependent code.

The new Document edit action, bound to Ctrl+/ by default, lets you quickly generate a documentation comment for the nearby code element instead of using the context action.

Enum refactorings

Enum refactorings

ReSharper C++ 2020.1 introduces two new refactorings to help you upgrade your enum usage:

  • Convert to Scoped Enum converts a C-style enumeration declaration into a C++11 scoped enumeration.
  • Introduce Using Enum adds a C++20 using enum declaration and shortens enumerator references to make your code easier to read.

Navigation

Code navigation features have been extended to be even handier:

  • Go to Declaration is available on identifiers inside comments.
  • Search Everywhere/Go to includes two new filter categories: concepts and namespaces. Type “/” in the search box to see all the available filters.
  • You can now middle-click (click your mouse’s scroll button) to Go to Declaration.

In the File Structure window, the icons now have indicators for class member accessibility, inheritance, and virtual/static/pure specifiers.

Sorting of include directives

Sorting of include directives

ReSharper C++ 2019.3 allowed you to sort #include directives, rearrange existing groups, and create new ones separated by blank lines. ReSharper C++ 2020.1 adds two new settings to make this action even more configurable:

  • Case-sensitive sort.
  • Group headers by directory.

And it's now possible to import the sorting settings from a .clang-format file if Read code style from .clang-format style is checked on the ReSharper | Options | Code Editing | General Formatter Settings page.

Other changes

ReSharper C++ 2020.1 comes with several other noteworthy changes:

  • Generate dialogs provide an option to mark the generated getters and constructors with the C++17 [[nodiscard]] attribute.
  • Generate mock functions support the MOCK_METHOD macro introduced in GTest 1.10.
  • The new setting Use named pipes to communicate with child processes allows you to fix unit tests that are misbehaving because of security software.

Also, more changes are coming from ReSharper itself. For example, unit test sessions can now be exported and imported.

Download

Free 30-day trial

ReSharper C++ 2019.3

C++20 support

C++20 support

C++20 is feature-complete and will be officially signed off next year to provide C++ developers with a range of long-awaited goodies. ReSharper C++ 2019.3 already supports many of these features, augmenting them with additional analysis and insights.

First, ReSharper C++ is now aware that aggregates can be initialized from a parenthesized list of values, and that an extra ADL needs to be performed in some cases with function templates.

Not only are concepts supported in ReSharper C++’s parser, but Rename refactoring and Find Usages are also available. Even better, code analysis can show you more details about errors related to Concepts. For example, if the overload resolution fails because a Concept’s requirement is not satisfied, you’ll see all the details in a tooltip. By the way, in ReSharper 2019.3 we’ve also added color to the tooltip that shows the details on the overloading resolution failures.

We’ve started a series of C++20 and ReSharper C++ blog posts, which you can use to learn about the new language features and their adoption in ReSharper C++.

Code analysis & quick-fixes

Code analysis & quick-fixes

If you find a Clang warning too distracting, you can now disable it from the inspection menu. And for all code checks, you can now suppress the corresponding inspection for all such issues in the file – simply use Disable in file with comment, or even suppress all inspections in the file with Disable all inspections in file with comment.

As you type a lambda body, a new quick-fix will assist you with adding variables to the lambda capture list. No need to do it manually – just place the caret on a variable in the lambda body and press Alt+Enter. ReSharper C++ will suggest a list of options for how to update the capture list.

Clang-Tidy

Clang-Tidy

In this version, we’ve upgraded the built-in Clang-Tidy binary to Clang 9, to give you many new code checks and accompanying fixes. Importantly, the bundled binary no longer prevents modifications to the source files. Clang-Tidy also starts more quickly as it doesn’t wait for all other ReSharper C++ analyses to finish.

Clang-Tidy settings were improved in a couple of areas:

  • You now have 3 options to select from for the Clang-Tidy executable to use in ReSharper C++. In addition to the bundled binary and a custom binary, which you can provide in settings, you can now select the one from %PATH% (ReSharper C++ will search in folders listed in the %PATH% environment variable and let you know if it finds anything).
  • You can now point ReSharper C++ to a specific Clang-Tidy configuration file instead of the YAML/JSON format string used before.

Type hints

ReSharper C++ gives you hints about your code to help improve its readability. New code hints added in v2019.3 help you identify types that might not be obvious when you look at modern C++ code:

  • For auto variables
  • In structured bindings
  • For function and lambda return types
Live templates

Live templates

In ReSharper C++ 2019.3, several live templates were renamed to match the corresponding language keyword. For example, to generate a class, type class (was cls before); for structures, use struct instead of str; and use similar logic for unions, enums and namespaces.

Navigation improvements

Navigation improvements

Go to file member was improved in two ways:

  • The dialog is shown instantly without waiting for the file to be parsed.
  • If the declaration and the definition of the function are both located in the same file, the dialog now lists them only once.

In initializer lists, code hints help you better understand what you are actually initializing. Now, you can also navigate to the aggregate class from the opening brace of a brace-enclosed initializer list.

Code analysis & quick-fixes

Formatter

In ReSharper C++ 2019.3, it’s now possible to export your formatting settings to a .clang-format file. Use ReSharper | Options | Code Editing | General Formatter Style | Write current style to .clang-format.

Two new formatter options were added to control the spacing:

  • before ptr in abstract declaration
  • before ref in abstract declaration

ReSharper C++ 2019.3 can now check the order of the #includes directives in your code. Simply provide the ordering settings, and a corresponding inspection and a quick-fix will help you notice if they’re out of order and reorder them in no time.

Unreal Engine 4 support

Unreal Engine 4 support

When ReSharper C++ detects you are developing an Unreal Engine project, it adjusts its behavior to be more UE4-specific.

The “new” postfix template for UCLASSes expands to a proper factory function call (which will register the created object in the garbage collector). Live templates with the corresponding names are now available to help you quickly generate USTRUCT/UCLASS/UENUM/UENUMCLASS.

Unreal Engine’s Smart Pointers (TSharedPtr, TSharedRef, TWeakPtr, TUniquePtr) are now handled by ReSharper C++ similarly to std::shared_ptr/std::unique_ptr. This means features like Parameter Info, code analysis, and postfix code completion work for Smart Pointers.

Finally, there are some performance improvements for UE4 projects. For example, we fixed a hang after "Refresh Visual Studio Project" in the UE4 editor.

Project Properties

Project Properties

For custom compiler toolchain or custom build tool cases, ReSharper C++ 2019.3 adds ReSharper Project Properties. They are stored in the ReSharper settings and allow you to specify:

  • Include directories
  • Preprocessor definitions
  • The C++ language standard

Performance improvements

Thanks to some improvements in the code highlighting engine, re-highlighting now happens faster. After a function’s body is changed, only the body will be reanalyzed.

Find Usages was sped up by adding a heuristic based on the graph of includes. This helps by cutting out the files without any usages.

Other changes

There are more changes coming from ReSharper. You can learn about them here.

ReSharper C++ 2019.2

Faster startup times

In this release, we have finalized what we have been working on over the last few release cycles, and can now officially announce there is a new preprocessor implementation used inside ReSharper C++. There are two of them now, in fact – a newer one used for indexing, and an older one used for everything else. This new one delivers 15-25% faster indexing on typical solutions, like LLVM and Unreal Engine.

Completion summary tooltip

Code completion

In code completion, ReSharper C++ shows a summary tooltip for each item in the completion list (controlled by the Show summary checkbox in the Environment | IntelliSense | Completion Appearance page of the ReSharper options). The description for the selected completion item is now colored and shows the documentation for the corresponding item.

Code hints

Code hints

The editor has even more code hints to help improve code readability. New hints were introduced after preprocessor directives and for function arguments that are passed by a non-const reference, while hints in aggregate initialization expressions now show the names of the initialized base classes.

More C++20 support

The C++20 standard is almost ready to be signed off on by the C++ committee. And naturally, we are working hard to get fully compliant support in. ReSharper C++ 2019.2 got support for:

  • conditional explicit,
  • new char8_t type,
  • pack expansion in lambda init-capture,
  • default constructible and assignable stateless lambdas,
  • C++20 rules for aggregates,
  • consteval and constinit specifiers,
  • C++20 improvements to structured binding declarations.
Typing assist

Typing assist

Typing assist in multiline comments was improved. First of all, multiline comments that use single-line syntax are automatically extended. Second, extending multiline comments now inserts correct indentation when virtual space is enabled.

Wrapping code blocks with braces is now even easier – just select a block of code or an expression and then type an opening brace. ReSharper C++ will do the rest for you:

Formatter

Formatter

There are a whole bunch of new formatter options inside ReSharper C++ 2019.2:

  • Use continuous line indent in function declaration and invocation parentheses.
  • Prefer wrap before ")" in declaration.
  • Prefer wrap before ")" in invocation.
  • Use continuous line indent in initializer lists.
  • Align initializer list arguments.
  • Prefer wrap after "{" in initializer lists.
  • Prefer wrap before "{" in initializer lists.

Code analysis

New inspections are available to help you catch more code smells:

  • Unmatched preprocessor directive.
  • Explicitly defaulted special member function is implicitly deleted.
  • Redundant final function specifier in a final class.

The Use static_cast fix for the C-style cast used inspection can be run in bulk and as part of Code Cleanup.

Navigation

Navigation

Code navigation actions got an accuracy-targeted update:

  • Go to declaration can navigate to the default constructor called when an object is default-initialized in variable declarations and new expressions.
  • Find usages finds usages of default constructors in default initialization.
  • Go to symbol now hides symbols with qualified names (like, for example, out-of-class function definitions).

Besides, you can search in a file right through the Go to File member dialog. The result list will have names of all matched members, and all the places where the search string appears in the file.

Unreal Engine

In the previous release, we began to work towards better support for UE4-specific Remote Procedure Calls. Now, we've updated the Rename and Change Signature refactorings to work correctly on RPC functions. A few new code analysis checks are also available for UE4-based code, especially targeting the missing or incorrectly set UE4 reflection macros.

Following on from adding code completion for reflection specifiers in v2019.1, we've now added built-in documentation for them. It is shown in the Quick Documentation popup (Ctrl+Q) when the caret is located on a specifier.

Other changes

ReSharper C++ 2019.2 provides initial support for the “Per-Monitor DPI Awareness” mode introduced in Visual Studio 2019. We’ve also updated the ReSharper | Options | Environment | Performance Guide page, adding a Windows Defender section as well as descriptions for all performance tips explaining what exactly will be done after a suggestion is applied.

There's some good news for plugin writers, too: C++ assemblies from ReSharper C++ are now included in the ReSharper SDK!