-
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 throw expressions #22015
Comments
What makes the |
@svick It's not special but it setting a breakpoint on |
Since similar feature request have been made previously I have filed a more general issue to track feature of placing breakpoint on an arbitrary expression: #22016. I would not hold my breath though expecting this feature to be implemented any time soon. |
@svick The @tmat I'm not nearly as interested in the general feature. Setting breakpoints on Long-standing debugging experience with argument validation and real-world projects leads me to classify |
@tmat I'm reopening this. Exceptions represent a special case in flow control which result in leaving a method. We don't need the general ability to set breakpoints in subexpressions, but we need the ability to set breakpoints on a throw expression. |
i agree with sam. It seems like we just need this on throw-expressions. I'm curious what level of hte stack would be blocking this. Is it just the IDE side? Or are we not creating hte right PDB information in order to actually do this properly in the debugger? |
The PDB, EnC, maybe JIT, since C# has never emitted sequence points for non-statements, so it's not tested. |
I'd be surprised if the pdb/jit cared. There's no actual difference at the IL/jit level for throw expressions/statements right? i mean, we're just going to convert if (x == null)
{
throw y;
} as far as the rest of the system is concerned. Right? |
@CyrusNajmabadi The stack might not be empty:
|
I don't quite understand. Isn't that just: var __temp1 = G();
if (!x) { throw expr };
F(__temp1, y); ? |
No, we don't do stack spilling. class C
{
static string F(string a, string b, string c) => a;
public static void Main()
{
string a = "1";
string b = "2";
string c = "3";
F(
a ?? throw new Exception(),
b ?? throw new Exception(),
c ?? throw new Exception()
);
}
} Compiles to
|
Version Used: 15.2
Steps to Reproduce:
Add the following code
Add a breakpoint which breaks into the debugger immediately before a call to
new ArgumentNullException("a")
Add a breakpoint which breaks into the debugger immediately before a call to
new ArgumentNullException("b")
Expected Behavior:
The debugging experience is not impaired by a decision to use
throw
expressions to simplify code.Actual Behavior:
The debugging experience is substantially impaired:
b
being null requires a conditional breakpoint with a manually-typed condition. It used multiple UI elements, further disrupting the workflow of a user attempting to add it.b
being null is very slow to evaluate compared to the unconditional breakpoint used fora
being null.The text was updated successfully, but these errors were encountered: