ReSharper 2021.2

Ajout de nouvelles inspections avec des correctifs rapides pour l'analyse du code C#, ainsi que la prise en charge des types de référence nullables.
Août 4, 2021
Nouvelle Version


  • C# Code Analysis:
    • Added new Swap via deconstruction quick-fix which will help you modernize your code.
    • You can now reduce the number of allocations in your code and increase throughput. Just replace empty array creation with Array.Empty<T>.
    • If you’re allocating a new Type[0], ReSharper will now suggest using Type.EmptyTypes to make memory usage more efficient.
    • If specific EventArgs are not required, ReSharper can now replace new EventArgs() with EventArgs.Empty.
    • Other improvements:
      • You can now use the generated_code property from .editorconfig to mark files or folders as generated code and exclude them from processing.
      • Code analysis is now faster for members with lots of local functions and closures.
      • Enjoy performance improvements in Find similar issues and code analysis for large and complex switch statements and switch expressions.
  • Nullable Reference Types (NRT):
    • ReSharper now indicates suppressions (!) that are no longer needed and can be safely removed.
    • Added a new context action which lets you search for all nullable warning suppressions in scope. From the Find Results tool window, you can then re-evaluate whether the suppressions are needed or not.
    • Added a new refactoring to change nullability. It’s available as a quick-fix, through the Refactor This action or through an in-place refactoring when adding or removing the nullable annotation (?).
    • ReSharper will now update nullability annotations and suggest propagating the changes throughout your codebase.
    • Several new inspections with corresponding quick-fixes are now available for when you’re using JetBrains.Annotations attributes and nullable reference types are enabled.
    • You can now update JetBrains.Annotations attributes to NRT syntax and compiler-supported attributes.
    • ReSharper will now inform you about redundant JetBrains.Annotations attributes, such as [NotNull] string or [ItemCanBeNull] List<string?>. It will also offer a quick-fix to update your code.
    • When the type annotation syntax is not allowed, a new inspection with a quick-fix adds compiler-supported annotations, e.g.:
      • [JetBrains.Annotations.NotNull] T param to [DisallowNull] T param (where T: class?).
      • [JetBrains.Annotations.CanBeNull] T to [System.Diagnostics.MaybeNull] T (in C# 8, where the T? syntax is not allowed).
    • Added new inspections and quick-fixes to help you with using compiler-supported annotations such as [DisallowNull], [AllowNull], [MaybeNull] and [NotNull].
    • Added a new inspection which detects redundant compiler annotations, such as when [AllowNull] is applied to a nullable type, and a quick-fix removes them.
    • When nullable reference type syntax can be used, ReSharper will now suggest doing so.
    • Additional improvements:
      • ReSharper now checks whether variables need to be nullable and produces stricter types when possible.
      • Many context actions, quick-fixes and postfix templates have been updated to work better with nullable warning suppressions. They either preserve nullable warning suppressions or produce them for introduced code if the original code suppressed the warning.
      • Improved support for using generics with nullable reference types.
  • Source Generator Support:
    • Source Generators can be used to reduce tedious and repetitive development work, and to generate code at compile time. In ReSharper 2021.2, many of the features available for human-written code files are available for source-generated files as well. Improved editor support, enhanced the debugger and added support for Solution-Wide Error Analysis (SWEA) and refactorings.
    • For generated code, warnings and errors are displayed in the editor and on the marker bar.
    • Solution Wide Error Analysis (SWEA) now includes files generated by source generators. If there's an error in a generated file in your project, you'll be able to spot it immediately and navigate to it.
    • You can toggle this behavior using the new option to include source generated files, which is enabled by default and located in ReSharper | Options | Code Inspection | Settings | Enable solution-wide analysis.
    • Refactorings can now be triggered from source-generated files. Use the Rename refactoring to rename a generated property. ReSharper will also rename the related symbol in manually written code.
    • Similarly, Change Signature lets you verify whether code that will be generated after the change can still be compiled.
    • You can now use Find Usages, search for inheritors, navigate from generated code to manually written code with Ctrl+Click and Navigate To and more.
    • Semantic highlighting is now enabled so that class members like events, fields and properties are highlighted correctly. All inlay hints are shown where appropriate.
    • ReSharper's own Data Tips are shown while debugging. This provides more powerful debugging assistance with the ability to search, property highlighting and more.
    • ReSharper now supports code generated by source generators in VB.NET.
  • HttpClient URI support - In the previous release, support for Microsoft ASP.NET route templates was added. In this release, support for HttpClient URI strings has been improved:
    • When using HttpClient, code completion will now suggest all URIs that can be resolved to actions in controllers annotated with [Route], [Http{Method}] or [AcceptVerbs] attributes.
    • You can now easily navigate between route attributes inside controllers and these URIs using Go to Declaration and Find Usages.
    • You can now rename an attribute route in a controller which affects its usages in URIs and you can even rename a route directly from the URI string.
  • Navigation - Useful features have been added for Navigation:
    • While debugging, ReSharper understands even more about your code. As a result, calling Go To Declaration (or Ctrl+Click) on interface references will take you directly to their implementations.
    • The Go To Base/Inheritors list now shows hidden overrides, as well.
  • Code Styling and Formatting
    • It can sometimes be useful to specify advanced naming rules for records, extension methods and catch variables. Starting from this release, it is now possible to configure these rules.
    • Pico style has been added as an option to the Brace Layout tab.
    • The default formatting preferences have been changed in a couple of cases to align with the Microsoft Visual Studio defaults.
  • C++ Inline Function Refactoring - The new Inline Function refactoring lets you quickly replace a function call with the body of the function. ReSharper C++ will perform the necessary transformations, handle all the name conflicts and reformat the resulting code.
  • C++ Type Conversion Hints - ReSharper C++ 2021.2 introduces inlay hints for implicit type conversions, which could have resulted in inadvertent data loss or performance issues. ReSharper C++ now indicates where implicit conversions happen in your code.
  • Dynamic program analysis (DPA) - DPA now stores two values for each issue - the historical max value and the value from the last run. This prevents false negatives, as it was previously possible for issues to fall below the threshold and disappear from the issue list, not because they had been fixed, but because their launch conditions had changed. There are also several other improvements:
    • DPA is automatically disabled when you start performance profiling.
    • The Dynamic Program Analysis window now supports selecting multiple issues.
    • Suppressing issues with the SuppressMessage attribute now works for asynchronous methods.
  • Assembly Explorer - The embedded decompiler can now decompile single-file apps. It supports single-file formats for the Microsoft .NET Core 3.1, .NET 5, and the upcoming .NET 6 SDKs. Using Assembly Explorer, you can browse through bundled assemblies inside a single-file app, just like you are used to doing.
  • Improved Coverage Performance:
    • dotCover can now run coverage analysis of test classes in parallel within one assembly. In certain scenarios this can result in faster coverage analysis.
    • Unit test runners can now be preloaded for .NET Core and .NET projects (this allows coverage analysis to start quicker, as the unit test runners are already loaded in memory).
  • Memory Allocation Analysis - This release improves the way you analyze memory allocation. Two new tabs have been added to the Memory Allocation view:
    • The Methods tab lets you analyze a plain list of methods that have allocated memory.
    • The Call Tree tab lets you analyze the allocation call tree. Each node in the tree shows not only the called method but also the objects allocated by the call.
  • Native Profiling - It is now possible to profile native applications on Microsoft Windows. When starting a profiling session, you have the option to download native source symbol files from remote servers. Native profiling is only available for the Timeline profiling type.
  • Other
    • Razor - Razor developers working on large views can now turn off the CPU-intensive assistance and automatic suggestions if their editor begins to lag.
    • ReSharper Command Line Tools - Introduced a breaking change in the InspectCode tool. Starting from v2021.2, InspectCode automatically restores NuGet packages and builds a solution before starting its analysis. If this behavior is undesired, use the option --no-build to disable restoring NuGet packages and building the solution.
C# Code Analysis


Augmentez votre productivité .NET.

ReSharper est également disponible en :

Vous avez une question ?

Discutez en direct avec l'un de nos spécialiste des licences JetBrains .