'DebuggerDisplay on generic class
I have a problem applying the DebuggerDisplay attribute on a generic class:
[DebuggerDisplay("--foo--")]
class Foo
{
}
[DebuggerDisplay("Bar: {t}")]
class Bar<T>
{
public T t;
}
When inspecting an object of type Bar<Foo> I would expect it to show as Bar: --foo--, but I get Bar: {Foo}
What am I doing wrong?
Solution 1:[1]
You can use [DebuggerDisplay("Bar<{typeof(T).Name,nq}>")]//nq - no quotes.
You also can use these practices: DebuggerDisplay attribute best practices
Solution 2:[2]
[Disclaimer: I'm affiliated with OzCode]
You can use OzCode's Reveal feature which supports nested/recursive debug information.

Once you define it for an instance it would be used automatically for all instances of that type.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Chuck Savage |
| Solution 2 | Dror Helper |
