What’s New in ReSharper C++

ReSharper C++ 2020.2 includes lots of performance improvements and bug fixes, in addition to extending and upgrading features throughout the product. The most notable improvements are the updates to C++/CLI support, enhancements for navigation and search, and a new set of code inspections with quick-fixes. Support for the Unreal Engine project model brings you to the next level of Unreal Engine development with smarter auto-import suggestions for include directives, refined completion lists, and responsiveness when switching solution configurations.

Download

Free 30-day trial

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.

Download

Free 30-day trial

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.

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.