Pergunta

Supposing I have the C# code line:

var myList = new List {1,2,3};

And I put "myList" in the Watch window, and then drag the 1st item of the list down, the watch window creates a new line with the internal name of this data member, which in this case would be

(new System.Collections.Generic.Mscorlib_CollectionDebugView(myList)).Items[0]

My question is, is there a way to programmatically get this internal name from an EnvDTE's Expression's DataMember?

Thanks a lot!

Foi útil?

Solução 2

No, you just can't. You have to roll your own.

Outras dicas

I do not have the complete recipe, but I see that List<T> has custom attribute System.Diagnostics.DebuggerTypeProxyAttribute set with ProxyTypeName set to System.Collections.Generic.Mscorlib_CollectionDebugView'1. Which, as I understand, means that in the watch windows you actually see that proxy type, not the original one. Maybe this can point you in the right direction.

To get the attribute I did:

myList.GetType().GetCustomAttributes(false);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top