ReSharper 2023.1

Adds new ways to introduce null checks into your code along with updates for several C++20 modules.
April 6, 2023
New Version

Features

C# support

  • Reducing the number of lookups in collections - Introduced a set of inspections with corresponding quick-fixes to optimize and speed up your work with different types of collections by reducing the number of lookups in collections:
    • To remove a Contains(item) check before adding the item into HashSet or other collections implementing the ISet interface.
    • To remove a ContainsKey(key) check before adding the item into Dictionary or other collections implementing the IDictionary interface.
    • To use TryAdd(key, value) for Dictionary collections or collections inherited from Dictionary when possible.
    • To use TryGetValue(key, out value) for IDictionary collections when possible.
  • Syntax style for null checking pattern - Added a new Syntax style setting to help you enforce one consistent style of not null checks inside the patterns. It consists of two options: empty recursive pattern syntax { } and negated pattern not null, where the latter is the default one.
    • Using the not null pattern has a disadvantage as it doesn't allow for variable names to be introduced for the checked value like the recursive pattern { LastName: { } lastName } can. The Add pattern variable context action has been added over the not null pattern to look for expressions accessing the same value (since you are introducing a variable name) and replace all of them with the newly introduced name to consolidate all of the accesses to the same value.
  • ArgumentNullException.ThrowIfNull style of null checks - Microsoft .NET 6.0 SDK introduced a new API for null checking - ArgumentNullException.ThrowIfNull. The code analysis engine has recognized this checking approach since that time, but there was no option to use this API as a default style of null checks produced by ReSharper. In this release an ArgumentNullException.ThrowIfNull patternhas been added to ReSharper | Options | Code Editing | C# | Null checking.
  • Extract common property pattern - If you use property pattern matching heavily, you can now use the new inspection with a quick-fix to extract common elements from several property patterns when they come together in the code flow. The code generated by the Extract common property pattern quick-fix helps you reduce code repetition by moving common property patterns to a higher level pattern.
  • Remove empty regions - C# developers often rely on the #region directive and code folding in the IDE to structure their code. Refactoring may leave some #region's empty, which can make the code look misleading when collapsed. With this new code inspection, you'll be able to identify empty #region’s in their collapsed state and clean up the code with a corresponding quick-fix.
  • Replace span.SequenceEqual("str") - Code analysis now has a code inspection that will suggest replacing span.SequenceEqual("stringLiteral") with span is "stringLiteral" - a cleaner and more convenient C# syntax solution than calling a function.
  • Insert a return type specification for lambdas - Lambda expressions in C# can have implicitly-typed parameters and inferred return types. However, explicit types can be added to clarify code in complex overload resolution scenarios. Starting from C# 11, it's also possible to add a return type specification for lambda expressions.
    • To accomplish this, an Insert return type specification context action has been introduced in this release. The action can be applied to all scopes, including method, class, file, project, or to the entire solution, to accomplish this.
  • Pattern is redundant inspection - C# or/and/not patterns are useful for compact value checks, but can be less recognizable than traditional expressions, such as ||/&&/!. They may also create hard-to-find bugs if parentheses are missed. To help with this a new code analysis has been introduced that warns you about "dead" checks inside complex patterns.
  • Convert to list pattern context action - Improved support of C# 11 list patterns. With the new Convert to list pattern context action you can now turn collection length checks into a list pattern syntax. It works in any context where a check of a collection length can be done.

C++ support

  • Macro substitution preview - When hovering over a macro, you can now see the macro expansion in the tooltip with full syntax highlighting and proper code formatting. You can still use the Substitute macro call context action to check out the macro expansion right in the code, but the instant preview makes working with macros easier. The Quick Documentation popup (Ctrl+Shift+F1) now allows you to click on any entity from the substitution preview to check out its documentation.
  • Call tracking - You can now view and navigate through call chains in the hierarchy of incoming calls. In the call tracking results window, you can double-click the hierarchy entry to navigate to the corresponding call in the editor or expand any node to check out its incoming calls.

UX/UI changes

  • The update dialog - This release introduces a reworked update dialog that contains notes on the changes made to the latest build available, so you can make a more informed decision on whether you'd like to download or skip the update.
  • New shortcut dialog - Starting with this release, when you launch ReSharper for the first time, you'll be presented with a Keyboard Shortcuts screen where you can choose the shortcuts scheme you'd like to use.

Code cleanup

  • Introduced a new task type for code cleanup in this release - Reformat inactive preprocessor branches in file. The task enables you to reformat inactive preprocessor branches. It can only be applied to the entire file at once and works only with C# sources. This task cannot reformat code hidden behind a preprocessor directive #if that is always false. The two most obvious examples of this limitation are '#if false ... #endif' and '#define A #if !A ... #endif' constructs.

Unit Tests

  • Text search filters applied to Unit Test trees, inside both the Session and Explorer tool windows, are now taken into account when running tests using the Run buttons in the toolbar. Only the nodes that satisfy the search criteria will remain listed and will be run.

Rename refactoring

  • Improved the way ReSharper handles renaming files in a project. From this build on, whenever you rename a file inside your solution, a dialog will appear with the option to rename all relevant symbols (classes, interfaces, etc.) to match the change.

dotTrace on Apple macOS and Linux (Beta) (dotUltimate)

  • The standalone version of dotTrace is now available on Linux and macOS. You can now perform the full profiling workflow on these operating systems, including collecting and analyzing performance snapshots.

Plugin migration

  • As long as the APIs they reference remain valid and unchanged, ReSharper plugins now automatically migrate from one version to the next. A built-in API verifier will check the installed plugins for binary compatibility and migrate the viable ones. Plugin authors will also receive automatic notifications via JetBrains Marketplace whenever the APIs used by their plugins are no longer present in the SDK.

Miscellaneous

  • CSS support switched off by default - CSS support has been put on hold until a better way to support the language can be found. Starting with this release, CSS support will be disabled by default. If you still want to use the language, you can re-enable.
  • Ending Development for Microsoft Visual Studio 2010 and 2012 - ReSharper and .NET Tools currently support 7 major versions of Visual Studio, from 2010 up to the most recent, 2022. As of the 2023.1 releases, the list is being reduced by dropping support for the two oldest versions, Visual Studio 2010 and Visual Studio 2012.
ReSharper

ReSharper

Increase your .NET productivity.

Got a Question?

Live Chat with our JetBrains licensing specialists now.