How to perform 500 identical assignments in Visual Studio’s Immediate window?

Go To StackoverFlow.com

3

I’ve finally managed to reproduce a very elusive bug. I have Visual Studio attached to the process. In order to further debug it, I need to perform the same assignment on roughly 500 elements in a collection, something a bit like this:

for (int i = 0; i < coll.Length; i++)
    coll[i].Something = coll[i].Other;

for isn’t legal in the immediate window, however. Neither is pasting several statements in one go. Is there a way of doing this that doesn’t involve messing around with AutoHotkey and the like?

2012-04-03 19:27
by Roman Starkov
The debugger parser can only parse expressions. Linq expressions work. But you can't use lambdas, that kills it - Hans Passant 2012-04-03 19:46


1

I don't think it is a good idea to do actions like that in the immediate window - you may want to reproduce the bug more than once, so you need that statement above over and over again. Better try to create an automatic test which provides the statement above as part of the test data preparation.

2012-04-03 19:35
by Doc Brown
In order to write the test, I need to figure out what exactly is wrong. In order to figure out what exactly is wrong, I need to perform 500 assigments. Vicious circle.. - Roman Starkov 2012-04-03 20:08
This is where Edit+Continue gets to be really handy - Hans Passant 2012-04-03 20:43
Ads