The investments being made by Microsoft to enhance the tooling and improve the experience for its developers keep on coming this year. Just when you think they’ve put the lid on Visual Studio 2019 and shift their focus to the new version they surprise us with numerous new features and enhancements.
The .NET Productivity team (aka. Roslyn) continues to enhance your developer productivity with the latest tooling updates in Visual Studio 2019.
Mika Dumont, Product Manager for .NET productivity
In this article we are going to cover what I consider to be the most impactful to the developer community and frankly features that should have been in the IDE years ago.
Removing Unused References
As projects grow and direction changes, many unused and forgotten project or package references are left scattered throughout your code. In the past, developers were left to remove these references manually as they ran into them. That is no more, now we are given the ability to remove unused references across entire projects with a single click. Doing so helps reclaim wasted space, as well as improve the overall performance of the resultant application as well as the project itself within Visual Studio.
Automatically Added Using Directives
We undoubtedly reuse code in our work, whether from our own previous work or from help we got from others on the internet. Pasting code is a very real part of the development process. Now Visual Studio will automatically add any missing using directives when code is pasted into your files. Previously a missing using directive error would be displayed and it was up to developers to add the missing references manually, now that is a thing of the past. This feature is not turned on by default, but taking advantage of it is very easy! You can enable it by opening Visual Studio then going to Tools > Options > Text Editor > C# or Basic > Advanced and select Add missing using directives on paste.
As Blazor becomes a first class citizen in the .NET ecosystem, so does the functionality of the Visual Studio when it comes to MVC, Razor Pages and Blazor. Improvements to IntelliSense for MVC and Razor Pages had improved through out the years, but the arrival of Blazor has really pushed Razor forward. Now developers are getting support for Find All References even in closed Razor files. Razor intrinsic completions along with various improvements to stability and performance when working with large MVC, Razor or Blazor projects.
I have personally suffered from Visual Studio unreliability issues when working on large MVC projects. Broken IntelliSense across views, crashed instances and random slow downs both while coding and debugging. To enable this new feature you must go to Tools > Options > Environment > Preview Features > select Enable experimental Razor editor, followed by a restart of Visual Studio.
For a complete list of bug fixes and improvements check out the release notes for the latest version of Visual Studio 2019 or check out this amazing blog post by Mika Dumont.