-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Allow setting breakpoints on expressions #22016
Comments
📝 Related to #21781. |
Permitting breakpoints in the when clause and expression parts of a switch expression is a fairly simple change. |
💯 Without the ability to set breakpoints developers will be shunning expressions. We already see expressions being undone because they make debugging so much harder. |
I've avoided object initializer in the past already because they destroy line numbers in stacktraces, expression switch cases make this so much worse, i've basically banned them for anything that does a method call or could possible generate an exception. I hope this is adressed very soon. |
Addressed in #42711 |
Is there a summary of where to expect the additional sequence points to show up? So far I know about switch expressions. Does it go as far as conditional expressions, object initializers, |
Currently only switch expressions. We will need to discuss what other expressions we want to support because for other expressions it will degrade code quality. For the debugging experience, the parts of the expression will act just like statements. |
One side benefit of more granular expression sequence points is that code coverage tools will begin to recognize conditional expressions and short-circuiting operators as branches. Many (all?) of them depend on debugger sequence points because that's the only mapping from IL to source code. There are two distinct things I'd really love:
Is #21781 the issue to follow for both of these? |
Recursive patterns are not expressions. Order of evaluation is not guaranteed, and in a switch the order is nonlinear (we don't re-evaluate patterns that were previously evaluated for other branches). I do not expect sequence points within patterns. The other places we can do, at the cost of reduced code quality. I don't know yet which ones we actually will do. #21781 hasn't been designed yet, and nobody's currently working on it, so I can't say what would result from work on that. |
Thanks. Should I file an issue or multiple issues for the ones I want to follow (conditional expression, |
@jnm2 Yes, please. I think for those expressions a single issue would make sense. The other one we are considering is object initializers, but we don't have an issue tracking that yet. |
Actually, would #27184 be the issue for object initializers now? |
@gafter Is there any point in me generating such a description, or do you have an idea of how you'd like it to be either way? |
Currently we only allow setting breakpoints on sequence points and those are limited to IL offsets where the evaluation stack is empty.
As C# gets more expression oriented it would be very useful to be able to place breakpoint on an arbitrary expression.
Implementing such a feature is certainly not gonna be cheap as it might require changes across many layers and components.UPDATE: Turns out we were able to find out an inexpensive technique how to achieve this.
The text was updated successfully, but these errors were encountered: