简体   繁体   English

在 Visual Studio 中观看 Window

[英]Watch Window in Visual Studio

Is there a way to specify what members of an object to see in Watch Window without expanding the tree with all the properties.有没有办法指定 object 的哪些成员在 Watch Window 中看到,而不用扩展所有属性的树。 For example:例如:

p = new Point(10,10) will display on the Value column in Watch: {X = 10 Y = 10} . p = new Point(10,10) 将显示在 Watch 的 Value 列中: {X = 10 Y = 10}

For my own classes it always displays: {MyNamespace.MyClass} or {MyNamespace.MyStruct} .对于我自己的课程,它总是显示: {MyNamespace.MyClass} 或 {MyNamespace.MyStruct}

Could I change this in order to display: { MyStringProperty = "" MyIntProperty = 0... } ?我可以更改它以显示: { MyStringProperty = "" MyIntProperty = 0... }吗?

See Using DebuggerDisplay Attribute请参阅使用 DebuggerDisplay 属性

If you have marked class by an attribute:如果您通过属性标记了 class:

[DebuggerDisplay("x = {X} y = {Y}")]
public class MyClass
{
   public int X { get; private set; }
   public int Y { get; private set; }
}

Output appearing in the Value column of Watch window will be like following:出现在 Watch window 的 Value 列中的 Output 将如下所示:

x = 5 y = 18

You could use BugAid (an add-on for Visual Studio), which lets you star the members you want to see without expanding the tree, without needing to stop debugging to recompile your code.您可以使用BugAid (Visual Studio 的附加组件),它允许您在不展开树的情况下为想要查看的成员加注标,而无需停止调试以重新编译您的代码。

See example in the following screenshot:请参阅以下屏幕截图中的示例:

星星功能

Full disclosure : I am the co-creator of "BugAid".全面披露:我是“BugAid”的共同创造者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM