Now’s the time to switch to Visual Studio 2019 (VS 2019).
Check out my video that was recorded at our Visual Studio 2019 event and get a crash course on the new features of VS 2019.
I recommend watching the full video (above) for an in-depth explanation of Visual Studio 2019 features. If you’re looking for some highlights of what I consider to be the major features and changes, see below.
What are the New Features?
Convert to Interpolated String
You can right-click (Ctrl+.) on the format method and convert it to interpolated string because it’s easier to read, assuming you’re not doing localization.
Renames at the csprog Level
Finally! You can rename your application, and it automatically changes the Assembly Name and Default namespaces in the project properties.
It doesn’t change the source code; it just changes the project file renders inside the Project Properties Window in Visual Studio.
*Note – It does not update resource files either. All other namespaces stay the same.
Document Health Indicator
There’s now an indicator of how good your source code is doing. It appears in a couple of places, and you can navigate between the warnings.
There’s a new dropdown for code cleanup that you can configure. You would think that it would be extensible. It will be, but it isn’t available right now.
New Search Feature
It now searches all the variables accessed through the debugger and finds the value entered. It’s navigating through the hierarchy of the data in either autos, locals or the watch window.
It seems like a minor feature, but it’s a cool addition and an incredibly efficient way to find the required value.
You can now add a null check automatically as your values come in. This check is critical because the nullability feature in C# 8 only expresses your intent. It does NOT actually make any changes to verify that you do not have Null, so this is a valuable check to run.
It’s now expanding into multiple resources, including the installer, and it indexes all of them.
If you want to search within install, you can now search by individual components, and it will pull up all the tools related to your search.
Visual Studio Installer Includes Side by Side Installs
You can work on bleeding-edge or older versions. Appropriately, they will go into different directories that can be updated however you need.
This flexibility now includes customizing multiple dot releases so that you can work on projects for various customers within the version that they request.
*Note – Visual Studio installs with the Azure Powershell module, and that has been updated to the AZ module. Those are not compatible with each other, so be sensitive to what you’re installing.
You can control whether your environment color theme is dark or light. The easiest way to do this is to enter “theme” in the Search (Ctrl+q).
The project/solution is significantly faster. When there is a delay, a tip appears indicating that loading will continue in parallel, but you can begin coding.
If you have large projects, you can save a subset using .slnf files (Unfortunately, dotnet CLI doesn’t read this file at the time of this writing).
It has been available for a while, but what’s interesting now is that if you don’t have Docker installed and would like to, it will walk you through the installation process. Of course, after installation, it will allow you to debug within a Docker container, allowing for cross-platform debugging.
You’ll be prompted to install the “visx” package, however, do so with caution as it only works in the Visual Studio UI, not on the command line.
Instead, I recommend installing the code analysis packages. Be careful when you search for analyzers as there are several. Always read to confirm it’s what you’re looking for. At IntelliTect, we install IntelliTectAnalyzers, which in turn pulls in additional analyzers that we have dependencies on.
Interaction with Git has been improved.
Emojis can now be embedded in your source code.
Check out this blog for a deeper dive into pull requests.
Time Travel Debugging (TTD)
If you run windbg, it will launch TTD that will allow you to debug unmanaged code on your machine and will save the entire dump of the file. It’s a great feature if you have a hard to find bug.
Want more on TTD? Click here.
Test Explorer – My Favorite Feature
I’m a little biased, but I’m excited about what’s now available in the test explorer. The entire UI has been rewritten. You can now:
- Run tests after build
- Run tests in parallel
- Analyze code coverage for all tests
- Select a box in Azure DevOps to reject a build if code coverage drops, and you can make sure all new code coming in has unit tests associated with it
*Bonus – There is a new keyboard shortcut. Control-RL will rerun your tests as you modify your code.
Nullable Reference Types
In C# 8, a string type can be configured to not null by default unless it’s decorated with a nullability operator. However, if Microsoft took your existing code and changed all of the reference types to be not null by default, then there’s a good chance it wouldn’t compile.
To avoid such broken code, you need to opt in to the nullability feature by setting a Nullability element to “enable” within your csproj.
Rather than enabling your entire project for nullability, you can also pinpoint the functionality to a block of code.
Want more on C# 8 features before you move on? Check out this video from my talk at the Spokane .NET Users group.
Where is Visual Studio Headed?
I know of at least two teams that are trying to look at data of reported bugs and associate that data with their fixed bugs so that they can determine patterns to fix future bugs through machine learning.
Intellisense utilizes C# 7 or 8 features to alert you to potential bugs.
That was just a taste of the new features of Visual Studio 2019 (and there were more on the full video). Click here for a blog by Microsoft MVP, Kevin Bost called Debugging like a Pro in Visual Studio.
Also, here’s the link to all the code for IntelliTect’s Visual Studio 2019 event.
Have a question? Ask me in the comments.