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

Allow setting breakpoints on expressions #22016

Closed
tmat opened this issue Sep 10, 2017 · 16 comments
Closed

Allow setting breakpoints on expressions #22016

tmat opened this issue Sep 10, 2017 · 16 comments

Comments

@tmat
Copy link
Member

tmat commented Sep 10, 2017

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.

@sharwell
Copy link
Member

📝 Related to #21781.

@gafter
Copy link
Member

gafter commented Aug 7, 2019

Permitting breakpoints in the when clause and expression parts of a switch expression is a fairly simple change.

@RussKie
Copy link
Member

RussKie commented Jan 28, 2020

💯

Without the ability to set breakpoints developers will be shunning expressions. We already see expressions being undone because they make debugging so much harder.

@Suchiman
Copy link
Contributor

Suchiman commented Feb 8, 2020

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.

@gafter
Copy link
Member

gafter commented Apr 1, 2020

Addressed in #42711

@gafter gafter closed this as completed Apr 1, 2020
@jnm2
Copy link
Contributor

jnm2 commented Apr 2, 2020

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, && operators, etc? Will 'step over'/'step in' apply to nested expressions?

@gafter
Copy link
Member

gafter commented Apr 2, 2020

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.

@jnm2
Copy link
Contributor

jnm2 commented Apr 2, 2020

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:

  • A sequence point for every branching expression, such as a series of && or a recursive pattern
  • 'Step into expression' for non-branching expressions such as object initializers

Is #21781 the issue to follow for both of these?

@gafter
Copy link
Member

gafter commented Apr 2, 2020

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.

@jnm2
Copy link
Contributor

jnm2 commented Apr 2, 2020

Thanks. Should I file an issue or multiple issues for the ones I want to follow (conditional expression, &&, ||, ??), or is there already an issue to follow?

@gafter
Copy link
Member

gafter commented Apr 2, 2020

@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.

@jnm2
Copy link
Contributor

jnm2 commented Apr 5, 2020

@gafter Opened #43092. Should I open an issue for object initializers too?

@jnm2
Copy link
Contributor

jnm2 commented Apr 5, 2020

Actually, would #27184 be the issue for object initializers now?

@gafter
Copy link
Member

gafter commented Apr 6, 2020

@jnm2 Sure, though it would be better if #27184 actually had a description of what it is asking for.

@jnm2
Copy link
Contributor

jnm2 commented Apr 6, 2020

@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?

@gafter
Copy link
Member

gafter commented Apr 14, 2020

@jnm2 It would be great if you would please write a description suitable for the issue asking for breakpoints inside object initializers for #27184.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants