What’s new in ReSharper 2021.2

ReSharper 2021.2 offers new inspections with quick-fixes for C# code analysis and nullable reference types support, and many of the features available for manually-written code files are now available for source-generated files. ReSharper 2021.2 also provides support for single-file applications in the Assembly Explorer, improved issue handling in Dynamic Program Analysis, and advanced naming rules for records, extension methods, and catch variables.

Download

Free 30-day trial available

C# Code Analysis

Do you use temporary variables to swap variable values? There is now a more elegant way to do this! ReSharper 2021.2 will help you modernize your code with the new Swap via deconstruction quick-fix!

Reduce the number of allocations in your code, and increase throughput! Replace empty array creation with Array.Empty<T>.

If you’re allocating a new Type[0], ReSharper will suggest using Type.EmptyTypes to make memory usage more efficient.

If specific EventArgs are not required, ReSharper will let you know you can replace new EventArgs() with EventArgs.Empty.

Other improvements:

  • Use the generated_code property from .editorconfig to mark files or folders as generated code and exclude them from processing.
  • Code analysis is now faster for members with lots of local functions and closures.
  • Enjoy performance improvements in Find similar issues and code analysis for large and complex switch statements and switch expressions.

Nullable Reference Types (NRT)

Do you have lots of nullable warning suppressions in your code base after enabling nullable reference types?

ReSharper indicates suppressions (!) that are no longer needed and that can be safely removed.

A new context action lets you search for all nullable warning suppressions in scope. From the Find Results tool window, you can then re-evaluate whether the suppressions are needed or not.

We've introduced a new refactoring to change nullability! It’s available through a quick-fix, through the Refactor This action, or through an in-place refactoring when adding or removing the nullable annotation (?).

ReSharper will update nullability annotations, and suggest propagating the changes throughout your codebase.

Several new inspections with corresponding quick-fixes are available for when you’re using JetBrains.Annotations attributes and nullable reference types are enabled.

Update JetBrains.Annotations attributes to NRT syntax and compiler-supported attributes! For example, ReSharper can update [CanBeNull] string to string?.

ReSharper will inform you about redundant JetBrains.Annotations attributes, such as [NotNull] string or [ItemCanBeNull] List<string?>. And of course, it will offer a quick-fix to update your code.

When type annotation syntax is not allowed, a new inspection with a quick-fix adds compiler-supported annotations, e.g.:

  • [JetBrains.Annotations.NotNull] T param to [DisallowNull] T param (where T: class?)
  • [JetBrains.Annotations.CanBeNull] T to [System.Diagnostics.MaybeNull] T (in C# 8, where the T? syntax is not allowed)

ReSharper adds new inspections and quick-fixes to help you with using compiler-supported annotations such as [DisallowNull], [AllowNull], [MaybeNull], and [NotNull].

A new inspection detects redundant compiler annotations, such as when [AllowNull] is applied to a nullable type, and a quick-fix removes them.

When nullable reference type syntax can be used, ReSharper will suggest doing so.

There are additional improvements that also deserve a mention:

  • ReSharper checks whether variables need to be nullable and produces stricter types when possible.
  • Many context actions, quick-fixes, and postfix templates have been updated to work better with nullable warning suppressions. They either preserve nullable warning suppressions or produce them for introduced code if the original code suppressed the warning.
  • We’ve improved support for using generics with nullable reference types.

Source Generator Support

Source Generators can be used to reduce tedious and repetitive development work, and to generate code at compile time. In ReSharper 2021.2, many of the features available for human-written code files are available for source-generated files as well. We’ve improved editor support, enhanced the debugger, and added support for Solution-Wide Error Analysis (SWEA) and refactorings.

For generated code, warnings and errors are displayed in the editor and on the marker bar.

Solution Wide Error Analysis (SWEA) now includes files generated by source generators. If there's an error in a generated file in your project, you'll be able to spot it immediately and navigate to it.

You can toggle this behavior using the new option to include source generated files, which is enabled by default and located in ReSharper | Options | Code Inspection | Settings | Enable solution-wide analysis.

Refactorings can now be triggered from source-generated files. Use the Rename refactoring to rename a generated property. ReSharper will also rename the related symbol in manually written code!

Similarly, Change Signature lets you verify whether code that will be generated after the change can still be compiled.

You can now use Find Usages, search for inheritors, navigate from generated code to manually written code with Ctrl+Click and Navigate To, and more.

Semantic highlighting is enabled so that class members like events, fields, and properties are highlighted correctly. All inlay hints are shown where appropriate.

ReSharper's own Data Tips are shown while debugging. This provides more powerful debugging assistance with the ability to search, property highlighting, and more.

ReSharper now supports code generated by source generators in VB.NET.

HttpClient URI support

In the previous release, we implemented support for ASP.NET route templates. In the v2021.2 release, we have continued in this direction and brought better support for HttpClient URI strings:

  • When using HttpClient, code completion will suggest all URIs that can be resolved to actions in controllers annotated with [Route], [Http{Method}], or [AcceptVerbs] attributes.
  • You can easily navigate between route attributes inside controllers and these URIs using Go to Declaration and Find Usages
  • Renaming an attribute route in a controller affects its usages in URIs, and you can even rename a route directly from the URI string.

Navigation

Useful features have been added for Navigation:

  • While debugging, ReSharper understands even more about your code. As a result, calling Go To Declaration (or Ctrl+Click) on interface references will take you directly to their implementations.
  • The Go To Base/Inheritors list now shows hidden overrides, as well.

Code Styling and Formatting

It can sometimes be useful to specify advanced naming rules for records, extension methods, and catch variables. Starting from this release, it’s possible to configure these rules.

If you prefer using a Pico brace (indenting) style, we’ve got you covered. The Pico style has been added as an option to the Brace Layout tab on the ReSharper | Options | Code Editing | C# | Formatting Style | Braces Layout page.

We’ve changed the default formatting preferences in a couple of cases to align with the Visual Studio defaults.

C++ Inline Function Refactoring

With the new Inline Function refactoring, you can quickly replace a function call with the body of the function. ReSharper C++ will perform the necessary transformations, handle all the name conflicts, and reformat the resulting code.

C++ Type Conversion Hints

ReSharper C++ 2021.2 introduces inlay hints for implicit type conversions, which could have resulted in inadvertent data loss or performance issues. ReSharper C++ now indicates where implicit conversions happen in your code.

What’s new in ReSharper C++ 2021.2

Dynamic Program Analysis (DPA)

Improved issue handling

DPA now stores two values for each issue – the max value and the current value. This prevents false negatives, as it was previously possible for issues to fall below the threshold and disappear from the issue list, not because they had been fixed, but because their launch conditions had changed (the program ran for less time, the required functionality was not executed, and so on.)

Other updates

  • DPA is automatically disabled when you start performance profiling.
  • The Dynamic Program Analysis window now supports selecting multiple issues.
  • Suppressing issues with the SuppressMessage attribute now works for asynchronous methods.

Assembly Explorer

The embedded decompiler can now decompile single-file apps. It supports single-file formats for the .NET Core 3.1, .NET 5, and the upcoming .NET 6 SDKs. Using Assembly Explorer, you can browse through bundled assemblies inside a single-file app, just like you are used to doing.

Improved Coverage Performance dotUltimate

Improved coverage performance
  • Now, dotCover can run coverage analysis of test classes in parallel within one assembly. In certain scenarios this can result in faster coverage analysis.
  • Unit test runners can now be preloaded for .NET Core and .NET projects (this allows coverage analysis to start quicker, as the unit test runners are already loaded in memory).

What’s new in dotCover 2021.2

Memory Allocation Analysis dotUltimate

In this release, we have continued to improve the way you analyze memory allocation. Two new tabs have been added to the Memory Allocation view:

  • The Methods tab lets you analyze a plain list of methods that have allocated memory.
  • The Call Tree tab lets you analyze the allocation call tree. Each node in the tree shows not only the called method but also the objects allocated by the call.

What’s new in dotMemory 2021.2

Native Profiling dotUltimate

It’s now possible to profile native applications on Windows. When starting a profiling session, you have the option to download native source symbol files from remote servers. Native profiling is only available for the Timeline profiling type.

Other

Razor

Razor developers working on large views can turn off the CPU-intensive assistance and automatic suggestions if their editor begins to lag. You can find the settings here: ReSharper | Options | Environment | Editor | Behavior | Razor | Allow CPU-intensive typing assist.

ReSharper Command Line Tools

We introduced a breaking change in the InspectCode tool. Starting from v2021.2, InspectCode automatically restores NuGet packages and builds a solution before starting its analysis. If this behavior is undesired, use the option --no-build to disable restoring NuGet packages and building the solution.

Download

Free 30-day trial available