Finally Snapshot Debugger tool is now ready for the Production, it’s a tool that enables you to debug web apps running in production in Azure. With the latest Visual Studio 2017 Enterprise 15.5 you can make use of that tool.
I am sure many developers might have come across a scenario in which it’s very tough to debug an application and that’s the reason we use logs. But many times digging logs is very tough and painful and many times you won’t be able to reproduce the issue in Local Environment. Snapshot Debugger comes as a saviour in such scenario. The Snapshot Debugger enables a safe, non-invasive way for you to use the Visual Studio debugger you know and love directly against the production environment in Azure where the issue is happening.
Just like in memory profiler we take the snapshot of the particular state of our application, Snapshot Debugger works very much similarly. Here Snapshot debugger takes a snapshot of the state of your app at specified lines of code where you set Snappoints. While traditional breakpoints would halt your live server when hit and stop it from serving requests; Snappoints quickly capture state, including locals, watches, and the call stack while your app continues to run. This means that you can debug the actual live, running app, without impacting the experience your customers have while using the app.
Below is the GIF file which Microsoft released showing how to use Snappoints.
Best part of Snapshot debugging is that, it has no performance impact on the application
Behind the Scene
As per Microsoft, Snapshot debugger intelligently captures state where you have pin pointed your snappoints. When snappoint is placed Debugger forks your app’s process and suspends the forked copy, creating a snapshot. You then debug against this snapshot, which sits in-memory on your server. The snapshot is not a copy of the full heap of the app – it’s only a copy of the page table with pages set to copy-on-write. The Snapshot Debugger only makes copies of pages in your app if the page gets modified, minimizing the memory impact on your server. In total, your app will only slow down by 10-30 milliseconds when creating snapshots.
You can try out Snapshot debugger in Visual Studio 2017 Enterprise version 15.5 and greater. Currently, the Snapshot Debugger supports ASP.NET and ASP.NET Core apps running in Azure App Services. For more details you can read at official visual studio blog.
Microsoft released .Net API Analyzer which are of great use for writing/porting the cross platform code.
Many times you might have encountered that the function which you have written in Windows might not work in Linux, also many times APIs get deprecated. The API Analyzer is a Roslyn (remember Roslyn is the name of the C#/.NET compiler) analyzer that's easily added to your project as a NuGet package. All you have to do is add it and you'll immediately start getting warnings and/or squiggles calling out APIs that might be a problem.
Below is the console app which I have created and added the analyzer NuGet package in that.
Now I will use only Windows specific API which won't work on any other platform
Now build the application, and you will get detailed warning about the API that doesn't work everywhere.
You can even watch the YouTube video by Olio from .NET team, which shows API Analyzer and how it works.