ReSharper 2023.1 improves support for C#, including a set of inspections to optimize and speed up your work with different types of collections, and more adjustable ways to introduce null checks in your code. This build also brings updates for C++20 modules, the first batch of support for C++23 features, as well as macro substitution previews and Call Tracking for C++. Also included are enhancements to the unit testing and code cleanup user experience.
Free 30-day trial available
We’ve 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:
Contains(item)
check before adding the item into HashSet
or other collections implementing the ISet
interface.
ContainsKey(key)
check before adding the item into
Dictionary
or other collections implementing the
IDictionary
interface.
TryAdd(key, value)
for Dictionary
collections
or collections inherited from Dictionary
when possible.
TryGetValue(key, out value)
for IDictionary
collections when possible.
We provided the 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. You can adjust the
behavior anytime on the ReSharper | Options | Code Editing | C# | Syntax Style
page.
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. We've added the
Add pattern variable context action over the not null
pattern
to look for expressions accessing the same value (since we 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.
.NET 6.0 SDK introduced a new API for null
checking -
ArgumentNullException.ThrowIfNull
. Our 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 the 2023.1 release we added an ArgumentNullException.ThrowIfNull
pattern to ReSharper | Options | Code Editing | C# | Null checking.
If you use property pattern matching heavily, try our 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.
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.
span.SequenceEqual(“str”)
Code analysis 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.
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, we’re introducing an Insert return type specification context action in ReSharper 2023.1. The action can be applied to all scopes, including method, class, file, project, or to the entire solution, to accomplish this.
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 we introduced a new code analysis in version 2023.1 that warns you about
"dead" checks inside complex patterns.
We are continuing to improve our support of C# 11 list patterns. With the new Convert to list pattern context action you can turn collection length checks into a list pattern syntax. It works in any context where a check of a collection length can be done.
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. Additionally, the Quick Documentation popup (Ctrl+Shift+F1) allows you to click on any entity from the substitution preview to check out its documentation.
Call tracking has finally come to ReSharper C++! 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.
ReSharper 2023.1 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.
Reformat inactive preprocessor branches in file is a new task type we’re introducing in ReSharper 2023.1. 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.
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.
We have 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.
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.
With little demand for CSS in ReSharper, we found it increasingly hard to prioritize keeping up with the latest versions of the language. Therefore, we decided to put CSS support on hold until we can find a better way to support the language.
Starting with ReSharper 2023.1, CSS support will be disabled by default. If you still want to use the language, you can re-enable it here: ReSharper | Options | Environment | Products & Features | the "CSS" checkbox.
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, we’re reducing that list by dropping support for the two oldest versions, Visual Studio 2010 and Visual Studio 2012.
Free 30-day trial available