ReSharper 2022.2 includes support for C# 11 features such as required members, checked user-defined operators, raw strings, and list patterns. The solution-wide analysis has greatly optimized memory consumption. Additionally, this release also brings the Virtual Formatter, which allows you to view code in your preferred format without actually reformatting the source code on the disk, and a Disk Cleanup tool to remove temporary files generated by ReSharper while it works on your code.
This release brings support for several more features from the C# 11 preview.
In C# 11,
record types gained the
ability to declare a list of required members. This is the list of all
properties and fields that are considered required and must be initialized
during the initialization of a type’s instance. Types inherit these lists
from their base types automatically, providing a seamless experience that
removes boilerplate, repetitive code.
Apart from being aware of the
required keyword for members inside a
record type, ReSharper provides additional
support for the
requiredmodifier has been added to the Modifiers order on the
ReSharper | Options | Code Editing | C# | Syntax Stylepage.
We’ve added a new Add initializer for required members quick-fix for cases where you’ve created a type’s object but haven’t initialized the members yet. It automatically generates all of the missing “required” members for your object – you just need to fill in the members’ values with meaningful data.
Checked user-defined operators help developers create user-defined
operators that operate on types where arithmetic overflow is a valid concept.
ReSharper shows all of the compiler errors and warnings. To fully support
checked user-defined operators, ReSharper has a couple more inspections
and a context action.
We’ve updated the Unchecked/checked context is redundant inspection
to take into account
checked operators when they are used in this context.
If you have a set of user-defined operators and some of them already have a
version, ReSharper will help you propagate
checked operators to the whole set.
A new inspection called
The operator does not have a matching
checked operator while other operators do
will notify you which operators don’t have a checked operator yet and suggest a
quick-fix to generate the
checked versions automatically.
If you haven’t used
checked operators in your codebase yet, but want to start
adding them, a new context action called Create matching checked operator
will come in quite handy. It is available on every user-defined operator and
generates a checked version of an operator right from the Alt+Enter
menu in one click.
C# 11 improves the ability to embed other languages or text formats into C# code by introducing the concept of "raw" strings.
ReSharper has basic “raw” string support including compiler errors and correct
parsing and color highlighting for
""" syntax, pairs of double quotes,
and placeholders inside interpolated strings
C# 11 continues to expand the set of patterns available in the language. This
time around, C# allows matching through list-like structures, such as arrays,
ReSharper 2022.2 fully supports list patterns with error checking, code completion, and code analysis. We are still working to add code inspections to suggest using the list patterns in existing code and additional refactoring actions.
>>>), including support for user-defined operator
Span<char>values as a replacement for string instances, since in C# 11 it's possible to directly pattern-match string constants against the values of type
In this release, we've greatly optimized the memory usage of ReSharper with the Solution-Wide Analysis mode turned ON, both in terms of memory traffic (number of memory allocations) and in terms of memory consumption.
The Solution-Wide Analysis engine uses memory to store the list of issues in the solution and to store the type/member usage information to perform solution-wide usage reporting (code inspections like "public member is never used"). The usage data is "hot", meaning it needs to be constantly updated while you are editing the code, and can’t be off-loaded to the disk. This can consume a significant amount of memory if your solution contains lots of types and type members. We reviewed the data stored in memory and found patterns that allowed us to deduplicate/normalize the data. We also utilized specialized collection types to further reduce the working set. These optimizations resulted in a 5-10x memory consumption improvement and faster Solution-Wide Analysis loading.
.NET 6 introduced new project templates with the use of C# 9 top-level statements.
Top-level statements simplify declaring a
Program class or
public static void Main(string args) method. But sometimes the
class Program is necessary or more desirable to use. ReSharper
2022.2 adds the new context action To explicit 'Program' class to execute
a transformation to the old style.
At the same time, if you have an existing
Program startup class and wish
to migrate to top-level statements, we've got you covered with a new Convert to
top-level code context action.
In this release we reworked our
INotifyPropertyChanged support. It no longer
relies on external annotations to detect common
which allowed us to support more MVVM frameworks and
base classes automatically. We now emit a
SetField method that enables the
most concise syntax for
It's also now possible to add property change notifications for all of the properties in the type or file.
To increase the discoverability of refactorings, we reviewed the most commonly used refactorings and introduced related context actions in the Alt+Enter menu that depend on the current context.
We've added the Extract method context action when you call the Alt+Enter menu on a selected piece of code.
Change Signature, Transform Parameters, Convert to extension method, and Convert Property To Method refactorings are all now available as context actions over member signatures.
ReSharper 2022.2 now recognizes the registrations of
in WPF projects and suggests using a
nameof operator to capture the
corresponding CLR property name. Built-in live templates were also updated
nameof instead of string literals.
Often ReSharper can’t recognize the special meaning of a particular string literal in your code that is used to specify the name of some code entity like a member or type name. For these cases, we've introduced a new Capture element name context action for string literals with identifiers that can reference a code entity in the context containing the string literal.
Quick-fixes which come from Structural Search And Replace (SSR) patterns can
now be applied in the scope of a file, folder, project, or entire solution. It
affects user custom patterns created on the
ReSharper | Options | Code Inspection | Custom Patterns page, ReSharper
built-in code inspections, and the corresponding fixes based on the SSR.
ReSharper 2022.2 now detects some assignment patterns in your code and suggests more idiomatic C# code with pattern matching.
ReSharper 2022.2 is now able to replace some
is patterns under
?: expressions with the more concise
as under the
?? expression, effectively eliminating a temporary variable.
We’ve introduced the Virtual Formatter — a way for you to view code with your
desired formatting without actually reformatting the source code on the disk. For
example, you can now virtually align parameters in columns or increase indents. Our
goal with this feature is to improve readability and maintainability of code and make
it more accessible for visually impaired and neurodivergent developers. To enable
the Virtual Formatter with predefined settings, go to
ReSharper | Options | Environment | Inlay Hints | General. To further tailor
the formatting to your exact specifications, check the
Use dedicated Virtual Formatter style settings checkbox and click C#.
You can now remove temporary files generated by ReSharper while it is working on your code. We’ve added a new page in Options where you can:
is outdated and slow. In the current implementation, it's difficult to follow TS
language changes and support new versions quickly, so we are looking for a better
way to support these languages. After a long internal discussion, we've decided to
put our current JS and TS support on hold. As a result, we've disabled TS/JS support
by default in this release. If you still want to use it, you can re-enable it here:
ReSharper C++ introduces Blueprint-specific inlay hints and allows you to see the bigger picture behind your code:
UFunctionhas implementations in Blueprints and search for all such cases.
UProperty, including whether it has been overridden and what value is set in the Blueprint file.
We’ve also added inspections to let you know if there are inconsistencies between the Blueprint-specific function specifiers used in the code and the Blueprints themselves.
ReSharper can now detect if the StyleCop.Analyzers package is referenced by
a project and read its settings from the
File headers and indentation settings are lifted from
StyleCop rules are applied in accordance with the active
.ruleset file setup.
R2Rlabels are now displayed next to each assembly's name.