{"id":147240,"date":"2021-05-31T16:50:11","date_gmt":"2021-05-31T15:50:11","guid":{"rendered":"https:\/\/blog.jetbrains.com\/?post_type=dotnet&#038;p=147240"},"modified":"2021-06-03T22:56:29","modified_gmt":"2021-06-03T21:56:29","slug":"resharper-2021-2-eap","status":"publish","type":"dotnet","link":"https:\/\/blog.jetbrains.com\/zh-hans\/dotnet\/2021\/05\/31\/resharper-2021-2-eap","title":{"rendered":"ReSharper 2021.2 Starts Its Early Access Program!"},"content":{"rendered":"\n<p>Hello everyone,<\/p>\n\n\n\n<p>We\u2019ve just started the <a href=\"https:\/\/www.jetbrains.com\/resharper\/nextversion\/\" target=\"_blank\" rel=\"noopener\">Early Access Program for the ReSharper 2021.2<\/a> release cycle! Let\u2019s look at what the first EAP build has in store.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"jetbrains.com\/resharper\/nextversion\/\"><img decoding=\"async\" loading=\"lazy\" width=\"1600\" height=\"800\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/05\/image-18.png\" alt=\"\" class=\"wp-image-147447\"\/><\/a><\/figure>\n\n\n\n<p>In case you missed that, starting with the 2021.2 EAP builds of our .NET productivity tools, including ReSharper, we will require .NET Framework 4.7.2 or newer installed on your machine. Learn more <a href=\"https:\/\/blog.jetbrains.com\/zh-hans\/dotnet\/2021\/04\/26\/resharper-and-rider-2021-2-will-require-net-framework-4-7-2-on-windows\" class=\"ek-link\"><a href=\"https:\/\/blog.jetbrains.com\/zh-hans\/dotnet\/2021\/04\/26\/resharper-and-rider-2021-2-will-require-net-framework-4-7-2-on-windows\">here<\/a><\/a>.<a href=\"https:\/\/www.jetbrains.com\/resharper\/nextversion\/\" target=\"_blank\" rel=\"noopener\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code Analysis<\/h2>\n\n\n\n<p>Do you still use temporary variables to swap variable values? There is a more elegant way! ReSharper 2021.2 EAP will help you modernize your code with the new <em>Swap via deconstruction<\/em> quick-fix!<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/05\/swap-2x.png\" data-gif-src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/05\/image-1.gif\">\n\n\n\n<p>There are two new useful inspections that come with the corresponding quick-fixes:<\/p>\n\n\n\n<ul><li>Replace empty array creation with <code>Array.Empty&lt;T&gt;<\/code> (or with <code>Type.EmptyTypes<\/code> in case of <em>new <\/em><code>System.Type[0]<\/code>).<\/li><li>Replace <code>new EventArgs()<\/code> with <code>EventArgs.Empty<\/code><em>.<\/em><\/li><\/ul>\n\n\n\n<p>ReSharper 2021.2 EAP respects the <em>generated_code<\/em> property from your <em>.editorconfig<\/em> file, allowing you to specify which files to ignore in its code analysis.<\/p>\n\n\n\n<p>Code Analysis is getting a couple of performance improvements:<\/p>\n\n\n\n<ul><li><em>Find similar issues<\/em> now provides its results faster. This is because ReSharper no longer runs analyses that are irrelevant for the corresponding highlighting\/inspection.&nbsp;<\/li><li>We\u2019ve sped up a code analysis for large and complex <code>switch<\/code> statements and <code>switch<\/code> expressions by caching\/sharing the data needed for different inspections.<\/li><\/ul>\n\n\n\n<p>Last but not least in this section, we\u2019ve got good news for our VB.NET developers! ReSharper now supports code generated by source generators in VB.NET.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Nullable reference types&nbsp;<\/h2>\n\n\n\n<p>We are improving our support for nullable reference types (NRT) and updating some actions accordingly.<\/p>\n\n\n\n<p>If you use NRT, you may have noticed that an action to use explicit types instead of <code>var<\/code> always produces a nullable variable. Although that is correct, <code>var<\/code> being nullable is an implementation detail of the compiler, and using a nullable type might be confusing if developers never store nullable values in it.<\/p>\n\n\n\n<p>Starting from this EAP build, ReSharper checks whether the variable needs to be nullable, and it will produce a stricter type when possible.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/05\/nrt-strict-2x.png\" data-gif-src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/05\/image-2.gif\">\n\n\n\n<p>As you adopt nullable reference types, you might use some nullable warning suppressions that are no longer needed, since the suppressed expression is no longer nullable. ReSharper will help you find such suppressions and remove them.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/05\/nrt-redundant-supression.png\" data-gif-src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/05\/image-3.gif\">\n\n\n\n<p>Finally, sometimes we may be too optimistic about some code and suppress an actual problem, thinking it&#8217;ll never happen. When this does eventually happen, it&#8217;s very hard to backtrack such suppressions, since <code>!<\/code> is a very common symbol in source code. If you want to investigate where <em>nullability<\/em> contracts are violated with suppressions in your solution, you can now enable a new inspection, <em>A suppressed nullable warning might hide an underlying problem<\/em>, to find every suppression without having to dig through all other usages of the <code>!<\/code> symbol. The inspection can be found in the ReSharper settings. And it will not be triggered by default, since suppressions are a completely valid way to prevent the compiler from nagging you about complex code that it cannot analyze.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Navigation&nbsp;<\/h2>\n\n\n\n<ul><li>While debugging, calling <em>Go To Declaration<\/em> (or <kbd>Ctrl<\/kbd>+<kbd>Click<\/kbd>) on interface references will navigate you directly to the implementations.<\/li><li>The <em>Go To Base\/Inheritors<\/em> list shows hidden overrides, as well.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1600\" height=\"700\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2021\/05\/image-19.png\" alt=\"\" class=\"wp-image-147503\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Code Styling and Formatting<\/h2>\n\n\n\n<ul><li>We\u2019ve changed the default formatting preferences to align with the Visual Studio defaults. Learn more at <a href=\"https:\/\/youtrack.jetbrains.com\/issue\/RSRP-479702\" target=\"_blank\" rel=\"noopener\">RSRP-479702<\/a>.<\/li><li>Support for <a href=\"https:\/\/en.wikipedia.org\/wiki\/Indentation_style#Pico_style\" target=\"_blank\" rel=\"noopener\">Pico brace (indenting) style<\/a> is here.<\/li><li>It\u2019s now possible to specify advanced naming rules for <code>records<\/code>, extension methods, and <code>catch<\/code> variables.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Razor<\/h2>\n\n\n\n<p>Razor developers working on large views can turn off the CPU-intensive assistance and automatic suggestions if their editor begins to lag. You can find the settings here: <code>ReSharper | Options | Environment | Editor | Behavior | Razor | Allow CPU-intensive typing assist<\/code>.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ReSharper C++<\/h2>\n\n\n\n<ul><li>New&nbsp;modernizing inspections:&nbsp;<em>Structured binding can be used instead of&nbsp;<\/em><code><em>tie(..)<\/em><\/code>&nbsp;and&nbsp;<em>Type trait can be simplified using a template alias or a variable template<\/em>.<\/li><li>Improved&nbsp;generation of function definitions: configurable default function body and automatic insertion of the call to the overridden function.<\/li><li>Clang-Tidy 12.<\/li><li>Support for the new&nbsp;compiler switches&nbsp;from Visual Studio v16.10.<\/li><\/ul>\n\n\n\n<p>For more information, please refer to&nbsp;<a href=\"https:\/\/blog.jetbrains.com\/zh-hans\/rscpp\/2021\/05\/31\/resharper-cpp-2021-2-eap1\" class=\"ek-link\">this blog post<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ReSharper Command Line Tools&nbsp;<\/h2>\n\n\n\n<p>The InspectCode tool restores NuGet packages and builds a solution before starting the analysis.<\/p>\n","protected":false},"author":307,"featured_media":147755,"comment_status":"closed","ping_status":"closed","template":"","categories":[4992,826,907],"tags":[4702,737,1914,2017],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/dotnet\/147240"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/dotnet"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/types\/dotnet"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/users\/307"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/comments?post=147240"}],"version-history":[{"count":9,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/dotnet\/147240\/revisions"}],"predecessor-version":[{"id":148733,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/dotnet\/147240\/revisions\/148733"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media\/147755"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media?parent=147240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/categories?post=147240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/tags?post=147240"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/cross-post-tag?post=147240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}