We had a great summer here at DMC's Chicago office. We got to watch the Air and Water Show at Belmont Harbor, go to the Circus, drink on a boat, and play some beach volleyball. However, for a .NET developer like me the real highlight of the summer was the release of Visual Studio 2015. VS2015 was released officially on July 20th, and over the past several weeks I've gotten a chance to dig into it and explore all of the great new features. This new version of Visual Studio includes many improvements ranging from cross-platform development tools to a major update in the ASP.NET platform. However, the features that I've been enjoying the most are the enhanced debugging and diagnostics tools.
Below are a few tips and tricks that I've learned about debugging in Visual Studio 2015 that I think every developer should know about:
LINQ Expressions in Debug Windows
LINQ expressions now work in debug windows. You may not have been aware of this limitation before, but all previous versions of Visual Studio did not allow for LINQ expressions within debug windows. So for instance if I wanted to do a quick LINQ query in my Watch list to narrow down a list of 100 elements to the few elements that I actually wanted to look at I couldn't. Now I can!
LINQ expressions working great in Visual Studio 2015...
...not so well in Visual Studio 2013.
This was a feature I didn't even know I needed until I had it. PerfTips give you in-line information about the performance of your code as you are stepping through it in the debugger. This makes it very easy to time how long the execution of a block or line of code is taking without having to deal with adding in debug timers and writing to the console. Its super simple and effective. You can also click on the PerfTip to bring up information about events and resource usage related to that PerfTip in the Diagnostics Tools Window.
PerfTips in action. In this case, we can see that it took 5 milliseconds to execute the previous line.
Diagnostic Tools Window
This is a brand new window that is useful for debugging performance issues while your application is running. The Diagnostic Tools Window makes it easy to observe the memory and CPU usage of your application by charting the resource usage on live charts. You can also take snapshots of your applications memory usage in a single click and then compare the snapshots to find memory leaks.
A series of memory snapshots taken in the Diagnostic Tools Window indicates that this program has a memory leak.
Live Visual Tree
Yet another brand new window in VS2015. This tool allows you to explore the visual tree of a XAML window (or HTML document) while the application is running. I've been using tools like WPF Inspector and Snoop in the past to accomplish UI debugging in WPF applications, but I always welcome the opportunity to use an integrated tool. If you are someone who is constantly tweaking user interfaces in XAML and trying to figure out why that MVVM binding isn't working then you should definitely check this out.
The Live Visual Tree lets you explore the live XAML tree and easily trace down the source code for any element.
To learn more about Visual Studio and .NET check out other DMC blog posts or our Custom Software development services.