Visual Studio:使调试器知道功能不会引起“副作用” [英] Visual Studio: Make debugger aware that a function doesn't cause "side effects"

查看:121
本文介绍了Visual Studio:使调试器知道功能不会引起“副作用”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个对象,我必须通过观察窗口观看很多次的功能输出。
问题是我必须按每次我刷新按钮,因为这个表达式会导致副作用,不会被评估
有什么方法可以使用[DoesNotCauseSideEffects]这样的功能来标记一个函数,所以每次我做一个步骤时,手表都可以自动评估?

I have an object i have to watch a function output of pretty many times through the watch window. The problem is that i have to press the refresh button every time i step because "this expression causes side effects and will not be evaluated". Is there any way to tag a function with something like [DoesNotCauseSideEffects] so the watch automatically can evaluate it every time i make a step?

我是编辑VS2008或2010中的C#。

I'm coding C# in VS2008 or 2010.

编辑:
函数看起来像这样,可以看出,不会导致任何副作用(x,y,z都是双打)

The function looks like this and does, as you can see, not cause any side effects.(x,y,z are all doubles)

public override string ToString()
{
    return "{ " + x.ToString(".00") + ", " + y.ToString(".00") + ", " + z.ToString(".00") + "}";
}


推荐答案

你可以追加,ac 到手表表达式以使其自动刷新值:

You can append ,ac to the watch expression to have it automatically refresh the value:

x.ToString(),ac

请参阅MSDN了解更多信息和其他格式说明符

See MSDN for more information and other format specifiers.

这篇关于Visual Studio:使调试器知道功能不会引起“副作用”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆