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.
    Live templates in ReSharper C++
  • Surround templates let you pick a chunk of code and then surround it with a block of code such as an if or try-catch statement. Surround templates are instantly available on any selection via Alt+Enter:
    Surround templates in ReSharper C++
  • 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:

Generate menu in ReSharper C++

Refactorings

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:
    Introduce Variable refactoring in ReSharper C++
  • Extract Method lets you extract a calculation into a separate function:
    Extract Method refactoring in ReSharper C++

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:
    Navigate to Specializations in ReSharper C++

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:

Contect actions in ReSharper C++

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:

File Structure window in ReSharper C++

Another useful window is the Inheritance Hierarchy window which, as the name suggests, helps you quickly visualize the inheritance tree for a particular type:

Inheritance Hierarchy window in ReSharper C++

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.

Code Analysis

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 #include statement:

Code Analysis in ReSharper C++

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:

Generate definition in ReSharper C++

If you are using a function such as printf(), ReSharper can check the arguments for you and offer fixes there, too:

printf() argument check in ReSharper C++

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:

Inline macro definitions with ReSharper C++

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:

static_assert checking in ReSharper C++

Conclusion

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!

This entry was posted in How-To's and tagged , . Bookmark the permalink.

37 Responses to Introducing ReSharper C++

  1. Pingback: [#RESHARPER] R# for C++, ahora no hay excusa para no hacer #IoT | El Bruno

  2. Pingback: Dew Drop – April 10, 2015 (#1991) | Morning Dew

  3. Stephen says:

    I know it doesn’t currently support it, but is on the roadmap – is there a timeframe for C++/CLI support?

  4. Pingback: [#RESHARPER] R# for C++, there let’s go for #IoT | El Bruno

  5. June says:

    Any chance we’ll see Linux or Mac support for this any time soon?

  6. Adnan says:

    When you guys going to launch IDEs for GO and RUST?

  7. Ladislav Mrnka says:

    I didn’t work with C# and .NET for almost 2 years but I use C++ a lot. I really miss the Resharper and all features it offered for C# development. I wonder if other tools in Resharper Ultimate also support native code and C++? Also what is status of support for test runner ant unit test frameworks like Google Test in Resharper C++?

    Is there at least any long term plan to support native memory profilling in dotMemory, native calls profilling in dotTrace and native code coverage in dotCover? Is there any roadmap and list of features we can expect in next versions of Resharper C++?

    • Jura Gorohovsky says:

      We’re currently trying to figure out (and hopefully plan work on) both of the points you’ve raised: unit testing in ReSharper C++ and native profiling. No estimates so far though.

  8. Mike says:

    Just getting back to my school life for C++ got in to this tryign to figure out doubt for my cousin assignment. Thanks !

  9. Pingback: The Morning Brew - Chris Alcock » The Morning Brew #1838

  10. Eugene Pavlov says:

    Had to uninstall ReSharper for C++ as it is toooooo slooooooow

    • Jura Gorohovsky says:

      How large is your code base? Is ReSharper C++ still slow if you turn off all other plug-ins and VCS connectors in Visual Studio?

      If it’s still slow, then provided that your hardware meets the system requirements, we’d appreciate if you capture a performance snapshot as described in this document (the procedure is the same for ReSharper and ReSharper C++).

      We certainly try to consistently improve performance but it goes so much better when we have specific snapshots that illustrate problems in real-world installations.

      Thanks

    • Karl says:

      Agree. For larger code bases (100+ MB), performance for activities such as “updating source files” after a build is painful. The EAP suggested code bases > 40 MB would experience such performance issues, so I guess that hasn’t gone away.

      Would be nice to have a “batch add” function in the “elements to skip” settings panel…one by one addition is a bit silly.

  11. Ezo says:

    Could extract method have functionality to specify placement of extracted function? Now it’s quite inconvenient. There could be a window with content from file strucuture window that let user specify exact place.

    Also, how to configure shourcuts? Are there any preconfigured?

    • Jura Gorohovsky says:

      There are two standard keymaps but the Visual Studio keymap is applied by default in a new installation. Here’s the full keymap. An alternative keymap (recommended if you use other JetBrains products a lot) is available from ReSharper C++ documentation. If necessary, you can remap ReSharper commands to alternative shortcuts using the standard Visual Studio mechanism: Tools > Options > Environment > Keyboard.

      As to Extract Method, we’d appreciate if you file a feature request in ReSharper C++ issue tracker. Thanks

  12. Roman says:

    I’ve tried C++ Resharper, and have to admit that the functionality is great, far better than IntelliSense. However the performance is sometimes not very good. I can understand that when I fetch a new version from Perforce, I get a lot of files in my project updated, and it takes time for ReSharper to update its database. But sometimes even without updating many source file, the entire VisualStudio freezes for a second or two. I suspect that it is .Net garbage collector freezes everything when trying to traverse the ReSharpers’s symbol database. Is ReSharper written in C# or another managed language? I mean is it managed code or native?

    • Jura Gorohovsky says:

      Roman, right, ReSharper C++ is written in C# and shares a lot of the code base with the mainline ReSharper for .NET developers.
      The freezes may indeed be related to garbage collection which in turn can be related to excessive memory usage. If the freezes become frequent and hugely annoying, we’d appreciate if you investigate memory usage as described in this document and possibly provide us with a memory snapshot if other options don’t help.

  13. Fabio Di Peri says:

    Is C++/CX support a planned feature?

    • Ahmad Ragab says:

      +1 Would definitely like to know as well. I am sure it won’t be trivial, especially since some of the syntax is shared between C++/CLI and CX

      • Daria Dovzhikova says:

        Yes, support for CLI and WinRT are on the roadmap, but without any exact estimation on time, unfortunately.

  14. Roman says:

    One more observation.
    I like the fact that with ReSharper I can quickly go to a file/class/method/whatever. But to accomplish this I always have to traverse a couple of menus: RESHARPER->Naviagte->Go To . I’d rather prefer using a convenient hot keys combination, like, for example, Ctrl+N in IntellijIdea to search for a class.

  15. Alexey says:

    Tried with Unreal Engine 4 source (github master branch).
    Loading(‘Updating source files’ phase) takes about hour, until that no highlight, no bug tracking (‘analysis will start shortly’).
    Worst thing – I need to make it from the beginning on each commit I’m pulling.
    Isn’t it store all the data it parsed before? Isn’t it uses IntelliSense database? Any way to speed it up?

    • Loofou says:

      Yes, it really takes a long time. I am currently testing both Resharper C++ and Visual Assist to find if any of them can help our productivity when using with the Unreal 4 source code. So far I am pretty happy with Resharpers functionality, but waiting an hour to get the features, while VAssist takes about 10 minutes, is absolutely not okay. Some kind of caching needs to be done for it to become usable for larger projects.

  16. Will says:

    Does Resharper C++ disable itself entirely for C++/CLI projects?

    We use C++/CLI projects as a wrapper for developing embedded projects – so there are a huge number of ‘vanilla’ C++ files and a very small number of C++/CLI files.

    It appears that Resharper C++ doesn’t work at all for us in these projects, even in the ordinary ‘unmanaged’ code, which presumably it could understand without any trouble.

    Is this behaviour to be expected?

  17. db says:

    Visual Assist has a very useful refactor option to edit a method’s parameters. Will Resharper C++ get this soon?

  18. Pingback: ReSharper C++ | Making Visual Studio perfect

  19. Philippe says:

    I have a very fast and big computer, but Resharper C++, with my 1 million line project, is so slow that it is totally unusable and decrease my productivity. Even free I would not use it. On paper it is nice, but in practise, terrible :(
    I have uninstalled it and will check it again in maybe one year, to see if dramatic improvements have been done.
    The competition has not to worry…

  20. Niki says:

    How can you turn off Resharper C++? I like Resharper for C#, but it isn’t working for C++/CLI at all, and what’s worse, it seems to disable Visual Studio intellisense.

    • Jura Gorohovsky says:

      There are several ways to solve your problem AFAIK:
      1. Uninstall ReSharper C++ completely via ReSharper Ultimate installer (keep the mainline ReSharper intact
      2. Go to ReSharper > Options > Environment > Products and Features and disable “ReSharper C++”.

      I assume you can also tweak Visual Studio settings to bring VS native IntelliSense back (probably via Tools > Options > Text Editor > C/C++ > General > Auto list members) but if ReSharper C++ isn’t helping at all, it’s better to disable or uninstall it as suggested above.

    • Chiel ten Brinke says:

      Weird, since the intellisense works fine for me with C#, C++ and C++ CLI. Using Visual Studio 2015.

  21. Vladmir says:

    I installed Resharper Ultimate 2015.2 and can’t get the C++ naming style to work
    as expected. I want to enforce the _lowerCamelCase style for all class variables
    but when I set the following setting:
    Class and struct fields: _lowerCamelCase
    I do not get the squiggly line under a class variable that doesn’t follow that naming
    convention.

    Any idea why this doesn’t work as I expect it?
    Thanks.

    • Jura Gorohovsky says:

      Vladimir, naming inspections are not yet implemented in the current version of ReSharper C++. AFAIK naming rules that you set currently affect suggestions that you’re getting from code completion, refactorings and code generation actions but so far there’s no highlighting of code that violates your naming preferences (which there are in the mainline ReSharper for C# for example.)

      I’m not sure if there’s an estimate for naming inspections to be implemented but I’d recommend that you vote up and watch this feature request to be updated whenever this occurs.

Leave a Reply

Your email address will not be published. Required fields are marked *