有没有一个.net属性prevent财产评估在调试器中? [英] Is there a .Net attribute to prevent property evaluation within the debugger?

查看:166
本文介绍了有没有一个.net属性prevent财产评估在调试器中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这个问题(在监视窗口刷新标志,警告)的框架内可见多个类。这是控制的属性?如果是这样,我怎么能效仿这一在我的图书馆?

I've seen several classes in the framework with this behavior (a refresh symbol in the watch window, and a warning). Is this controlled by an Attribute? If so, how can I emulate this in my library?

编辑:感谢您​​的信息!为了澄清,我正在开发那些必须由一个单独的线程访问数据属性的框架。不幸的是,我得到一些奇怪的行为,当我在,因为观察窗等我与调试器可浏览属性经验的调试;不过,我想preFER显示性能的主要线程访问后/设置。我所看到的,尤其是在IEnumerables调试器将不会计算,而无需用户输入。 ......有什么办法来标记这些属性为要求隐评价,或者,我可以没有我的鱼和熊掌兼得呢?

Thanks for the info! To clarify, I am developing a framework with properties that must access data from a single thread. Unfortunately, I am getting some odd behavior when I am in the debugger because of watch windows, etc. I have experience with the Debugger Browsable attribute; however, I would prefer to display the properties after the main thread has accessed / set them. I have seen, especially in IEnumerables that the debugger will not evaluate without user input. ...Is there any way to flag these properties as requiring "Implicit Evaluation", Or can I not have my cake and eat it too?

推荐答案

这不是由属性控制。它是调试器的固有特征。

This is not controlled by attributes. It's an inherent feature of the debugger.

的根本原因此功能是由用户prevent不需要的功能评价。 FUNC Evals是一个危险的操作,在调试器,并可能导致显著缓慢起伏或损坏的程序状态。调试器需要非常谨慎,以确保它不会意外地做额外的FUNC evals,可能会降低你的调试经验。

The underlying reason for this feature is to prevent unwanted function evaluations by the user. Func Evals are a dangerous operation in the debugger and can cause significant slow downs or corrupt program state. The debugger takes great care to make sure that it doesn't inadvertently do extra func evals that may degrade your debugging experience.

在那里是在手表/当地人/自动窗口中的项目,可能会导致一个函数计算和调试不相信一个函数计算应该发生的情况下,该值将变成灰色和刷新按钮将出现在值列。点击该按钮告诉调试器,无我真的要评估的前pression。

In the case where there is an item in the watch/locals/auto window that may cause a func eval and the debugger does not believe a func eval should happen, the value will grey out and a refresh button will appear in the value column. Clicking on that button is telling the debugger, "no really I want to evaluate that expression".

有很多原因,这将在调试器中发生。以下2虽然是最有可能。

There are many reasons why this will happen in the debugger. The following 2 though are the most likely.

隐式属性的评价是禁用

工具 - >调试器 - >选项​​ - >启用隐性资产评估

Tools -> Debugger -> Options -> Enable Implicit Property Evaluation

如果这个值被选中,你告诉调试器请不要自动计算特性。引擎盖下的属性只是函数调用。它们一般比正常的函数调用安全但并非总是如此。

If this value is unchecked, you are telling the debugger please don't auto-evaluate properties. Properties under the hood are just function calls. They are generally safer than normal function calls but not always.

但你仍然可以强制性质直接输入它们到监视窗口来评估。如果在连续输入2,第一数值就变成过时。这是因为,在监视窗口中键入第二个前pression将导致所有其他前pressions得到重新评估。为什么?因为评估任何EX pression的行为可能已经改变了别人的成果。

But you can still force properties to evaluate by typing them directly into the watch window. If you type 2 in a row, the first value will become "stale". This is because typing a second expression in the watch window will cause all other expressions to get re-evaluated. Why? Because the act of evaluating any expression could have altered the results of the others.

由于隐函数计算被关闭的第一个属性将不会自动评价,你必须强迫它。

Because implicit func eval is turned off the first property will not auto-evaluate and you must force it.

函数计算和步骤

如果您添加一个前pression到Watch窗口,做了功能评估,然后做在监视窗口中的一个步骤的操作,该值将staled。

If you add an expression to the watch window which does a function evaluation and then do a step operation, the value will be "staled" in the watch window.

这是做的原因有很多,其中最有影响力的原因,但正在加紧性能之一。这是很常见的用户在监视窗口中键入许多前pressions,这绝对不是难得有一个功能评价。一次一个这些都不是很慢的。但是想象一下,你试图通过一些code步骤迅速,你不得不在监视窗口10 FUNC evals。这可以快速添加和显著降低您的步进经验。所以FUNC evals不会自动重新评估。

This is done for many reasons, one of the most impactful reasons though is stepping performance. It's very common for a user to type many expressions in the watch window, and it's definitely not rare to have a function evaluation. One at a time these aren't very slow. But imagine you're trying to step quickly through some code and you had 10 func evals in the watch window. That can quickly add up and significantly degrade your stepping experience. So func evals are not automatically re-evaluated.

这篇关于有没有一个.net属性prevent财产评估在调试器中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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