-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Describe the Issue
I am trying to debug a test which is exhibiting a debug assertion failure. But simply debugging the test doesn't cause it to break at the point the assertion failed. Instead the test run just finishes without the debugger ever breaking and reports an error.
Steps To Reproduce
dotnet new xunit -o MyRepro; code MyRepro- Insert
Debug.Assert(false);into the test inserted by the template - Go to Debug->Breakpoints menu, ensure that User-Unhandled Exceptions is checked, and All Exceptions is unchecked
- Debug Test at Cursor
Expected Behavior
The test breaks on the Debug.Assert(false) statement.
Actual behavior: the test run fails without the debugger ever breaking.
It seems an uncaught exception is causing the test to fail, so, it seems reasonable to me to classify this as a "user-unhandled exception". It's necessary to retry with All Exceptions enabled to get the debugger to break. Since All Exceptions causes the debugger to break in unwanted places in a complex test, it's necessary to filter All Exceptions to type Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException. (If the program installs its own debug trace listener, it may also be necessary to filter to the particular exception type thrown by that trace listener. For example, InvalidOperationException in Roslyn.)
I am unsure exactly what VS settings are analogous to "disable all exceptions, enable user-unhandled exceptions", but I did note that debugging the same test in VS, with default CLR exception settings, causes the debugger to break on the assertion failure.
Environment Information
C# Extension version: 2.114.6
CDK Extension version: 1.93.20
VS Code version: Code 1.108.2 (c9d77990917f3102ada88be140d28b038d1dd7c7, 2026-01-21T13:52:09.270Z)
OS version: Windows_NT x64 10.0.26100