ReSharper C++
The Visual Studio Extension for C++ Development
ReSharper C++ 2021.1: Syntax Style, New C++ Features, and Improved Unreal Engine Support
Please welcome our first major release of the year! ReSharper C++ 2021.1 brings support for several new C++17 and C++20 language features, adds new inspections, and improves Unreal Engine support. You can now configure ReSharper C++ to match your code style even more closely with a new set of syntax style settings. The accompanying quick-fixes and context actions help you keep your code style consistent and update your code with ease.
Update to this version, or start a free 30-day trial today! The brand new build is available on our website, and all our tools for Visual Studio can be downloaded via the Toolbox App.
Here is a quick overview of the new features and improvements in 2021.1:
-
C++ support: class types in non-type template parameters, C++20 class template argument deduction rules,
noexcept
as a part of the function type, and code completion for coroutines. -
Unreal Engine: initial support for Unreal Engine 5, a postfix template for
Cast
, and support for theRIGVM_METHOD
reflection macro. - Syntax style: a new set of code style settings for various aspects of the C++ syntax with accompanying inspections, quick-fixes, and context actions.
- Code cleanup: new code cleanup tasks, the Cleanup selection context action, and performance improvements.
- Code analysis: inspections with quick-fixes for redundant casts, template arguments that can be deduced, and variables that can be moved to the inner scope.
- Other changes: exclusion list for aggregate initialization hints, improved support for various platform targets.
C++ support
Before C++20, non-type template parameters were limited to having scalar non-floating-point types. ReSharper C++ 2021.1 adds support for class types in non-type template parameters. With this C++20 feature, you can use your own classes in the types of template parameters when the class satisfies certain requirements.
Another useful addition is the support for C++20 CTAD rules – class template argument deduction is now consistent and works for aggregate templates, type aliases, and inherited constructors.
Since C++17, the noexcept
specification has been considered a part of the function type, and ReSharper C++ now fully supports the new exception specification semantics.
ReSharper C++ added support for coroutines in the 2018.2 update, but code completion didn’t include support for the C++20 coroutine-related syntax. Now co_await
, co_yield
, and co_return
are available both in basic code completion and as postfix completion templates.
Unreal Engine
We’ve introduced initial support for Unreal Engine 5 based on the feedback from the Epic Games team. This means you’ll be able to try out the new features as soon as Unreal Engine 5 is officially released.
Unreal Engine’s Cast for type-safe dynamic casting is now available as a postfix template in code completion.
In 2021.1, we’ve added support for another Unreal Engine-specific reflection macro, RIGVM_METHOD
. ReSharper C++ now handles it correctly.
Syntax style
One of the aspects of the code style is how to use interchangeable language syntax elements.
With the 2021.1 release, we’ve introduced a collection of syntax style settings that you can use to configure ReSharper C++ to match your chosen code style. With the supporting inspections, quick-fixes, and context actions you can easily enforce the chosen syntax style in your code.
Regular or trailing return types, typedefs or type aliases, “East const” or “West const”, virtual
or override
or both? You can customize all these preferences and even more on the Options | Code Editing | C++ | Syntax Style page. There are granular options for each case. For example, we have separate preferences for enforcing the auto
usage for numeric and non-numeric types. Here you can set the syntax style setting to Never if you prefer explicit types, to Always if you follow the Almost Always Auto style, or to When type is evident, which means that the auto
specifier will only be introduced when the deduced type is evident from the initializer expression.
When the severity of a syntax style setting is set to a suggestion, a hint, or even a warning, ReSharper C++ will highlight the style violations and offer you quick-fixes to help eliminate them. The inspection context menu also lets you conveniently change the value of the syntax style property without having to open the options dialog.
Have you ever thought of trying out trailing return types everywhere for consistency’s sake or switching from traditional “West const” to the alternative “East const”, but don’t want to waste your time migrating the codebase to the new syntax? With ReSharper C++, all syntax style quick-fixes can be applied in scope: in the entire project/solution or local scopes like a function body or a class definition.
Enabling all the syntax style inspections can be overwhelming, so we’ve made sure that context actions are always available for tuning your code even if you’ve muted the corresponding inspections.
To fix all the syntax style violations in a specific scope, you can use code cleanup or the dedicated ReSharper | Edit | Apply Syntax Style action. Depending on the current context, this action will fix syntax style issues in the selection, the entire current file, or a set of files selected in the Solution Explorer.
You can check out this blog post for details about all the new syntax style settings. Go ahead and try them out, and let us know which syntax style rules you’d like to see added next!
Code cleanup
Code cleanup adds several new tasks. First, all the new syntax style settings get a corresponding code cleanup task, which you can disable if necessary in a custom code cleanup profile. Secondly, there are tasks to apply the fixes for the new “Redundant cast” and “Template arguments can be deduced” inspections during code cleanup.
The new Cleanup selection context action lets you quickly run code cleanup on the selected code range. You can also choose one of the custom code cleanup profiles to use during the run.
Finally, we’ve improved the performance of code cleanup considerably. In many cases, code cleanup now spends less time analyzing code and performs fewer unnecessary operations, and finishes faster on real-world codebases.
Code analysis
ReSharper C++ will now notify you when a variable is declared before the scope in which it’s used. In this case, you can use the provided quick-fix to move the variable and limit its scope.
Another new inspection detects redundant cast expressions, which can be safely removed from the code without changing its semantics.
ReSharper C++ 2021.1 highlights redundant template arguments that can be deduced by the language according to the C++17 class template argument deduction rules.
We’ve also added some quick-fixes for conversion errors. ReSharper C++ will suggest one of the conversions suitable for the current context (c_str()
, to_string()
, get()
, value()
, data()
, operator *
, operator &
, dynamic_cast<>
or static_cast<>
, etc.) to resolve the error.
Other changes
ReSharper C++ 2020.3 added the Push-to-Hint visibility mode, in which hints are hidden by default to save space in the editor but can be revealed with a keypress. You can now quickly change the visibility mode for different types of hints from the Alt+Enter context menu.
We’ve also added a stop list of class patterns for which aggregate initialization hints will always be hidden. The new stop list can be found along with other related settings on the new Environment | Inlay Hints | C++ | Aggregate Initialization options page. For convenience, you can also quickly add a class name to the stop list from the context menu:
ReSharper C++ 2021.1 also improves support for various platform targets. GCC’s inline assembly syntax is now supported, as well as several new language extensions including __has_feature
and __builtin_const_p
. ReSharper C++ also predefines the correct platform macros on the ARM and ARM64 MSVC platforms and recognizes the Clang-based toolset used in the Microsoft Flight Simulator SDK.
Those are all the highlights of ReSharper C++ 2021.1! The full list of new features and bug fixes is available in our issue tracker, where you’re always welcome to submit a new feature request or upvote an existing one.
More changes are coming from ReSharper itself, so be sure to visit What’s new in ReSharper for all the details, especially since the license covers both ReSharper and ReSharper C++. For example, there is a new navigation action, Navigate to Windows Explorer, and an action for creating links to GitHub sources with the Copy FQN feature.
Give ReSharper C++ 2021.1 a try and please share your feedback with us!
Your ReSharper C++ team
JetBrains
The Drive to Develop