Visual Studio 2019 .NET productivity
Your friendly neighborhood .NET productivity team (aka. Roslyn) focuses a lot on improving the .NET coding experience. Sometimes it’s the little refactorings and code fixes that really improve your workflow. You may have seen many improvements in the previews, but for all of you who were eagerly awaiting the GA release here’s a few features you may enjoy!
I’m most excited about the new Roslyn classification colors. Visual Studio Code colors received high praise so we incorporated similar color schemes into Visual Studio. Your code editor is now just a little more colorful. Key words, user methods, local variables, parameter names, and overloaded operators all get new colors. You can even customize the colors for each syntax classifications in Tools > Options > Environment > Fonts and Colors and scroll to ‘User Members’.
At the bottom of files in your editor are the document health indicators as well as our code cleanup icon. The document health indicators let you know at a glance how many errors and warnings are present in the file you currently have open. You can click on the code cleanup icon to apply code style rules specified in Tools > Options or, if you have an editorconfig file that shares one code style across your team, it will apply styles specified in that file.
You can edit sdk-style project files with a simple double-click! You can also view these project files with preview in GoToAll (Ctrl+t) navigation and search the contents for file references.
Load a subset of projects in your solution with filtered solutions! You can now unload projects and save a .slnf file that will only open the projects you specified. This helps you get to the code you are interested in quickly without needing to load an entire solution.
Find all references categorizes by reference type. You can filter by read/write in the new ‘Kind’ column in the find all references window.
Run code style formatting over the entire solution at the command-line with the `dotnet format` global tool.
Now the omnibus of new code fixes and refactorings!
Foreach to LINQ
Add missing reference for unimported types
Sync namespace and folder name
Invert conditional expressions
Pull members up dialog for promoting members to an interface
Remove unused expression values and parameters
This is a set of highlights of what’s new in Visual Studio 2019, for a complete list see the release notes. As always, I would love your feedback via twitter, on GitHub, or in the comments section below. Also, one important thing to note is that to use .NET Core 3.0 Preview you will need to download and install the SDK, it is not included with the Visual Studio 2019 installer yet.
Hi Kendra, thanks for the great detailed article. In one of the GIFS you have a terminal window opened. How did you get that? Also looks like it’s a power shell window. Thanks.
It looks like Whack Whack Terminal extension
You are correct!
Hi Kendra, is the code refactoring (like ‘Convert foreach loop to LINQ’ and ‘Convert anonymous type to tuple’) available in the Community Edition? I’ve just downloaded the release version of CE, and I cannot get these ‘Quick Actions’ to be available 🙁
Yes, these are in the community edition. Make sure your cursor is in the “foreach” keyword and it is iterating through an Enumerble. You can follow the doc here: https://docs.microsoft.com/en-us/visualstudio/ide/reference/convert-foreach-linq?view=vs-2019
Thanks Kendra. Its working for me now. Not sure what I was doing wrong.
Any way to change back the colors? Im not a huge fan of the new text colors. Too many distracting colors.
Sure! You can uncheck the option in Text Editor > CSharp > Advanced > Use Enhanced Colors for C# and Basic.
There is an issue that once you disable it, it cannot be reenabled. Disabling the future will permanently change ApplicationPrivateSettings.xml and it cannot be restored by checking the option later. One has to copy over the default settings from another profile manually.
Agreed… the new colors look like someone dipped my code into a bowl of Froot Loops. I thought that it was a bug with ReSharper and had to hassle their team over it. They, in turn, pointed me to this article to fix. https://youtrack.jetbrains.com/issue/RSRP-474615
Silly question: I’ve noticed you moved from GIF to incorporated videos. Any tip about tools you use to record such videos? Could be very helpful to incorporate such media in our documentation website
No silly questions! 🙂 I am a big fan of Snaggit for gifs. I’m not great at using Camtasia yet, but I plan on learning!
ShareX is also a great way to record your screen thats free, opensource and made with .NET
Could you please consider improving intellisence when adding package reference, like a list of packages and then available versions. This is now available as project tools extension but IMHO must have as we’re adding refrences manually via project file these days.
Hi Kendra, thanks for the great detailed article. The VisualStudio can help us to change the class name to match the file name. But can VisualStudio help to rename the file to match the class name?
Love the wrap all parameters automation which is something I spend I lot of time doing manually. What I don’t like is that you can no longer create temporary projects in VS2019 for testing out new features or learning a new feature. This is a significant productivity hindrance for me as well as for the developer community overall.