ReSharper 2022.2

Adiciona suporte para recursos C# 11, incluindo membros necessários e operadores definidos pelo usuário e verificados.
Agosto 4, 2022
Nova versão

Recursos

C# 11

  • Required Members
    • In C# 11, class, struct, and 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 class, struct, or record type, ReSharper now provides additional support for the required keyword:
      • There is a required keyword in the code completion.
      • Most of the compiler errors and warnings are available.
      • The required modifier has been added to the Modifiers order on the Preferences/Settings | Editor | Code Style | C# | Syntax Style page.
    • 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
    • ReSharper now shows all of the compiler errors and warnings. To fully support checked user-defined operators, ReSharper now has a couple more inspections and a context action.
    • 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 checked version, ReSharper will now 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 can be used. 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.
  • Raw strings
    • C# 11 improves the ability to embed other languages or text formats into C# code by introducing the concept of "raw" strings.
    • ReSharper now 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 ({{...}} syntax).
  • List patterns
    • C# 11 continues to expand the set patterns available in the language. This time around, C# allows matching through list-like structures, such as arrays, strings, and List<T>-like collections.
    • ReSharper now fully supports list patterns with error checking, code completion, and code analysis.
  • More C# 11 features
    • Added support for the new unsigned right shift operator (>>>), including support for user-defined operator >>> overloading.
    • Added support for simplifying the use of 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 Span<char> and ReadOnlySpan<char>.

Solution-wide analysis optimizations

  • 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 data stored in memory has been reviewed and patterns were found that allowed for the data to be deduplicated/normalized.
    • Now utilizes specialized collection types to further reduce the working set.
    • These optimizations result in a 5-10x memory consumption improvement and faster Solution-Wide Analysis loading.

Code Analysis

  • Top-level statements
    • Microsoft .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 explicit startup class Program is necessary or more desirable to use. This release 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, you can use the new Convert to top-level code context action.
  • Updates to the INotifyPropertyChanged support
    • Reworked the INotifyPropertyChanged support. It no longer relies on external annotations to detect common INotifyPropertyChanged APIs, which means support for more MVVM frameworks and INotifyPropertyChanged base classes could be added automatically. ReSharper now emits a SetField method that enables the most concise syntax for INotifyPropertyChanged notifications.
    • It's also now possible to add property change notifications for all of the properties in the type or file.
  • Refactorings in the Alt+Enter menu
    • To increase the discoverability of refactorings, the most commonly used refactorings were reviewed and related context actions have been introduced in the Alt+Enter menu that depend on the current context.
    • 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.
  • More suggestions for using a nameof operator
    • ReSharper now recognizes the registrations of DependencyProperty in WPF projects and suggests using a nameof operator to capture the corresponding CLR property name. Built-in live templates have also been updated to emit 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, a new Capture element name context action has been introduced for string literals with identifiers that can reference a code entity in the context containing the string literal.
  • Structural Search and Replace
    • 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, ReSharper built-in code inspections, and the corresponding fixes based on the SSR.
  • Other
    • ReSharper now detects some assignment patterns in your code and suggests more idiomatic C# code with pattern matching.
    • ReSharper is now able to replace some is patterns under ?: expressions with the more concise as under the ?? expression, effectively eliminating a temporary variable.

Virtual Formatting

  • Added the Virtual Formatter which allows you to view code with your desired formatting without actually reformatting the source code on the disk.

Disk Cleanup

  • You can now remove temporary files generated by ReSharper while it is working on your code. A new page has been added in Options where you can:
    • Observe a set of default paths and files ReSharper can remove.
    • Add a custom path template for files you want to be removed.
    • Specify after how many days ReSharper should consider files outdated for each path template.
    • Check how much space is occupied by files matched by each path template.
    • Set up automatic cleanup for outdated files which will run periodically (the default value is 1 day).
    • Run the cleanup manually for different scopes.

JavaScript and TypeScript support

  • JavaScript and TypeScript support has now been disabled by default in this release. If you still want to use it, you can re-enable it here: ReSharper | Options | Environment | Products & Features | the "JavaScript and TypeScript" checkbox.

Unreal Engine

  • ReSharper C++ introduces Blueprint-specific inlay hints and allows you to see the bigger picture behind your code:
    • Be aware of derived Blueprint classes and check out the list of all inheritors.
    • Spot that a UFunction has implementations in Blueprints and search for all such cases.
    • Quickly check the state of a UProperty, including whether it has been overridden and what value is set in the Blueprint file.
    • Inspections have also been added to let you know if there are inconsistencies between the Blueprint-specific function specifiers used in the code and the Blueprints themselves.

Native system calls

  • Improved support for native system calls [dotUltimate] - dotTrace now provides more details for native system calls in the Timeline Call Tree, including Windows kernel calls (ntoskrnl.exe), device driver calls (*.sys), and more.

Respect settings from StyleCop.Analyzers

  • ReSharper can now detect if the StyleCop.Analyzers package is referenced by a project and read its settings from the stylecop.json and .ruleset files. File headers and indentation settings are lifted from stylecop.json, while StyleCop rules are applied in accordance with the active .ruleset file setup.

ReadyToRun and NGen assemblies

  • The way ReadyToRun (R2R) and NGen assemblies are presented in the Assembly Explorer has been improved. A small processor-looking icon, as well as NGen or R2R labels, are now displayed next to each assembly's name.
  • The Metadata tree has the ReadyToRun header.
Required Members

ReSharper

Aumente sua produtividade de .NET.

ReSharper também está disponível em:

Tem alguma pergunta?

Chat ao vivo com nossos especialistas de licenciamento de JetBrains.