A coworker mentioned Func Eval sounds like "Funky-val".  Stopping at a breakpoint in the middle of a function evaluation could be considered funky.  It is also useful.

 

VS Whidbey allows stopping at a BP or Exception during a function evaluation in C# or VB code.  To use it, you need to do the function evaluation from the 'Immediate Window', rather than the 'Watch', or 'Quick Watch' windows. 

 

Why is nesting restricted to the Immediate Window?  Despite the name, the Immediate window is not immediate.  Watch windows do synchronous Function evaluation.  If the evaluation takes too long, it will timeout and give an error.  That doesn't happen in the immediate window, because it is infinitely patient.  The immediate window is implementing a REPL (Read Eval Print Loop).  However, it doesn't bother to wait for the Eval & Print to finish, instead it executes an asynchronous func eval. The 'Print' is going to happen whenever the Eval gets done, which allows us to do the Nested Break States.  Here's an example:

 

static bool Foo()

{

return false;

}

 

In the immediate window evaluate Foo 3 times:

?Foo()

?Foo()

?Foo()

 

Here is the Callstack:

NestedFuncEval

 

 

When I unrolled the set of Evaluations by hitting F5 three times, here is what I got in the immediate Window:

?Foo()

?Foo()

?Foo()

false

false

true

 

You might ask … why is the last one true?  It's because I used Edit and Continue to change the return value to true before hitting F5 the third time.  Nested Func Eval allows you to literally "push a debug task" on the stack.  Once you've figured out why Foo was doing something wrong you can go back to debugging what you were looking at before.