What’s New in ReSharper C++

ReSharper C++ 2020.3 takes another step toward full C++20 support by implementing the C++20 comparison rules and adding new inspections to help you adopt the C++20 ranges library. Push-to-Hint inlay hints and new navigation features are here to make your day-to-day development more enjoyable. Unreal Engine developers can take advantage of the editor integration with UnrealHeaderTool, an improved project model, and new inspections based on control-flow analysis in HLSL shader files.

Download

Free 30-day trial

Unreal Engine

ReSharper C++ 2020.3 provides seamless integration with UnrealHeaderTool to help you catch more issues with Unreal Engine class metadata right in the editor. When working with an Unreal Engine project, ReSharper C++ automatically runs UnrealHeaderTool on the file you’re editing and displays any errors or warnings, just like with other inspections. Watch the UnrealHeaderTool integration in action.

UE update model

To always keep you up to date, ReSharper C++ now tracks Unreal Engine properties in real time and regenerates the project model as soon as you save any changes in .Build.cs, .Target.cs, .uproject, or .uplugin files.

Unreal Engine model

ReSharper C++ 2020.3 improves its conformance to the Unreal Engine coding standard. For example, ReSharper C++ now suggests using MoveTemp (Unreal Engine's equivalent of std::move) for casting to an rvalue reference.

C++20 Comparisons

ReSharper C++ 2020.3 fully supports C++20 comparison rules. This includes a significant change to how comparisons work, where the language is allowed to rewrite a comparison expression or reverse the order of arguments. You can now consult the tooltip to learn how an expression has been rewritten. When a comparison operator cannot be resolved, the error message will list all the considered overloading candidates.

Defaulted comparison operators are another addition to C++20. If you are not sure why a defaulted comparison operator in your class has been implicitly deleted, you can check the detailed tooltip message to find out the exact reason. ReSharper C++ can now also deduce the return type of a defaulted three-way comparison operator.

IncludeCompareFix

A new quick-fix lets you quickly add an #include <compare> directive to your source file, which is required whenever you use a three-way comparison operator that returns a standard comparison category, such as std::strong_ordering.

CreateOperatorFix

The Create operator from usage quick-fix has been updated to support C++20 comparison rules as well. You can now create both the member and the friend versions of an operator in addition to the non-member version. For secondary operators, which can be rewritten in terms of a primary one, you can choose to create either the primary or the secondary operator.

Code analysis

The full power of ReSharper's control-flow analysis now comes to HLSL shader files, including warnings about unreachable code, uninitialized variables, redundant control flow jumps and conditional branches, and much more.

ReSharper C++ 2020.3 offers two inspections with quick-fixes to help you adopt the new C++20 ranges library and modernize your code:

  • An algorithm operating on ranges can be used.
  • std::views::keys/values can be used.
Algorithms quick-fixes

A new inspection suggests replacing usages of standard algorithms that accept a pair of iterators with equivalent algorithms that accept an iterator and a count where possible.

Clang-Tidy

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

Push-to-Hint inlay hints

Push-to-Hint

ReSharper C++ provides many kinds of inlay hints. While all of the hints are useful in certain scenarios, we’ve also heard feedback that sometimes they can be overwhelming. To help address this, we’ve come up with a new "Push-to-Hint" mechanism for inlay hints. In the Push-to-Hint visibility mode, hints are only shown when you either press and hold Ctrl, or press Ctrl twice.

Hint visibility

We've made sure that the visibility mode can be configured separately for every kind of C++ inlay hint. You can quickly change the visibility mode for a given hint using the context menu, or head to the new option pages under Environment | Inlay Hints | C++ to check out all the settings.

Code completion

Invert ternary

A new context action helps you invert ternary operator expressions.

Join declaration and assignment

The "Join declaration and assignment" quick-fix is now available for cases when a local variable is reassigned in all paths before being read.

With import completion enabled, the completion list will suggest suitable members of incomplete classes from the header files that are not included in the current file.

Import completion now also suggests a new option to add an elaborated type specifier for the corresponding class, in addition to the options to add an include directive or a forward declaration.

Code completion

We've improved argument code completion for library functions that accept macro constants. Library macro constants that are applicable to the current argument are now prioritized in the completion list. This heuristic works for functions from the standard library, WinAPI, and OpenGL.

Navigation and Search

Fuzzy search

In addition to its regular search, Find Text now performs a fuzzy search, which means it takes possible typos and missing words into account. This feature can be very helpful if you are looking for a certain format string used as an argument to a text formatting function like printf or std::format.

Navigation between preprocessor directives

You can now use Go to Declaration to jump between matching preprocessor directives, such as branches of a conditional preprocessing block, or the #define and #undef of the same macro in a single file.

Go to Declaration can also be used to quickly navigate to a base function – just invoke it on an override keyword.

Peek Implementations and Peek Base Symbols come to C++, allowing you to view and edit code in a popup window without switching away from the code you're writing.

File structure

For better readability, File Structure now uses the C++17 syntax for nested namespaces even if you have not yet adopted the new syntax in your codebase.

Go to Derived Symbols

Go to Derived Symbols works for get/set functions inside C++/CLI properties and for add/remove functions inside C++/CLI events.

Other changes

  • C++20 support has been improved according to the standard conformance updates in Visual Studio 16.8. In particular, ReSharper C++ now supports both the standard and the extension modes for C++ coroutines, along with the new <coroutine> header.
  • Thanks to the reduced search scope, we’ve been able to boost the performance of Find Usages and Rename when these actions are used on private class members.

Take a look at What's New in ReSharper to learn about other changes coming to the ReSharper platform. For example, command-line tools now support plugins, and you can invoke CleanupCode on a specific set of files or folders instead of the whole solution.

Download

Free 30-day trial

ReSharper C++ 2020.2

Unreal Engine

Unreal Engine

To increase the accuracy of auto-import and code completion, ReSharper C++ 2020.2 introduces support for the Unreal Engine project model. This means that ReSharper C++ is now able to read project information directly from .uproject files, without using the intermediary project files generated by Visual Studio. The new project model provides more refined lists of suggested items that depend on the plugin and module references. ReSharper C++ will also adjust its behavior when you switch the solution configuration.

ReSharper C++ will now also remind you to refresh your Visual Studio project in Unreal Editor if the project files are out of date.

Unreal Engine

For easier navigation, symbols from engine sources are now treated as library symbols and will be hidden by default from the search results if there is a matching symbol in user code.

Unreal Engine

To match the Unreal Engine coding standard, ReSharper C++ 2020.2 includes several updates to inspection severity, code generation actions, and auto-import of include directives.

Also, a new inspection with a quick-fix is available for adding the virtual specifier to overriding functions.

C++/CLI

ReSharper C++ 2020.2 includes a lot of bug fixes and brings improved interoperation of C++/CLI with C#. When looking for derived symbols in C++/CLI code, ReSharper C++ finds symbols in C# code in addition to symbols in C++/CLI. Navigation to base and derived symbols also works on imported CLR entities.

New code inspections with quick-fixes are available for the gcnew, sealed, and safe_cast usages.

Navigation and Search

Navigation

The following features have had their their scope and applicability extended:

  • Go to declaration works on unresolved identifiers to help you understand what went wrong.
  • Find usages finds constructor usages from braced init lists in more cases, including return statements. Find usages has also received a performance boost thanks to several fixes.
  • Go to Base Symbols and Go to Derived Symbols now work on imported CLR entities.
Navigation and Search

ReSharper C++ can now automatically highlight usages of the element under the caret as you move through your code.

In the File Structure window, preprocessor directives are now hidden by default so you can navigate through large files more easily.

Code analysis

Code analysis

New inspections are available with corresponding quick-fixes that help you with the following cases:

  • Structured bindings can be used to modernize the code.
  • Overriding function does not have a virtual specifier.
  • Cannot use gcnew on a native type and cannot use new on a managed type.
  • The final specifier cannot be used for managed classes.
Code analysis

ReSharper C++ now also highlights spelling mistakes for preprocessor directives.

With a brief preview of Clang-Tidy quick-fixes, it's now easier to select the required fix option.

Code analysis

The evaluation engine has been updated with support for the modification of values inside constexpr functions and can work with the values of class types.

Code completion

Code completion

A new completion item can insert an auto-generated lambda argument when a std::function parameter is expected.

Code completion

If a class is not included in the current file, import completion will suggest a new option to add a forward declaration instead of including the corresponding header file.

Code style and formatting

Code style and formatting

ReSharper C++ 2020.2 adds three new settings for more flexible configuration:

  • Indent aligned ?: operator – a formatting option for multiline ternary expression.
  • Insert // on Enter in multi-line // comments – an editor option to prevent the auto-extension of multi-line comments in single-line style.
  • Consider only quoted includes as potential main headers – an option for sorting include directives to improve main header detection.
Code completion

The #include ordering settings have been moved to a separate options page and are now easier to find – just click Order of #includes under the Code Editing | C++ option group.

Last but not least, the formatting engine now works significantly faster in source files with many macro calls.

There are more updates from ReSharper itself. For example, code cleanup can now be launched automatically on save or applied only to the changed parts of recently modified files. You can learn more about these improvements here.

ReSharper C++ 2020.1

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.