This is something I’ve often wanted to be able to do while debugging. If I have a line of code which computes a collection inside the header of a foreach loop:
foreach ( var item in someObject.GetItems( someParameter ) ) {
...
}
There doesn’t seem to be anything I can hover over to get the computed set of items returned by GetItems, even though it was clearly computed and returned in order for the loop to be able to execute.
Just seems like something that would be obviously handy. Am I missing something? It’s a pain to have to rewrite the code to store the list in a variable just so I can see it while debugging, especially if I discover a bug that isn’t easily reproducible.
One way is to just add the following expression to the watch window
Hovering won’t work for this scenario but explicitly adding it to the watch window will. There is a lot of care taking in the code which evaluates expressions during hovering to not evaluate functions. The logic being that functions are expensive, can deadlock the IDE and we don’t want a hover operation to cause a deadlock. The
GetItemsportion of this expression is a function evaluation and hence the EE refuses to evaluate it.