7

Is there a way to get the underlying variable name of a target object in a Visual Studio debugger visualizer? 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". How can I get this in my own visualizers?

2
  • +1, I hope someone can help, but I fear that without access to the internal DebugeeHost class it's not going to happen. Commented May 20, 2009 at 22:12
  • Does this answer your question? Visualized expression in custom data visualizer Commented Apr 14, 2021 at 9:39

1 Answer 1

10

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.