Visual Studio debugging gets cleaner in .NET 8

Posted: (EET/GMT+2)

 

If you spend a lot of time in the Visual Studio debugger, .NET 8 includes some welcome improvements in how values are shown.

Microsoft recently published a detailed overview of the new debugging enhancements coming in .NET 8, with a focus on making commonly used ASP.NET Core types easier to inspect while debugging.

One common complaint when debugging web applications is that objects such as HttpContext, HttpRequest and HttpResponse contain so much information that finding the interesting values can take many clicks.

In .NET 8, these types now provide cleaner debugger views and summaries. Important values such as URLs, headers, query strings, cookies, and response status codes are easier to locate without drilling through multiple levels of properties.

For example, when stopped at a breakpoint:

app.MapGet("/", (HttpContext context) =>
{
    return Results.Ok();
});

The debugger now presents a much more useful summary of the HTTP request than previous releases. Another area that received attention is WebApplication. When debugging startup code, the debugger can now display useful information such as configured endpoints, middleware, and configuration values directly from the object view.

WebApplication app = builder.Build();

This makes it easier to verify application configuration without expanding dozens of internal framework objects.

ASP.NET Core MVC and Razor Pages also benefit from cleaner debugger output. Microsoft reviewed many framework types and removed or hid non-essential details, making controllers, views, and Razor Pages easier to inspect during development.

Tip: none of the underlying information has been removed. If you still need to inspect the complete object graph, the debugger's Raw View remains available.

While this is not a headline feature like performance improvements or new language features, it is the kind of enhancement that can save time every day when troubleshooting ASP.NET Core applications.