Introducing ReSharper C++
Throughout its 11-year history, ReSharper has focused primarily on the .NET state of affairs. This commenced with support for C#, then VB.NET, and has slowly encompassed both the desktop (WinForms, WPF) as well as web (ASP.NET, HTML/CSS/JS/TS) languages and technologies.
Now, we are happy to announce the release of ReSharper C++ — a new product specifically targeted at modern C++ developers. Without wasting any more time, let’s talk about some of the features coming your way in this initial release.
Live Templates and Code Generation
ReSharper’s powerful Live Template ecosystem has been adapted to C++. This means that C++ benefits with support from the following:
- Live templates act like Visual Studio’s snippets but are much more context-sensitive, offering hints as well as programmability options.
- Surround templates let you pick a chunk of code and then surround it with a block of code such as an
try-catchstatement. Surround templates are instantly available on any selection via Alt+Enter:
- File templates let you generate either individual files or, indeed, several files at the same time. For example, the Class template can generate both the header and CPP files in one click.
In addition to generating code via live templates, ReSharper C++ supports quite an extensive Generate menu. Here’s a visual of some of the things you can generate:
An ability to change the structure of code while preserving correctness is ReSharper’s calling card, so here are some of the refactorings that are available out of the box:
- Rename — this refactoring lets you seamlessly rename a symbol (e.g., a macros, a class or a field name) throughout the entire project. ReSharper automatically updates all usings of the symbol.
- Introduce Variable — this refactoring lets you select a part of a calculation and introduce a new variable for it:
- Extract Method lets you extract a calculation into a separate function:
Search & Navigation
ReSharper C++ lets you quickly navigate large code bases by providing the following navigation mechanisms:
- Go to Everything lets you quickly find a particular entity (class, class member, file or folder name) in the entire solution. You can also filter the result set with Go to Type, Go to File or Folder and Go to Symbol.
- Go to File Member lets you quickly find a member within the file you are currently working with.
- You can Go to Base/Derived classes or class members and also quickly Go to Definition.
- Go to Related Files lets you navigate to files related to your current position. This may involve, for example, a file with a declaration related to a definition you are working with, or an included file. Additionally, ReSharper supports an option to switch between header and source files.
- Navigate to Specializations lets you find all the instances where a template is specialized:
The Find Usages quickly finds all the locations where a particular symbol is used. It gives you a preview of what’s been found, with plenty of filtering and navigation options:
ReSharper provides plenty of contextual navigation, too. Pressing Alt+Enter on a symbol offers various navigation options:
In addition to the direct navigation facilities, ReSharper also provides a couple of tool windows for helping you navigate complex code bases. These include the File Structure window, which visualizes and helps you quickly navigate the structure of the currently opened file:
Another useful window is the Inheritance Hierarchy window which, as the name suggests, helps you quickly visualize the inheritance tree for a particular type:
Finally, ReSharper provides general-purpose navigation options such as Go to Next/Previous Member, Go to Next/Previous Issue, and others. You can also jump to the containing declaration.
As soon as you open up a C++ solution in Visual Studio, ReSharper starts analyzing your code and offering hints and suggestions. These may include things like having to add a namespace prefix and an
If you have a declaration without a definition, ReSharper will let you know, and will help you generate a definition – whether inline or in an implementation file:
If you are using a function such as
printf(), ReSharper can check the arguments for you and offer fixes there, too:
Macros and Templates
ReSharper processes macros and templates in their entirety, ensuring that the results of analyses always reflect the correctly postprocessed code. This lets it do some other things: for example, you can inline macro definitions:
The same ideas of fidelity go towards macro evaluation: you can write a
static_assert and ReSharper will instantly check this assert and complain if it doesn’t work:
We have a video with a live demonstration of all of these features in action. Check it out:
With all that said, we invite you to check out ReSharper C++! It is bundled as an optional component of the ReSharper Ultimate installation — you can get a 30-day trial version here. Enjoy!
Subscribe to Blog updates
Thanks, we've got you!
Eager, Lazy and Explicit Loading with Entity Framework Core
Entity Framework Core (EF Core) supports a number of ways to load related data. There’s eager loading, lazy loading, and explicit loading. Each of these approaches have their own advantages and drawbacks. In this post, let’s have a quick look at each of these ways to load data for navigational prope…
OSS Power-Ups: bUnit – Webinar Recording
The recording of our webinar, OSS Power-Ups: bUnit, with Egil Hansen and Steven Giesel, is available. This was the twelfth episode of our OSS Power-Ups series, where we put a spotlight on open-source .NET projects. Subscribe to our community newsletter to receive notifications about future webi…
Accelerating Your Testing Workflow with Unit Test Creation and Navigation
Unit tests play an important role in our daily development workflow. They help us ensure our codebase's correctness when writing new functionality or performing refactorings to improve readability and maintainability. In the process, we often create new test files that accompany the p…
Introducing Predictive Debugging: A Game-Changing Look into the Future
With the introduction of debugging tools, software developers were empowered to interactively investigate the control flow of software programs to find bugs in live environments. At JetBrains, we've always strived to improve the art of debugging. Besides the more standard things you expect from a de…