What’s New in ReSharper C++

ReSharper C++ 2022.1 mainly addresses quality and performance issues. This release also introduces support for the Unreal Engine testing framework and the overhauled version of the Catch2 unit test framework.

Download

Free 30-day trial available

Unreal Engine

ReSharper C++ 2022.1 brings a brand new way to quickly consult the Unreal Engine documentation about the details of a class, symbol, or function. You can now click Read more in the Quick Documentation pop-up (Ctrl+Shift+F1) to open the corresponding page in your browser.

The Rename refactoring now handles the Unreal Engine interface classes better. When renaming interfaces, both the U and I classes will be renamed accordingly.

ReSharper C++ can now substitute the parameter names when you generate a member function signature from the Unreal Engine delegate.

You can now also generate such functions when the ThisClass typedef is used.

Here is a short overview of the most important Unreal-related fixes delivered in this version:

  • The Unreal Engine 5 built-in preprocessor macros are now supported in the .Build.cs and .Target.cs files.
  • ReSharper no longer suggests the recent C# features that are not applicable in the .Build.cs and .Target.cs files on Unreal Engine 4.
  • ReSharper C++ now reads the list of valid reflection specifiers directly from the version of Unreal Engine which is currently in use, so it only offers you applicable items in code completion and displays up-to-date documentation.
  • There are no more issues caused by the DOREPLIFETIME_WITH_PARAMS_FAST and MARK_PROPERTY_DIRTY_FROM_NAME push model macros – ReSharper C++ now is aware of entities generated by the replication system, such as ENetFields_Private enum.

Unit Testing

The Unreal Engine testing framework is now supported. ReSharper C++ discovers Unreal Engine unit tests and adds the corresponding action indicators next to each test in the editor to run or debug the test or the whole test suite. In the Unit Test Sessions window, you can review the results of the tests, and rerun failed, all, or specific tests.

The new version of the Catch2 unit test framework brings significant changes – it’s now split into multiple headers and has a statically compiled library as its distribution model. It means you now have to include several headers, but the compilation time is improved. So if you’d like to check out the updated Catch2 unit test framework, ReSharper C++ 2022.1 has full support to help you with it.

ReSharper C++ 2022.1 also includes updates for the latest releases of GoogleTest and doctest, as well as various unit testing fixes.

C++ support

ReSharper C++ is now better at handling implicit constructor calls, allowing you to find usages and navigate to the called constructor in more cases, including the following:

  • standard (make_unique/make_shared) and Unreal-specific (MakeShared/MakeUnique) smart pointer creation functions.
  • emplace-like container methods.
  • static_cast and c-style cast expressions.

ReSharper C++ now also shows you an overloading warning when an emplace-like function is called with incorrect arguments.

ReSharper C++ 2022.1 improves the multiline generation of boilerplate code for aggregate initialization using C++20 designated initializers. You can now invoke completion on the next line if you’d like to see each initializer on a new line.

Formatting

ReSharper C++ now treats the C++20 requires-expressions correctly, allowing you to configure spaces formatting via the Around ‘->’ in trailing return types option.

Use the new Line feed at the end of file option to control adding or removing a blank line from the end of files.

Take a look at What's New in ReSharper to learn about the other changes introduced in this release. For example, you can now autodetect syntax style settings for C# files.

Download

Free 30-day trial available

ReSharper C++ 2021.3

Support for Visual Studio 2022

ReSharper C++ now supports the new Visual Studio 2022 release build, meaning you will have access to the same rich feature set you are used to using in other Visual Studio versions. Since Visual Studio 2022 is an x64 process, there is no longer a limit to the maximum amount of memory that can be allocated to it, and all the ReSharper С++ features work faster.

To work with ReSharper C++ in Visual Studio 2022, make sure that the VS2022 icon in the dotUltimate 2021.3 installer is selected.

C++20

You can use C++20 designated initializers to quickly generate boilerplate code for aggregate initialization (P0329). Just select the corresponding item from the completion list to insert designators for the data members, and then provide the initial values.

With the C++20 contains function, you can easily check whether an element exists in an associative container (P0458). A new inspection suggests replacing instances of find or count with the new contains member function.

The new standard brings convenient library functions for erasing elements that work for all standard containers (P1209). A dedicated inspection will let you know when an erase-remove idiom can be replaced with std::erase or std::erase_if.

Another new library addition is the smart pointer creation functions that perform default initialization (P1973). When you need to allocate an array of built-in types and then immediately initialize it, you can now apply a quick-fix to use make_shared_for_overwrite or make_unique_for_overwrite.

Unreal Engine

With ReSharper C++ 2021.3, you no longer need to switch to Unreal Editor to create a new class – all predefined templates for Unreal Engine classes are now available in the list of ReSharper file templates.

To create a new class, go to Solution Explorer and right-click on the preferred project folder to open the Add menu (or use Ctrl+Alt+Insert). After you choose an Unreal Engine template from the list and give your new class a name, ReSharper C++ will generate the header and source files with the template code in the proper folders depending on whether the folder is private or public.

ReSharper C++ now works correctly with the Unreal Engine Sparse Class Data system.

We’ve fixed an issue that would sometimes cause ReSharper to reindex source code when a solution was loading.

Code analysis

A new inspection marks redundant parentheses in lambdas with no parameters, since a parameter list is not required in such cases.

When an elaborated type specifier is used neither to declare a new class nor to refer to a previously declared but hidden class, ReSharper C++ will suggest removing the specifier.

A new inspection finds for loops that can be written in a more concise way as while loops. The accompanying quick-fix lets you quickly rewrite them.

User specializations of classes like std::hash or std::formatter are often wrapped in a standalone namespace. To make your code more readable, ReSharper C++ suggests using a qualified class name instead.

If you construct an object of an exception type but do not use it, ReSharper C++ now warns you and lets you quickly add the throw keyword.

The bundled Clang-Tidy has been updated to Clang 13, adding new checks from the latest LLVM release.

Coding assistance

The Quick Info tooltip now includes the evaluation results for constant expressions. You can use this feature to see what subexpressions of a failing static_assert expression evaluate to, or to check out the value of a sizeof or alignof operator.

In addition to the Document action (via the Alt+Enter menu or the Ctrl+/ shortcut), you can now generate a stub for a new documentation comment by typing /// before a function or another entity you want to document.

Navigation

The File Structure window now groups symbols with the same qualifier. This is especially useful in source files that contain a lot of out-of-class functions.

ReSharper C++ 2021.3 allows you to search for declarations in inactive code, where navigation was previously not available.

You can also now navigate from a goto statement to the corresponding label.

Change Signature

The Change Signature refactoring now lets you easily control the C++17 [[nodiscard]] attribute, which indicates that the function caller should use the function’s return value.

C support

ReSharper C++’s 2021.3 supports C11 _Generic expressions, which provide a mechanism for limited compile-time choices in C.

We’ve also introduced support for typeof – a GNU extension to the C language for referring to the type of an expression.

Take a look at What's New in ReSharper to learn about the other changes introduced in this release. For example, additional GitHub-related items in the Copy Code Reference pop-up make it easy to share links with people, and you can also add a custom URI template for non-GitHub repositories.

ReSharper C++ 2021.2

Type conversion hints

New inlay hints make hidden type conversions visible in the editor, so that you are aware of their potential performance and correctness implications.

You will see special icons for implicit conversions. Alternatively, you can choose to show the conversions as textual hints.

ReSharper C++ displays hints for different kinds of class type conversions, including object copying, object initialization using converting constructors or aggregate initialization, and calls to conversion operators.

You can also enable hints for standard conversions between built-in types, for example, conversions between numeric types that might lose precision or change the signedness of the type.

Immutability inspections

Immutability-related analyses can help you keep your code more readable and correct. By adding two new inspections, ReSharper C++ now covers all the rules from the Constants and immutability section of the C++ Core Guidelines.

The first new inspection extends the immutability analysis for function parameters of reference and pointer types. ReSharper C++ will notify you if you can pass a pointer or a reference to const, which guarantees that the function will not modify the corresponding function argument.

The second inspection suggests marking variables that can be evaluated at compile-time with constexpr, which can lead to faster performance and better compile-time checking.

Modernizing inspections

ReSharper C++ 2021.2 includes some new inspections to help you modernize your code.

Structured binding can be used instead of tie(..): since C++17, you no longer need to use std::tie() or boost::tie() for unpacking a tuple or a pair – structured binding declarations help you simplify your code.

Type trait can be simplified using a template alias or a variable template: C++14 alias templates let you shorten C++11 type trait expressions.

std::size can be used: this inspection suggests using std::size as a type-safe alternative to the error-prone C idiom for array size calculation.

Zero initialization can be used instead of memset: zero-initialization leads to more concise code and prevents various memset-related errors.

Inline Function refactoring

The new Inline Function refactoring lets you quickly replace a function call with the body of the function. To invoke it, place the caret on a function call and select Inline Function from the Refactor This menu, or choose ReSharper | Refactor | Inline from the main menu. ReSharper C++ will perform the necessary transformations, handle all the name conflicts, and reformat the resulting code.

Coding assistance

By default, ReSharper C++ generates functions with empty bodies, but now you can specify whether the generated functions should throw an std::logic_error, return a default value, or include uncompilable code. To configure this, go to ReSharper | Options | Code Editing | C++ | Code Generation. ReSharper C++ will also automatically call the base function from the body of an overriding function.

A new context action lets you convert any string into a C++11 raw string literal, which is easier to read when the string literal contains special characters. The transformation works both ways, so you can convert a raw string literal into a regular string literal, too.

If you want to quickly consult cppreference.com about the details of a standard library class or function, you can now click Read more in the Quick Documentation pop-up (Ctrl+Shift+F1) to open the corresponding page in your browser.

When you press Backspace on an empty line or a line with whitespaces or tabs to the left of the caret, ReSharper C++ can now place the caret at the proper indent position instead of moving it back one position at a time.

Unreal Engine

ReSharper C++ 2021.2 supports working with Unreal Engine 5 from both the Unreal Launcher and GitHub sources.

In the .Build.cs and .Target.cs files of an Unreal Engine project, ReSharper C++’s code completion now suggests the list of available modules and plugins.

After you’ve added a module or a plugin, the new inspection for missing dependencies will highlight any that must be referenced in the .uproject or .uplugin file. Use the accompanying quick-fix to add new modules and plugins to the project files with a single click.

When generating a definition of an overriding function, ReSharper C++ will now call the overridden function from the generated body using the idiomatic Super type alias.

We've improved the performance and memory usage of a cold startup. Now ReSharper C++ indexes the Unreal Engine codebase 10% faster.

Other changes

The bundled Clang-Tidy has been updated to Clang 12, adding new checks from the latest LLVM release. We’ve also improved its performance in complex files, particularly in C++20 projects.

A new inspection warns you when you compare an unsigned expression with 0, which may cause an infinite loop or unreachable code.

Take a look at What's New in ReSharper to learn about the other changes coming to the ReSharper platform. For example, the InspectCode command line tool now restores NuGet packages and builds a solution before starting its analysis.