.NET Tools Early Access Program News Releases ReSharper Platform

ReSharper 2023.2 Kicks Off the Early Access Program!

You can download the ReSharper 2023.2 EAP build 1 from www.jetbrains.com or via the JetBrains Toolbox App.

Now, let’s take a look at what the first EAP build has in store.

C# inspections for #nullable directives and NRT annotations

We’re kicking off the new cycle of C# language support development with the introduction of two new inspections that can counter the misuse of #nullable directives.

The new Redundant nullable directive inspection is designed to point out cases where the #nullable directive does not change nullable context and can be safely removed. The Unused nullable directive inspection deals with cases where there is no code affected by the #nullable directive. As always, both inspections come with corresponding quick-fixes for easy code cleanup.

Another C# inspection we’re introducing in EAP 1 is designed to alert you to cases where nullable reference type (NRT) annotations contradict JetBrains.Annotations attributes on a base member.

New nullable directive inspections in ReSharper 2023.2

NRT annotations alone can verify signature mismatches on inheritance only when both the base and derived types use nullable reference types. This leaves a dangerous gap in the nullability safety net when a project is only partially migrated to NRT or when it uses a third-party library that has only JetBrains.Annotations or external JetBrains.Annotations (for example, if its authors don’t want to migrate it to NRT). The new inspection will cover such cases, catching signature mismatches at the border of two different nullability annotation systems and making it harder for NullReferenceException exceptions to creep into your code. 

New options for formatting fluent API calls

ReSharper 2023.2 EAP 1 introduces a couple of new options for C# code formatting, designed to improve the readability of chained method calls.

The first code formatting option controls whether a line break comes before the first method call. The second option is for situations where method and property invocations are mixed, and it determines whether a line break should be inserted after the property invocation.

Code formatting for fluent API calls

You can find and enable the formatting options by going to Resharper Settings | Code Editing | C# | Formatting Style | Line breaks and wrapping.

New inlay hints

The first EAP build for ReSharper 2023.2 comes with a set of brand new inlay hints to aid the readability of your code whenever tuples, discards, and deconstruction components in deconstruction patterns are involved.

When passing a value to a tuple argument or return type, C# allows you to skip component names. However, without the names it becomes more difficult to tell the meaning of each component without looking at its target type. For example, many software developers will have to check where a tuple (null, false) is assigned to understand what its components mean.

That’s where inlay hints can help you out! ReSharper 2023.2 will display inlay hints with tuple component names when those names aren’t already apparent from the component expression, making your code much easier to read and understand at a glance.

Inlay hints for tuple component names

For null and default components, ReSharper 2023.2 will display hints about their target types even if the target component doesn’t have an explicit name. It will make an exception for string and object types, as those usually aren’t very informative.

Another common situation in which names can improve readability is deconstruction patterns where an explicit name is known either from the Deconstruct method or from source tuple components. These hints were developed to provide you with additional context when a pattern itself doesn’t contain enough data to understand what is matched, such as value is ({ }, true, null).

Inlay hints for deconstruction patterns

Last but not least, ReSharper 2023.2 will allow you to quickly check names and types of discarded values with Push-to-hint. Sometimes, an object or method returns more variables than needed, and some are discarded with `_`. When returning to such code later, knowing what additional data could have been obtained is often beneficial. Perhaps, a bug you are looking for is caused by someone disregarding an additional bit of information instead of checking it? Hints for discards are not shown by default, but when you need to know what value is discarded, you can quickly check it by pressing and holding Ctrl to activate the Push-to-hint functionality.

C++ updates

Safe Delete comes to C++

The Safe Delete refactoring lets you remove symbols from the source code safely. It is now available in C++ for deleting a class, function, variable, namespace, or even a concept. What makes this refactoring safe is that before deleting a symbol, ReSharper C++ searches for usages and gives you a preview of the results, so you can be sure that all the removals are intended.

If you try to delete a complex entity, like a class or namespace, ReSharper C++ will recursively check usages for all its members.

More C++20 and C++23 features

In this EAP build, ReSharper C++ introduces support for if consteval and brings 3 new inspections to help you play around with recent language additions for constant evaluation:

  • consteval if is always constant
  • std::is_constant_evaluated will always evaluate to constant
  • if can be replaced by if consteval
Consteval inspection in ReSharper C++

With improved completion for dependent code with C++20’s concepts, you will now get completion items when the type is restricted by concepts or traits. There are also handy new context actions to move a constraint to a requires-clause and to convert a clause to a parameter constraint.

C++20 completion in ReSharper C++

For more details on the ReSharper C++ updates, see the dedicated blog post.

For the full list of resolved issues, please refer to our issue tracker.

That’s it for now! Make sure you give ReSharper 2023.2 EAP 1 a try and leave your feedback in the comment section below or on our social media, and submit any issues you come across to our tracker.

image description