简体   繁体   English

在调试器可视化工具中获取变量名称

[英]get variable name in debugger visualizer

Is there a way to get the underlying variable name of a target object in a Visual Studio debugger visualizer? 有没有办法在Visual Studio调试器可视化工具中获取目标对象的基础变量名称? The built-in string visualizer does it: 内置的字符串可视化工具:

string myStr = "abc\ndef";
Debugger.Break();

Clicking on the visualizer icon for myStr , you will see the "Expression" text box shows "myStr". 单击myStr的可视化图标,您将看到“表达式”文本框显示“myStr”。 How can I get this in my own visualizers? 我怎样才能在自己的可视化工具中获得这个?

It's not possible to do. 这是不可能的。 The only information provided to the visualizer is the value. 提供给可视化工具的唯一信息是价值。

The string visualizer has the name because it is in fact not a true visualizer. 字符串可视化器具有名称,因为它实际上不是真正的可视化器。 That is, it's a debugger feature which has a greater level of access to the underlying metadata and more importantly the expression evaluators. 也就是说,它是一个调试器功能,它具有更高级别的底层元数据访问权限,更重要的是表达式评估程序。

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

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