ReSharper C++ 2018.3: every bit better!

Please welcome the third release of ReSharper C++ this year! v2018.1 brought debug step filters and includes analyzer, while v2018.2 came with the initial C++/CLI support and better understanding of C++17 and C++20 standards. The just released v2018.3 tunes literally every smart feature the product has, making them work more precisely on modern C++ code.

blog@2x

Let’s dive into the details:

Get the fresh build on our site and evaluate new features and enhancements completely free for 30 days:

Download ReSharper C++ 2018.3

Performance improvements meaning a more responsive editor

In this release cycle, we dedicated a lot of time to making ReSharper C++ perform faster:

  1. Memory usage and memory traffic have been optimized, especially affecting indexing and code analysis which are now much quicker.
  2. On project reopening, cache loading is now done in parallel and thus twice as fast, on average.
  3. The Find code issues command and InspectCode command line tool are now parallelized.
  4. We’ve also sped up code completion.

All these changes helped make the editor much more responsive. Try it now and share your impressions with us!

Code formatting

There are dozens of formatter settings in ReSharper C++, available under ReSharper | Options | Code Editing | C++ | Formatting Style. However, wouldn’t it be easier to simply detect the settings from your existing code? Now ReSharper C++ can do that for you! There are several options depending on the scope in which you’d like to detect the settings:

  1. For code opened in the editor, use the menu ReSharper | Edit | Detect formatting settings.
  2. For any specific scope like file, project, or solution, use Detect formatting settings in the context menu in the Solution explorer.
  3. For a selected block of code, select Format Selection | Detect formatting settings… from the Alt+Enter menu.

formatter_settings

After you review the result, you can save to use globally or in the current file only (if you click Save as comments).

Unlike ReSharper for C#, ReSharper C++ can’t auto-detect C++ naming schemes, but v2018.3 has added predefined C++ naming styles. You can find them under ReSharper Options | Code Editing | C++ | Naming Style, in the Reset to Scheme dropdown. The options are: STL, Google, LLVM, CamelCase, or Microsoft:
cpp_naming

Get a grasp on the code with ease

ReSharper C++ understands your C++ code and gives you hints and useful tips across different areas. In v2018.3, we’ve improved quite a few of them.

Better parameter info view

The Parameter view (Ctrl+P) popup window provides useful information about function parameters. Now it also shows information for user-defined binary operators, deleted functions, and implicitly generated functions:
parameter_info

It’s really helpful on dependent code, where it takes template parameter descriptions taken from documentation comments for template arguments:
parameter_info_templates

It also uses default template arguments to provide information about parameters in dependent code:
parameter_info_dependent

Besides that, default template arguments are also used to provide code completion in the dependent code:
dependent_code_completion

Name hints

C++ name hints are placed in the editor for function parameters, aggregate initialization, namespace names and macro calls, and they are really helpful to find your way through long (and sometimes nested) lists of parameters, namespaces, etc.
parameter_hints

By the way, talking about the name hints at the end of namespace definitions, a neat Clang-Tidy quick-fix can generate a closing comment for you:
namespace hints

Better error diagnostics in templated code

When overload resolution fails in C++, you often get error messages that don’t tell you the exact cause of the problem. The ‘Substitution failed’ error is of little help unless additional details are provided, such as failed enable_if conditions, ill-formed expressions inside decltype, or absent inner types. ReSharper C++ 2018.3 now provides a more specific description of the cause, identifying the exact requirements that aren’t satisfied. Learn more in this detailed blog post.
substitution_failed

Change your code reliably

Smarter refactorings

Refactorings are now even more reliable than before. For example, when you refactor members of an anonymous namespace, they are considered unique to their containing file, so the same names in different files do not clash.

When calling up the Change Signature refactoring, you can now choose to make a function constexpr, const, or noexcept, as well as change the ref-qualifiers:
change_signature

Context actions, inspections, and quick-fixes

To help you quickly make minor changes to your code and improve it, ReSharper C++ provides a set of automatic code transformations called context actions. In v2018.3, the set was expanded with a few very useful actions:

  • Generate a function implementation and copy it to the clipboard instead of inserting it into the document.
  • Generate a function that converts an enum to a string.
  • Convert a regular return type in a function declaration into a trailing return type, and vice versa.
  • Insert template arguments deduced using class template argument deduction.

Let’s take a closer look on one particular context action from the list above – generating a function to convert an enum to a string. Printing enum options and making sure you cover all the options might be a non-trivial task. Often, developers come with some macro-based approach to get a generic solution. But what if you can simply generate the required function? In ReSharper C++ 2018.3 you can do that!
convert to string

The enum_to_string live template used in this code generation is fully customizable: go to ReSharper | Tools | Templates Explorer and find this template in the C++ scope. For example, you can change the live template to generate a stream output operator for an enum:
convert to string

ReSharper C++ 2018.3 has added many new inspections and quick-fixes. For example, there are new quick-fixes to add a functional-style cast, initialize all uninitialized members/bases, and mark class definition as final.

Upgrading the Clang-tidy integration to use Clang 7 has additionally introduced 50+ new C++ checks.

We’ve tuned Go to declaration to provide better results in many situations. On a lambda call, it now navigates to the lambda body; it works on non-dependent decltype specifiers, and even works during the initial project indexing. Go to symbol is also available during indexing.

However, the most interesting case is likely using Go to declaration to navigate to unmatched signatures. For example, assume the declaration of a member function was updated. You still can go to its definition with an old signature by using Go to declaration:
go to unmatched signature

In IntelliJ-based IDEs, you can use Ctrl+Click on a declaration to search for usages. Many users find this behavior quite handy, so we’ve added an option in ReSharper and ReSharper C++ to help you configure the behavior you prefer:
ctrl_click_config

Support for Catch2 2.5

Catch2, a unit testing framework for C++, added support for type parameterized test cases in its recent 2.5 version. The idea is that it behaves the same way as a TEST_CASE macro, but tests are run for every type or type combination. The corresponding TEMPLATE_TEST_CASE macros are now supported by ReSharper C++:
catch25

Enhanced C++/CLI support

Support for C++/CLI, which originally appeared in ReSharper C++ 2018.2, has been greatly improved in this release. A whole new set of code generation abilities is available for C++/CLI code, including these:

  • Generate equality operators, generate hash function, and generate constructor, getters and setters
  • On C++/CLI classes, you can also call the context action create derived class/struct/interface context
  • The postfix templates new and foreach are available in C++/CLI code
  • You can also create a field and member function from the actual usage for C++/CLI classes

Other improvements for C++/CLI code include code completion after objects of generic types, additional filters in Search Everywhere dialog for events and properties, correct handling of inheritance in C++/CLI, and more.

Please note that C++/CLI functionality requires ReSharper Ultimate.

Enhanced Unreal Engine support

If you work on Unreal Engine projects, you can now start typing or navigating through your project seconds after you open it! To make this possible, we postponed engine indexing, which now starts in the background after the non-engine code is parsed.

Another notable change is improved support for Unreal Engine reflection macros such as UCLASS, USTRUCT, UENUM, and so on. They are used to emulate reflection, which is missing from the C++ language. You no longer have to build your Unreal Engine project to resolve these macros correctly!

Visual Studio 2019 Preview 1 support

Starting with v2018.3, you can use ReSharper (and ReSharper C++) with the Visual Studio 2019 Preview 1 build. Full support will be available in future ReSharper updates after Visual Studio 2019 is released officially.

That’s it! Give ReSharper C++ 2018.3 a try and share your feedback with us in the comments below, in our tracker, or on the support forum. We’re waiting to hear from you!

Download ReSharper C++ 2018.3

This entry was posted in ReSharper C++ Tips & Tricks and tagged , , , , . Bookmark the permalink.

2 Responses to ReSharper C++ 2018.3: every bit better!

  1. Lukasz Matuszewski says:

    I cannot use Refactor menu because it is grayed. My test env is CMake project type in VS 2017 Pro.

    • Anastasia Kazakova says:

      Can you please share a sample, maybe a screenshot where do you call a Refactor menu in particular, where is the cursor, etc.?

Leave a Reply

Your email address will not be published. Required fields are marked *