I'm getting this message in watch box.
Actually, my expression doesn't have any side effect, and I need to re-evaluate it automatically each time. How can I achieve that?
Asked
Active
Viewed 1.5k times
55
-
2The debugger disagrees with you. I'm with the debugger, got nothing else to look at. – Hans Passant Nov 14 '10 at 19:36
-
1@Hans, debugger just doesn't check at all. It only supposes "every method has side effects, every property doesn't". Both is wrong. – fithu Nov 14 '10 at 19:53
-
2This should probably be tagged with C#. The ",ac" modifier in the accepted answer is only valid in that language. Sources: [Format Specifiers in C#](http://msdn.microsoft.com/en-us/library/e514eeby.aspx), [Format Specifiers in C++](http://msdn.microsoft.com/en-us/library/vstudio/75w45ekt.aspx) – jake Jul 31 '13 at 19:12
-
1I have this problem for C++, so if there's a way to supress the message for C++ I would love to hear it! – uglycoyote Oct 31 '17 at 18:34
-
Possible duplicate of [Visual Studio: Make debugger aware that a function doesn't cause "side effects"](https://stackoverflow.com/questions/1049995/visual-studio-make-debugger-aware-that-a-function-doesnt-cause-side-effects) – David Dec 26 '18 at 17:39
1 Answers
87
You can append ,ac
to the watch expression to have it automatically refresh the value
x.ToString(),ac
See http://msdn.microsoft.com/en-us/library/e514eeby.aspx for more information and other format specifiers.
thanks to Scott Visual Studio: Make debugger aware that a function doesn't cause "side effects"
-
7Side note for Googlers: ",ac" is just for C#, not for C++. The return of the usual prodigal son. – Niki Romagnoli Jul 15 '16 at 13:49