Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Debugger.Break() to Debug.Assert #15024

Open
BrennanConroy opened this issue Mar 3, 2025 · 2 comments
Open

Add Debugger.Break() to Debug.Assert #15024

BrennanConroy opened this issue Mar 3, 2025 · 2 comments
Labels
future Improvements which can be done in future and need team triage up-for-grabs

Comments

@BrennanConroy
Copy link
Member

Running tests via command line, or running a program (not testing) will crash the process if a Debug.Assert condition fails, and it will pause the debugger if running under one. Both of these behaviors are what I expect and want. However, when running tests via VS testing the Debug.Assert just throws an exception. Which depending on the test could silently pass.

I see #2309 which is when this behavior changed. And while I still think the process should crash when not running under the debugger, I think at a minimum it should break under the debugger so you can see that one of your debug checks is failing.

See https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebugProvider.Unix.cs,18 for example.

@nohwnd nohwnd added up-for-grabs future Improvements which can be done in future and need team triage labels Mar 4, 2025
@nohwnd
Copy link
Member

nohwnd commented Mar 4, 2025

I would love this to be implemented as exception and also a "note" to the test framework that the test failed even if the exception is swallowed. In retrospect the design implemented was not the best.

@nohwnd
Copy link
Member

nohwnd commented Mar 4, 2025

but this needs to be implemented on each test framework level, so we cannot do anything about it here, except for adding an option to disable the Assert failure captuing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
future Improvements which can be done in future and need team triage up-for-grabs
Projects
None yet
Development

No branches or pull requests

2 participants