{"id":26941,"date":"2020-03-24T10:25:31","date_gmt":"2020-03-24T17:25:31","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet\/?p=26941"},"modified":"2020-03-24T07:43:28","modified_gmt":"2020-03-24T14:43:28","slug":"catch-up-on-the-latest-net-productivity-features","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/catch-up-on-the-latest-net-productivity-features\/","title":{"rendered":"Catch up on the latest .NET Productivity features"},"content":{"rendered":"<p>The Roslyn team continuously works to provide tooling that deeply understands the code you are writing in-order to help you be more productive. In this post, I&#8217;ll cover some of the latest .NET Productivity features available in <a href=\"https:\/\/visualstudio.microsoft.com\/downloads\/\">Visual Studio 2019<\/a>.\n<\/br><\/p>\n<h3>Tooling improvements<\/h3>\n<p>The feature that I&#8217;m most excited about is the new <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/ide\/navigating-code#go-to-base\">Go To Base<\/a> command. <strong>Go To Base<\/strong> allows you to easily navigate up the inheritance chain. The command is available on the context (right-click) menu of the element that you want to navigate the inheritance hierarchy. Or you can press <strong>Alt+Home<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/GoToBaseFinal.png\" alt=\"Go To Base\" width=\"1044\" height=\"591\" class=\"aligncenter size-full wp-image-26940\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/GoToBaseFinal.png 1044w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/GoToBaseFinal-300x170.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/GoToBaseFinal-1024x580.png 1024w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/GoToBaseFinal-768x435.png 768w\" sizes=\"(max-width: 1044px) 100vw, 1044px\" \/><\/br><\/p>\n<p><strong>Find All References<\/strong> now categorizes the results by type and member. You can group by type and member in the <strong>Find All References<\/strong> window.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/FAR-Membr-Type.png\" alt=\"Find All References \" width=\"1925\" height=\"591\" class=\"aligncenter size-full wp-image-26943\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/FAR-Membr-Type.png 1925w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/FAR-Membr-Type-300x92.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/FAR-Membr-Type-1024x314.png 1024w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/FAR-Membr-Type-768x236.png 768w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/FAR-Membr-Type-1536x472.png 1536w\" sizes=\"(max-width: 1925px) 100vw, 1925px\" \/>\n<\/br><\/p>\n<h3>Code fixes and refactorings<\/h3>\n<p>Code fixes and refactorings are the code suggestions the compiler provides through the light bulb and screwdriver icons. To trigger the <strong>Quick Actions and Refactorings<\/strong> menu, press (<strong>Ctrl<\/strong>+<strong>.<\/strong>) or (<strong>Alt<\/strong>+<strong>Enter<\/strong>). Below are the code fixes and refactorings that are new in Visual Studio 2019:<\/br><\/p>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/ide\/reference\/extract-local-function\">extract local function<\/a> refactoring allows you to turn a fragment of code from an existing method into a local function. Highlight the code that you want extracted. Press <strong>Ctrl<\/strong>+<strong>.<\/strong> to trigger the <strong>Quick Actions and Refactorings<\/strong> menu and select <strong>Extract local function<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/extract-local-function.png\" alt=\"Extract Local Function\" width=\"943\" height=\"445\" class=\"aligncenter size-full wp-image-26944\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/extract-local-function.png 943w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/extract-local-function-300x142.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/extract-local-function-768x362.png 768w\" sizes=\"(max-width: 943px) 100vw, 943px\" \/><\/br><\/p>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/ide\/reference\/make-member-static\">make members static<\/a> code fix helps improve readability by making a non-static member static. Place your cursor on the member name. Press <strong>Ctrl<\/strong>+<strong>.<\/strong> to trigger the <strong>Quick Actions and Refactorings<\/strong> menu and select <strong>Make static<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/make-member-static.png\" alt=\"Make Member Static\" width=\"936\" height=\"383\" class=\"aligncenter size-full wp-image-26945\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/make-member-static.png 936w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/make-member-static-300x123.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/make-member-static-768x314.png 768w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/br><\/p>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/ide\/reference\/simplify-string-interpolation\">simplify string interpolation<\/a> refactoring simplifies <a href=\"https:\/\/docs.microsoft.com\/dotnet\/csharp\/tutorials\/string-interpolation\">string interpolations<\/a> to be more legible and concise. Place your cursor on the string interpolation. Press <strong>Ctrl<\/strong>+<strong>.<\/strong> to trigger the <strong>Quick Actions and Refactorings<\/strong> menu and select <strong>Simplify interpolation<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/simplify-string-interpolation.png\" alt=\"Simplify String Interpolation\" width=\"976\" height=\"361\" class=\"aligncenter size-full wp-image-26966\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/simplify-string-interpolation.png 976w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/simplify-string-interpolation-300x111.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/simplify-string-interpolation-768x284.png 768w\" sizes=\"(max-width: 976px) 100vw, 976px\" \/><\/br><\/p>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/ide\/reference\/convert-if-statement-to-switch-statement-or-switch-expression\">convert if statements to switch statements or switch expressions<\/a> refactoring enables an easy transition between if statements and switch statements or expressions. Press <strong>Ctrl<\/strong>+<strong>.<\/strong> to trigger the <strong>Quick Actions and Refactorings<\/strong> menu and select <strong>Convert to &#8216;switch&#8217; statement<\/strong> or <strong>Convert to &#8216;switch&#8217; expression<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/convert-if-to-switch-expression.png\" alt=\"Convert if to switch statement or expression\" width=\"1033\" height=\"710\" class=\"aligncenter size-full wp-image-26947\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/convert-if-to-switch-expression.png 1033w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/convert-if-to-switch-expression-300x206.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/convert-if-to-switch-expression-1024x704.png 1024w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2020\/03\/convert-if-to-switch-expression-768x528.png 768w\" sizes=\"(max-width: 1033px) 100vw, 1033px\" \/><\/br><\/p>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/ide\/reference\/static-local-function-refactor-options#make-local-function-static\">make local function static<\/a> refactoring allows you to make a local function static and pass in variables defined outside the function to the function&#8217;s declaration and calls. Place your cursor on the function name. Press <strong>Ctrl<\/strong>+<strong>.<\/strong> to trigger the <strong>Quick Actions and Refactorings<\/strong> menu and select <strong>Make local function &#8216;static&#8217;<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/Make-Local-Function-Static.png\" alt=\"Make Local Function Static\" width=\"800\" height=\"236\" class=\"aligncenter size-full wp-image-26962\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/Make-Local-Function-Static.png 800w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/Make-Local-Function-Static-300x89.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/Make-Local-Function-Static-768x227.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/br><\/p>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/ide\/reference\/static-local-function-refactor-options#pass-variable-explicitly-in-a-static-local-function\">pass variable explicitly in a local static function<\/a> refactoring gives you flexibility to define variables outside a context, but still be able to pass them in as arguments to the static local function. Place your cursor on the variable within the static local function. Press <strong>Ctrl<\/strong>+<strong>.<\/strong> to trigger the <strong>Quick Actions and Refactorings<\/strong> menu and select <strong>Pass variable explicitly in local static function<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/pass-variable-explicitly-static-local-function.png\" alt=\"Pass Variable Explicitly Static Local Function\" width=\"1146\" height=\"530\" class=\"aligncenter size-full wp-image-26950\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/pass-variable-explicitly-static-local-function.png 1146w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/pass-variable-explicitly-static-local-function-300x139.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/pass-variable-explicitly-static-local-function-1024x474.png 1024w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/pass-variable-explicitly-static-local-function-768x355.png 768w\" sizes=\"(max-width: 1146px) 100vw, 1146px\" \/><\/br><\/p>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/ide\/reference\/add-null-checks-for-parameters\">add null checks for all parameters<\/a> refactoring saves you time by automatically adding if statements that check the nullity of all the nullable, non-checked parameters. Place your cursor on any parameter within the method. Press <strong>Ctrl<\/strong>+<strong>.<\/strong> to trigger the <strong>Quick Actions and Refactorings<\/strong> menu and select <strong>Add null checks for all parameters<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/add-null-checks-for-all-parameters.png\" alt=\"Add Null Checks for All Parameters\" width=\"1200\" height=\"583\" class=\"aligncenter size-full wp-image-26951\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/add-null-checks-for-all-parameters.png 1200w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/add-null-checks-for-all-parameters-300x146.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/add-null-checks-for-all-parameters-1024x497.png 1024w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/add-null-checks-for-all-parameters-768x373.png 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/br><\/p>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/ide\/reference\/introduce-local-variable\">introduce a local variable<\/a> refactoring allows you to immediately generate a local variable to replace an existing expression. Highlight the expression that you want to assign to a new local variable. Press <strong>Ctrl<\/strong>+<strong>.<\/strong> to trigger the <strong>Quick Actions and Refactorings<\/strong> menu and select <strong>Introduce local for<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/introduce-local-variable.png\" alt=\"Introduce Local Variable\" width=\"1018\" height=\"349\" class=\"aligncenter size-full wp-image-26953\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/introduce-local-variable.png 1018w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/introduce-local-variable-300x103.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/03\/introduce-local-variable-768x263.png 768w\" sizes=\"(max-width: 1018px) 100vw, 1018px\" \/><\/br><\/p>\n<h3>Get involved<\/h3>\n<p>This was just a sneak peak of what&#8217;s new in <a href=\"https:\/\/visualstudio.microsoft.com\/downloads\/\">Visual Studio 2019<\/a>. For a complete list of what&#8217;s new, see the <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/releases\/2019\/release-notes\">release notes<\/a>. And feel free to provide feedback on the <a href=\"https:\/\/developercommunity.visualstudio.com\/spaces\/8\/index.html\">Developer Community<\/a> website, or using the <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/ide\/how-to-report-a-problem-with-visual-studio\">Report a Problem<\/a> tool in Visual Studio.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Roslyn team continuously works to provide tooling that deeply understands the code you are writing in-order to help you be more productive. In this post, I&#8217;ll cover some of the latest .NET Productivity features available in Visual Studio 2019. Tooling improvements The feature that I&#8217;m most excited about is the new Go To Base [&hellip;]<\/p>\n","protected":false},"author":5818,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[685],"tags":[],"class_list":["post-26941","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet"],"acf":[],"blog_post_summary":"<p>The Roslyn team continuously works to provide tooling that deeply understands the code you are writing in-order to help you be more productive. In this post, I&#8217;ll cover some of the latest .NET Productivity features available in Visual Studio 2019. Tooling improvements The feature that I&#8217;m most excited about is the new Go To Base [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/26941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/5818"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=26941"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/26941\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=26941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=26941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=26941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}