【问题标题】:Can you step into specific properties in VS 2010?您可以进入 VS 2010 中的特定属性吗?
【发布时间】:2011-02-23 20:47:20
【问题描述】:

我知道您可以进入每个属性或不进入每个属性,但我真的希望能够进入特定属性,而不是其他属性。这可能吗? (我也知道我可以使用键盘命令,但我想问是否有更永久的解决方案。)我有很多属性,我的 setter 做重要的事情,所以跳过它们很愚蠢,但我的大多数 getter 都是无意义。我正在寻找类似的东西:

public string ImportantProperty
{
    get { return _importantProperty; }
    [DebuggerStepThrough(false)]
    set
    {
        if (this.State != ConnectionState.Closed)
            throw new InvalidOperationException(
                "Important Property cannot be changed unless This is closed.");
        if (ImportantProperty == value)
            return;
        _importantProperty = value;
        OnImportantPropertyChanged(new EventArgs());
    }
}

不幸的是,我找不到像[DebuggerStepThrough(false)] 这样的东西,我必须求助于turning off 属性跨步并将[DebuggerStepThrough] 放置在任何地方 我不想跨步-通过。

【问题讨论】:

  • 1.有趣的问题。我可能会向 John Robbins 寻求解决方案。 2. 最好使用 EventArgs.Empty,而不是 new EventArgs()。
  • 另外,在引发之前检查是否有人订阅了该事件,否则将引发异常。即: if(OnImportantPropertyChanged != null) OnImportantPropertyChanged(EventArgs.Empty);

标签: c# .net debugging visual-studio-2010 attributes


【解决方案1】:

为什么不只在感兴趣的属性设置器中设置断点,然后按 F5 运行到下一个断点?

您为什么不通过按 shift+F11 跳过不重要的属性 - 在设置它们时?

【讨论】:

    【解决方案2】:

    Microsoft 已发布有关如何在 Visual Studio 2010 和 2008 中执行此操作的信息。这些技术在 Visual Studio 2012 中运行良好。

    How to: Step Into Properties and Operators in Managed Code

    如果需要,请通读所有步骤,或者只需使用下面的屏幕截图编辑工具 > 选项(选中或取消选中该项目):

    这有什么用?

    如果您取消选中 Step over properties and operator (Managed only) 项,则 F11 将单步执行属性或方法。 F10 会跳过它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-10
      • 2013-05-20
      • 2013-08-23
      • 2021-05-04
      • 2010-09-08
      • 1970-01-01
      • 2010-10-26
      • 2012-05-31
      相关资源
      最近更新 更多