
In the 2023.1 release, we added an ArgumentNullException.ThrowIfNull pattern to ReSharper | Options | Code Editing | C# | Null checking. Our code analysis engine has recognized this checking approach since then, but there was no option to use this API as a default style of null checks produced in ReSharper.

NET 6.0 SDK introduced a new API for null checking – ArgumentNullException.ThrowIfNull. ArgumentNullException.ThrowIfNull style of null checks This Add pattern variable context action now looks for expressions accessing the same value (since we are introducing a variable name) and replacing all of them with the newly introduced name to consolidate all accesses to the same value. To help resolve this, we’ve added the Add pattern variable context action over the not null pattern. It consists of 2 options: empty recursive pattern syntax are not as concise as a recursive pattern.

We provided the new “Syntax style” setting to help you enforce one consistent style of not null checks inside patterns. You can apply it to all lambda expressions in scopes like method, class, file, project, or an entire solution. To accomplish this, we introduced a new context action, Insert return type specification, in version 2023.1.

Starting from C# 11, adding a return type specification for lambda expressions is also possible. A context action to insert parameter types, Insert parameter signature, has been around for a while. Sometimes, it can be useful to add explicit types in a signature of a lambda expression to make code clearer or to help C# type inference in some complex scenarios involving overload resolution. Lambda expressions in C# usually have implicitly-typed parameters and an inferred return type. C# support Insert a return type specification for lambdas But before you do it, let’s take a look at the updates in this build. You can download the latest ReSharper 2023.1 Early Access Program build from our website.
