user502255
user502255

Reputation:

Auto-enumerate Results View

So, I've just discovered the wonderful DebuggerDisplay attribute, and have started using it in my code. I've noticed something really quirky about it, though, or perhaps the issue is actually with KeyedCollection.

Without a DebuggerDisplay attribute, I get "Count = x" as the primary display for a KeyedCollection, and that expands to show the elements of the collection. Adding the attribute, however, I get my custom text, as expected, but it now expands to show the various values and properties that I've added to the object itself. That's great, and makes far more sense to me than the collection-->Raw View style that shows up by default. Now, though, the Results View isn't populated by default, it instead has the customary "Expanding the Results View will enumerate the IEnumerable".

How do I get rid of that behaviour? I know the results are safe to enumerate, and would like them to be enumerated automatically. For bonus points, can I have it auto-expand the selection as well?

Upvotes: 2

Views: 1144

Answers (1)

Crono
Crono

Reputation: 10478

As I said in my comments, the closest you can be to what you want is by using the DebuggerTypeProxyAttribute. Unfortunately it's a sealed type so you might not be able to make it easy to reuse.

Upvotes: 1

Related Questions