[C# Debugger] DAP variables request returns empty in ASP.NET Core HTTP request pipeline #2936
Unanswered
odinGitGmail
asked this question in
Extension Development QnA
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Background
I'm developing a VSCode extension to enhance the debugging experience. The original motivation was that VSCode's built-in Debug Console has a limitation: when displaying exception stack traces, clicking on file paths only navigates to the first line of the file, not the specific line number mentioned in the stack trace. This forces developers to manually search for the error location, which is very inconvenient.
My Solution: Custom Debug Window Extension
I created an extension that provides:
Enhanced Stack Trace Navigation
Smart Variable Parsing
Exception Object Parsing
The Problem: Cannot Access Variables in ASP.NET Core WebAPI
When extending the Exception parsing feature, I discovered a critical limitation:
What Works ✅
What Fails ❌
Technical Details
Environment
DAP API Behavior
In Console Applications (✅ Works):
// Scopes request
{ "scopes": [{ "name": "Locals", "variablesReference": 1008 }] }
// Variables request
{ "variables": [
{ "name": "ex", "type": "System.Exception", "value": "...", "variablesReference": 1009 },
{ "name": "result", "type": "bool", "value": "true" }
]}
// Evaluate request
{ "result": "{System.Exception: ...}", "type": "System.Exception", "variablesReference": 1009 }In WebAPI HTTP Request Handling (❌ Fails):
// Scopes request
{ "scopes": [{ "name": "Locals", "variablesReference": 1008 }] }
// Variables request (EMPTY despite non-zero reference!)
{ "variables": [] }
// Evaluate request (FAILS)
Error: "Evaluation failed."### What I've Tested
Through extensive testing, I confirmed this is NOT caused by:
The Root Cause
The issue appears to be specific to ASP.NET Core's HTTP request processing pipeline:
Comparison Test Results:
Questions for the Community
Is this a known limitation of the C# debugger in ASP.NET Core's HTTP pipeline?
Why does the Debug Console work while DAP API fails?
Is there a workaround to access variables via DAP in this scenario?
Should I file this as a bug in the C# debugger repository, or is this expected behavior?
Current Workaround
For now, I guide users to use the built-in Debug Console (
Ctrl+Shift+Y/Cmd+Shift+Y) when debugging WebAPI projects, as it's not affected by this limitation. However, this means users lose the enhanced features my extension provides (smart variable parsing, table views, clickable stack traces with line numbers).Repository
If helpful, I can provide a minimal reproduction repository demonstrating the issue.
Any insights or suggestions would be greatly appreciated! 🙏
Beta Was this translation helpful? Give feedback.
All reactions