What’s new in ReSharper 2020.3

ReSharper 2020.3 offers compatibility with C# 9 features, a new angle on inlay hints, Avalonia support, integrated Dynamic Program Analysis, and a set of small updates to help you with your day-to-day development.

Download

Free 30-day trial available

C# Support

Source Generators are almost certainly the most talked about feature in the C# compiler. It’s understandable: the ability to create new code right in the compilation process and use it immediately is exciting and could be useful in lots of different situations.

What can ReSharper do here? Well, it can do what it does best and take the generated files into account while performing refactorings, provide code editor features, and help you navigate to the generated code.

Partial methods are now allowed to have out parameters, non-void return types, and any type of accessibility, making them more useful with Source Generators. Source Generators can use the defining declaration of the partial method to customize the behavior of the generated code.

Another cool addition is init-only properties. Such properties can only be set during the initialization of an object. So finally you can use object initializers without exposing the property as mutable!

ReSharper is aware of init-only properties and takes them into account when completing your code, performing generative completion, analyzing whether the property changed anywhere, and offering a quick-fix to make it mutable if you change your mind.

The perfect place to apply init is new record types. These are reference types with value semantics that help you achieve immutability, but this time for the whole object. Again, ReSharper is keeping up with the language, from quick-fixes for choosing your preferred declaration style to basic completion.

Positional records have a compiler-generated Deconstruct() method. ReSharper supports all deconstruction features in such objects. Notice the popup when introducing a variable: it offers you the choice between single variable or a deconstructing declaration. The same choice will be offered when a function accesses a property of a record object.

Moving on from the big things, local functions are now permitted to have attributes (as well as parameters and type parameters in local functions). This is supported by ReSharper’s quick-fixes, including the neat feature of annotating the method as [NotNull] or [CanBeNull] by pressing ! or ?, respectively.

Another useful C# 9 addition is the ability to write top-level programs. No more fighting with Program classes: you can place your entry point code right after the using directives! There is some help available for working with top-level statements as well. There are two rules about top-level statements: they should precede any type or namespace, and only a single file in the project can contain top-level code. Both rules are easy to break when you’re rearranging and copy-pasting code. ReSharper provides quick-fixes to remedy this by moving your top-level code to the top or to another file.

Given that top-level code is also code, there are refactorings for it as well: Extract local variable and Extract method refactorings.

With target-typed new expressions in C# 9 we can omit the type after the new keyword when it can be inferred from the usage context. ReSharper provides full support for the feature including the ability to Find Usages of the constructor and configure preferred syntax style. The latter allows you to use new() syntax when a created type is evident while enforcing an explicit type specification in other cases.

By the way, ReSharper’s new (pun intended) type name hints can help if all the new() in your code gets out of control.

With return type covariance, you’re no longer bound to returning the same type in overriding members as you do in the base class method. There is no longer any need to implement workarounds to return a more specific type.

Pattern matching continues to evolve in the new language version. Matching expressions now allow using relational (<, >, etc.) and logical (not, or, and) patterns, cutting out a lot of the verbosity of the old switch constructs. ReSharper can assist you with analyzing the patterns and rewriting them in the desired style.

Finally, when lambda discard parameters were introduced, we felt it would be nice to add a quick-fix for them.

That’s about it for the major language highlights. There are smaller improvements added to the language that are supported in ReSharper 2020.3 as well. This includes target-typed conditional expressions, static lambdas, extension GetEnumerator methods in foreach, function pointer types, and native integer types.

Inlay Hints

We believe in the power of inlay hints, but we also know that the environment should be kept as clean and uncluttered as possible. We’ve come up with a new "Push-to-Hint" mechanism for inlay hints to keep the best of both worlds.

In Push-to-Hint visibility mode, hints aren't shown by default. They're shown if you press and hold Ctrl (and hidden as soon as you release it) or press Ctrl twice (in which case they remain visible until you press Ctrl twice again).

We’ve provided quite granular settings: you can tell ReSharper which hints should always be enabled, which should be shown on push, and which you don’t really care for. Use the ‘Visibility’ setting for each hint type.

Another thing we’ve worked on are the hints for implicit type casts. Such casts can result in data loss or performance degradation, and ReSharper can now indicate where an implicit cast is happening.

When you Ctrl+Click on a type conversion hint it will take you to the implementation of the implicit conversion.

Inlay hints for XAML, which were already available in the previous version, now also have the usual context menu that allows you to configure how they look.

Formatter

We continue to add more granular settings to the formatting engine. This is what we’ve added in this release.

A group of settings for arranging property patterns: you can tell ReSharper to place a simple pattern on a single line, and also how you prefer long patterns to be wrapped. There’s also a setting to align the property patterns in columns.

Blank lines can now be added around property or event accessors.

For Visual Basic, there’s the option to add a space after the unary +/- operator.

There are some updates for the .editorconfig support as well. ReSharper now supports the Roslyn properties: file_header_templates, dotnet_sort_system_directives_first, and dotnet_separate_import_directive_groups.

There’s also a new “Spaces around ‘=’” parameter in export to .editorconfig. It is detected automatically in existing files and can be set manually for new files. It is set to ‘true’ by default.

Dynamic Program Analysis

We’ve added Dynamic Program Analysis (DPA) to ReSharper to help you analyze and create better code by detecting closures and allocations to large and small object heaps in the memory.

The best part is that you don’t have to do anything except your usual routine of coding, running and debugging. DPA goes on in the background and is ready with a report after each launch of your project. Just keep an eye out for the icon in the bottom-right corner.

For more details about DPA, please see this blog post.

Structural Remove

You may already be familiar with the structural navigation feature: it allows you to select pieces of code according to their structure, a keyword, a block, a method, and so on.

When you’re using the Extend or Shrink Selection actions, they require another step to select a comma, a dot, or a bracket, which is easy to miss. If you were deleting a block, this would result in a code error. ReSharper will do a little cleaning up in this case: if something was selected structurally, ReSharper will try to delete it structurally when you press Backspace or Delete.

Command Line Tools

If you’re working on a large code base, every solution-wide operation takes a long time to run. Have you ever found yourself waiting for the whole solution to be reformatted after you’ve changed a couple of files? Well, now you can run the CleanupCode console tool without pointing to the solution file: just specify a set of files or folders. The command line will look like this: cleanupcode.exe [Path to folder] [Path to file] [Path to another file]

Please note that the tool only formats the code – cleanup isn't available in this mode.

One more thing that was missing from our console tools for some time was support for plugins. Well, it’s back! For now it’s only available on Windows. To make use of it, you’ll need to know the ID of the plugin. Go to the JetBrains Marketplace, open the plugin page, go to the Versions tab, click on any version and it will show you the plugin ID. After that, use the -x=[ID] key with the plugin ID when launching InspectCode or CleanupCode and the console tool will automatically download and enable the plugin: cleanupcode.exe -x=[ID] [Path to solution file].

Please note that the plugin has to be compatible with the tool version. Also, plugins are not yet supported if you’re using the .NET Core global tools mechanism to install ReSharper’s command line tools.

Navigation

Have you ever struggled when searching for text? Maybe for a string in your code, or a comment? Or did a typo in your text prevent you from actually finding anything?

Find Text now performs fuzzy search in addition to exact search, taking possible typos and missing words into account. The results are displayed below the results of the regular substring search, in the Fuzzy section. Hint: it can be very helpful if you are looking for a certain formatted string build in your code.

Avalonia Support

Code Analysis

As is typical for all the WPF-like frameworks, code analysis provides plenty of common code inspections with appropriate quick-fixes for both C# code-behind and .axaml files including “Possible ‘System.NullReferenceException’” and “Class/Property {...} is obsolete: Use {...}”.

In addition to the common WPF inspections, there are a lot of Avalonia-specific inspections, such as “Path to resource is case-sensitive” or “ColumnDefinitions tag can be converted to attribute” inspections with quick-fixes. For the latter, there is a context action on ColumnDefinitions="*,Auto,*" attribute to convert it back into a <Grid.ColumnDefinitions> tag.

We’ve added proper support for “$self", “$parent”, “^”, and “#” syntax in Avalonia bindings, as well as proper validation of indexes in the $parent[] array.

There is extended support for CompiledBinding and the x:CompileBindings extension. ReSharper knows that DataType is required here and prompts you to specify it for bindings in your code.

The “Create from usage” quick-fix is available for all sorts of Avalonia properties.

Avalonia XAML support includes understanding of the CSS-like styling system.

Inlay Hints help you better understand the code you are looking at.

Code completion

Code completion and parameter info are available for all XAML keywords, all sorts of markup extensions, x:Name, Style properties, Source properties for StyleInclude, and lots more.

Navigation

You can easily navigate to compiled binding data type, bound property, Avalonia control type, and x:Name declarations. ReSharper can also go directly from XAML to decompiled external code including style setter properties and to referenced xmlns namespaces.

Find Usages

Find Usages helps you find all usages of method bindings, x:Name attributes, Style classes and setters, and all sorts of properties.

Refactorings

Rename and Safe Delete refactorings are now aware of all kinds of usages in Avalonia XAML code and update them accordingly.

Hierarchy and code structure

You can observe the hierarchy and structure of the Avalonia XAML code.

Decompiler Updates

ReSharper’s integrated decompiler has also received updates to support more C# features. We’ve also improved the synchronization mechanism between IL Viewer and source code.

Specifically for top-level statements, we’ve added a <Top-level Entry Point> node in Assembly Explorer. You can double-click or use the context menu navigation on this node to get to actual top level statements in decompiled code.

Private Source Link is now supported. After you navigate to the external sources that require a connection to a private source server, ReSharper will show a notification and let you enter your credentials; unless, of course, you’ve already specified them in Visual Studio’s settings, in which case they will be applied automatically (for GitHub and BitBucket).

Blazor

We continue to add more Blazor support. This iteration was about supporting generic type parameters and their type inference from usages, and eliminating performance setbacks on opening solutions. For the full list of fixed issues, please refer to our public bug tracker.

Perfect Unreal Engine companion

Unreal Engine

ReSharper C++ 2020.3 provides seamless integration with UnrealHeaderTool to help you catch issues that are usually discovered only at compile time. ReSharper C++ runs UnrealHeaderTool in the background and displays the analysis results in real time right in the editor.

To improve its HLSL support, ReSharper C++ brings control-flow analysis inspections to shader files. Live tracking of changes to build configuration files lets ReSharper always use the most up-to-date project model.

Learn more

Even better C++20 support

C++20

ReSharper C++ 2020.3 implements the C++20 changes to comparison rules. With rich inspections and error messages, you can rely on ReSharper C++ when you need to understand exactly how your code behaves, while the new quick-fixes help you work with comparison operators easily.

In addition, ReSharper C++ 2020.3 brings new inspections to help you adopt the C++20 ranges library, and adds support for the standard mode of C++20 coroutines introduced in Visual Studio 16.8.

Learn more

Timeline inspections dotUltimate

Timeline inspections

dotMemory uses the timeline data to provide automatic inspections right on the Timeline graph.

Currently, there are three inspections available:

  • High Garbage Collection pressure
  • Pinned objects in Gen0
  • Fast Large Objects Heap growth rate

Learn more

Improved Continuous Testing dotUltimate

Improved Continuous Testing

Now, you can refine what projects should be built when a continuous testing session is triggered. This lets you speed up continuous testing sessions. The feature works in both Visual Studio and Rider.

Learn more

Other Updates

  • Support for nullable annotations on unconstrained generic types (includes default constraint).
  • We’ve implemented a modest update for TypeScript support: ReSharper now supports nullish coalescing and optional chaining.
  • We’ve added a new quick-fix that helps you transform a sequential pattern check into a complex pattern-matching check.
  • Inside the Change Signature refactoring, we’ve redesigned the tool used to set the default value for the parameter you’re adding – the tool that is opened when you choose ‘Resolve with call tree’. Navigation to code is now available by double-clicking on a node. There’s a new option called Create default parameter that takes you directly into the code to specify the value. Finally, different colors are applied for different fixes selected in the tree. We hope this makes resolving usages easier!
Download

Free 30-day trial available