What’s new in the latest ReSharper 2017.2 EAP builds?

ReSharper 2017.2 EAPIt’s been four weeks and 7 EAP builds since we blogged about the ReSharper Ultimate 2017.2 EAP (Early Access Program) — time to have a thorough look at what’s new since!

Improved C# 7.1 support in ReSharper

With C# 7.1 around the corner, several new language features will come available. In our first ReSharper 2017.2 EAP, we already added support for the default literal. This newest EAP comes with support for a change in pattern matching with generic types, full support for async main, and supports tuple projection initializers.

Traditionally, when we would want to project a collection and then run LINQ over it, we’d have to resort to using either a helper class or an anonymous type for doing that projection. Not only that: if we just wanted the values for name and age, we’d have to allocate those explicitly as well:

It looks verbose, and in fact there are several things happening under the covers that make this less than optimal. The compiler will generate an anonymous type which we are allocating on the managed heap (for every element in our list). We then have to allocate our name and age as well.

Granted, we could make this a bit more efficient by rewriting the example a little bit, or use C# 7.1’s tuple projection initializers. No anonymous type, less allocatons on the managed heap, and pleasant to read:

Just like with the anononymous type, C# 7.1 infers the value tuple’s element names from the projection here. We’ve also added an inspection for checking redundant value tuple component names:

Inspection for checking redundant value tuple component names

Note if you want to use this, the ValueTuple type is required. It’s built into .NET 4.7, .NET Core 2.0, Mono 5.0 and .NET Standard 2.0. If you’re on another target framework, the System.ValueTuple package will have to be installed.

When using ReSharper’s Go to Everything (Ctrl+T) or one of the other navigation features, we can find types, type members, files, text, … It’s a powerful search engine, much like the ones we use to find things on the Internet! ReSharper’s search supports partial search terms, CamelHumps, misspellings, … In this EAP build, we made finding things in our projects even more powerful!

ReSharper now returns results when word order is incorrect. What was that method called again? Was it ValidUser() or UserValid()? No worries, Go to … will find it:

Navigation - Word order no longer matters to find results

Sometimes we do know the correct name of what we are looking for. However when that name is something more generic like Service, ReSharper may return a lot of search results…

Navigation for general word returns lots of results

Just like with Internet search engines, ReSharper now supports adding quotes to enforce an exact match:

Navigation supports exact matching using quotes

It’s also possible to use wildcard * or ? inside quotes for a more exact wildcard match. For example "*Service" will show UserService, IssueService, WorkItemService – as long as it ends in Service.

ReSharper – Inspections and quick-fixes

We’ve always had a code inspection that encourages using implicit types using the var keyword (or, depending on your code style, the other way around, using explicit types). This EAP now also applies this inspection and its corresponding quick-fix to out variables:

Use var for out variable

A couple of other inspections were added as well:

  • New code inspection that detects possibly unintended transformations from IQueryable to IEnumerable.
  • More context actions and quick-fixes supporting <inheritdoc/>. We now show a warning when <inheritdoc/> is used in an invalid context. There is also a suggestion for adding <inheritdoc/> when implementing or overriding members, as not adding it would hide documentation from the base symbol.

There are many ways of checking for null values and there are many preferences with our users for what style of null checks should be used when generating code. We have added a new options page, Null checking, where the priority of null checking patterns used by quick-fixes, context actions and code generation actions can be configured:

Null checking priorities

ReSharper – Web

A lot of work in the latest ReSharper Ultimate 2017.2 EAP build was done on the TypeScript side:

  • We improved support for mapped type members in Find Usages and in the Rename refactoring (Ctrl+R, R). For example, the name property from our IDog interface will be found in mapped and derived types now:
    Find usages in mapped type
  • For TypeScript 2.3, we added the contextual this for object literals and the --strict option.
  • TypeScript 2.4 enums with string values (or mixed string/number values) are now supported by ReSharper. And when referenced via a mapped type property, string values are correctly found/renamed.
  • TypeScript 2.4 support for generic inference from contextual type returns and generic contextual signatures.

We made several JSON improvements as well, for example when working in package.json. ReSharper knows about the file type and when we invoke Quick Documentation (Ctrl+Shift+F1) on a package name, we can see additional package details as well as links to the home page, tarball and issue tracker:

Quick Documentation in package.json

While we’re in package.json: completion for scoped NPM packages like “@angular/core” now also works:

package.json scoped packages completion

ReSharper – More!

When generating a constructor using the Generate action (Alt+Insert), parameters for that constructor can be made optional:

Make parameters optional

ReSharper Build reduces the time it takes to build our solution by applying heuristics to only build projects that need updating. This latest ReSharper Ultimate 2017.2 EAP build adds .NET Core support to ReSharper Build.

dotPeek

Several other improvements and fixes went into dotPeek. We now have proper decompilation of assemblies that used nameof() in their original source code. We made various improvements and fixes for displaying and navigating in IL code.

SourceLink is a new way of embedding infomation about an assembly’s original source code into the PortablePDB format. Both our standalone decompiler as well as ReSharper now support SourceLink: when an assembly is compiled with the Roslyn compiler flag /sourcelink:<file> (and a source_link.json is generated using, for example, Cameron Taggart’s SourceLink tools), dotPeek will now download sources referenced in the PortablePDB or use the embedded source files when available.

Speaking of PortablePDB – we added some more features to the Metadata tree:

  • Navigation to embedded sources
  • Navigation to source_link.json
  • Display of embedded CustomDebugInformation blobs of the following kinds: AsyncMethodSteppingInformation, TupleElementNames, DynamicLocalVariables, EditAndContinueLocalSlotMap, EditAndContinueLambdaAndClosureMap

PortablePDB metadata with source_link.json

The Go to String (Ctrl+Alt+T) navigation is now integrated into Go to Everything (Ctrl+T). Additionally:

  • It searches for strings in attributes, making it easier to find occurences of a given string in a (decompiled) code base.
  • Improved presentation of long and multiline strings.
  • When searching for a substring in such string, dotPeek now navigates to the substring position instead of jumping to the start of that long or multiline string.

dotTrace and dotMemory

We have been working hard improving the profiler engine powering both dotTrace and dotMemory. First of all, we added support for profiling .NET Standard 2.0 applications, on our own machine or remote.

The profiler core engine now supports setting a directory where temporary files, diagnostics and snapshots are stored. This is especially handy when profiling remote applications: if the profiler has no write access on the system drive, dotTrace and dotMemory can still profile the application.

Several bugfixes went in as well. We fixed a crash of the CLR running the application being profiled when a forced garbage collection happens during garbage collector initialization. A deadlock when the profiler shuts down during forced garbage collection was fixed, too.

ReSharper C++ improvements

A number of changes and new features went into ReSharper C++, including performance improvements – for example on switching build configurations.

Let’s have a look at what else is new.

Code analysis and quick-fixes

An analyzer was added to check when a local variable can be defined as a constant. ReSharper C++ will inform us about that and display a suggestion in the editor.

From the ReSharper settings under Code Editing | C++ | Naming Style, we could already edit the naming styles for generating new entities. We now added an inspection that hints when existing code does not conform to these naming styles. The inspection can be enabled or disabled as well:

Naming Styles in ReSharper C++

An inspection for unused return values shows us when we forgot to return the value. Using a quick-fix, ReSharper C++ can solve things for us:

cpp-unused-return-value

Other inspections and quick-fixes that were added:

  • A quick-fix to add std::move when cannot bind rvalue reference to lvalue.
  • An inspection that shows unused entities with internal linkage.
  • Quick-fix to add an #ifndef/#define/#endif include guard for the Missing include guard inspection.

Editor formatting

Here’s an overview of enhancement to the editor formatter:

  • Support for line wrapping.
  • The formatter supports Clang-format style configuration files (in addition to EditorConfig).
  • Several code formatting settings were added:
    • Option to insert line breaks after template headers and function return types.
    • Options for indentation of parentheses in function declarations, method calls, if/while/for statements.

Language support

The ReSharper C++ team continuously works on adding additional support for the C and C++ languages. For example:

  • Find usages (Shift+F12) and the Rename refactoring (Ctrl+R, R) are now supported for user-defined literals.
  • Anonymous nested structures are now supported in C code .
  • Virtual methods that can be overridden are shown in completion inside class bodies.
  • The type traits std::is_trivially_constructiblestd::is_trivially_copy_assignable
    and std::is_trivially_move_assignable are now supported.
  • More C++17 support!
    • using for attribute namespaces.
    • Code inspections honor [[nodiscard]] and [[maybe_unused]] attributes.

That about wraps it up. We’re looking forward to any feedback you may have on the latest builds of ReSharper, ReSharper C++, dotCover, dotTrace, dotMemory, dotPeek, as well as various command-line packages included in this EAP.

Download the latest ReSharper Ultimate 2017.2 EAP and give it a try!

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

15 Responses to What’s new in the latest ReSharper 2017.2 EAP builds?

  1. Chris says:

    Just an additional suggestion with “Go to Everything”.

    Are you able to include brackets to cause the list to filter by a method?

    When searching for: “PersonAdd” it might find 10 results for example

    If I Search for: “PersonAdd(” it says nothing found.

    It would be much more beneficial if it matched any methods named PersonAdd(…)

    Also: “Person(” should match PersonAdd(..), PersonDelete(..), PersonFind(…)

  2. Al says:

    Can this be installed on VS2017 preview?

    • Maarten Balliauw says:

      Absolutely, that should work.

      • Fabio Salvalai says:

        It works, yes, unfortunately, the .net core 2 support still isn’t great.

        From a .Net Core 2.0 project, types that are described in a .net standard 2.0 assembly still cannot be resolved by ReSharper.

        Any plans to support it before the next RTM of Visual Studio hits the shelves ?

        • Maarten Balliauw says:

          That is unfortunate. Would you be able to share a project with us where you are seeing this? That can help us debug the issue. Feel free to email me at maarten.balliauw at jetbrains dot com.

  3. Adam Pluciński says:

    Hi,

    when do you plan supporting running tests written in Typescript?
    For full stack developer it is very impotant feature to have one consistent test runner – it was really cool to have this feature for javascript – right now after switching to Angular 4 and Typescript I feel how important this feature was and how it is missing.

  4. Pingback: Der Weg zu ReSharper Ultimate 2017.2 – entwickler.de

  5. Dev says:

    Will refactoring feature parity between ReSharper and Rider be maintained?

  6. Pingback: Dew Drop - July 21, 2017 (#2525) - Morning Dew

  7. rosdi says:

    Will R# be able to detect certain common innocent bugs but very hard to troubleshoot?

    Case in point, we had this code in our codebase:

    //Incorrect code:
    if(DateTime.Now.Subtract(transaction.CreatedDate).Minutes > TEN_MINUTES) {

    }

    //The correct code should have been:
    if(DateTime.Now.Subtract(transaction.CreatedDate).TotalMinutes > TEN_MINUTES) {

    }

    The incorrect code caused occasional ‘random’ issues with our ticketing system… we only detect it more than 2 years later after we analysed our code base with PVS Studio (https://www.viva64.com/en/pvs-studio/)

  8. Ramon Ordiales says:

    I found ReSharper TOO SLOW… :-(

    May be an accessible button to switch on/off Reshaper?

    Now I’m using Visual Studio 2017 PRO. And no CODE MAP :-(
    Why Architecture Tools doesn’t draw complete classes with methods, properties and fields included?
    I think there are a lot of improvements/possibilities in this area.

    • Scott Chamberlain says:

      There is a on off button to do that, If you go to the Tools->Options menu then scroll drown to the “Resharper” option in the list there is a button to “Suspend Now” which turns off Resharper completely.

      You can even bind this functionality to a keybinding, search your keybindings for “ReSharper_ToggleSuspended”.

Leave a Reply

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