By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,070 Members | 1,238 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,070 IT Pros & Developers. It's quick & easy.

Why does tsSource[j].Text.ToUpper() causes side effects

P: n/a
I get the following watch message:

tsSource[j].Text.ToUpper() This expression causes side effects and will
not be evaluated string
The Text is &Edit

Do you know what are the side effects?

Thanks
Mar 16 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Sun, 16 Mar 2008 02:45:41 -0400, "Academia" <ac************@a-znet.com>
wrote:
>I get the following watch message:

tsSource[j].Text.ToUpper() This expression causes side effects and will
not be evaluated string
The Text is &Edit

Do you know what are the side effects?
There probably aren't any in this case, but the debugger is not smart enough
to be able to tell - so it prefers to err on the safe side.

Quoting from http://msdn2.microsoft.com/en-us/library/a7a250bs.aspx :

"A side effect occurs when evaluating an expression changes the value of data
in your application.

Side effects are something to watch for if you are evaluating expressions in
the debugger. If you evaluate an expression in the Watch window or the
QuickWatch dialog box and the expression has side effects, you might change
the value of variables in another part of your program without realizing it.
Side effects can make debugging more difficult by creating the appearance of
bugs where none exist or masking the appearance of real bugs.

One common cause of side effects is evaluating a function call in a debugger
window. Such evaluations are usually noticeable. A more subtle cause of side
effects is the evaluation of properties and other implicit function calls in
managed code.

The debugger cannot tell whether a property evaluation or implicit function
call has side effects. Therefore, by default, the debugger does not evaluate
implicit function calls automatically. Property evaluation is allowed by
default, but can be turned off in the Options dialog box. When a function call
or property has not been evaluated, a refresh icon appears. You can manually
evaluate the expression by clicking the refresh icon. For details, see How to:
Refresh Watch Values."

Regards,
Gilles.

Mar 16 '08 #2

P: n/a
Thanks for the help

"Gilles Kohl [MVP]" <no_email_available@wrote in message
news:9o********************************@4ax.com...
On Sun, 16 Mar 2008 02:45:41 -0400, "Academia" <ac************@a-znet.com>
wrote:
>>I get the following watch message:

tsSource[j].Text.ToUpper() This expression causes side effects and will
not be evaluated string
The Text is &Edit

Do you know what are the side effects?

There probably aren't any in this case, but the debugger is not smart
enough
to be able to tell - so it prefers to err on the safe side.

Quoting from http://msdn2.microsoft.com/en-us/library/a7a250bs.aspx :

"A side effect occurs when evaluating an expression changes the value of
data
in your application.

Side effects are something to watch for if you are evaluating expressions
in
the debugger. If you evaluate an expression in the Watch window or the
QuickWatch dialog box and the expression has side effects, you might
change
the value of variables in another part of your program without realizing
it.
Side effects can make debugging more difficult by creating the appearance
of
bugs where none exist or masking the appearance of real bugs.

One common cause of side effects is evaluating a function call in a
debugger
window. Such evaluations are usually noticeable. A more subtle cause of
side
effects is the evaluation of properties and other implicit function calls
in
managed code.

The debugger cannot tell whether a property evaluation or implicit
function
call has side effects. Therefore, by default, the debugger does not
evaluate
implicit function calls automatically. Property evaluation is allowed by
default, but can be turned off in the Options dialog box. When a function
call
or property has not been evaluated, a refresh icon appears. You can
manually
evaluate the expression by clicking the refresh icon. For details, see How
to:
Refresh Watch Values."

Regards,
Gilles.

Mar 17 '08 #3

P: n/a
Academia wrote:
I get the following watch message:

tsSource[j].Text.ToUpper() This expression causes side effects and
will not be evaluated string
I rather suspect the message is "This expression causes no side effects".

What you've asked for is:
Find the jth item.
Read it's Text property.
Make an uppercase copy.
Throw away the result.
Mar 18 '08 #4

P: n/a
On Tue, 18 Mar 2008 09:02:26 -0700, Ben Voigt [C++ MVP]
<rb*@nospam.nospamwrote:
Academia wrote:
>I get the following watch message:

tsSource[j].Text.ToUpper() This expression causes side effects and
will not be evaluated string

I rather suspect the message is "This expression causes no side effects".

What you've asked for is:
Find the jth item.
Read it's Text property.
Make an uppercase copy.
Throw away the result.
"Watch message" implies debugger. What you're describing would be a
problem if the compiler were looking at the expression, but here the
result of the expression isn't thrown away, it's (in theory) displayed to
the user.

In practice, it seems that it's not being displayed, because the debugger
believes it causes side-effects and thus won't evaluate it. Why that
should be, I don't know...I can't reproduce the same problem (my debugger
seems perfectly happy to put a call to ToUpper() in the watch window, even
when the source is some variable or property). But it's not hard to
believe that the debugger is hesitate to call a method in the watch window
because of the possibility of a side-effect.

Pete
Mar 18 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.