EnvDTE.Expression - 以编程方式获取 DataMembers 的内部名称

发布于 2024-10-06 02:27:29 字数 289 浏览 0 评论 0原文

假设我有 C# 代码行:

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

我将“myList”放入“监视”窗口中,然后向下拖动列表的第一项,监视窗口将使用该数据成员的内部名称创建一个新行,在本例中为

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

我的问题是,有没有办法以编程方式从 EnvDTE 的表达式的 DataMember 获取此内部名称?

多谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笙痞 2024-10-13 02:27:29

我没有完整的配方,但我看到 List 的自定义属性 System.Diagnostics.DebuggerTypeProxyAttribute 设置为 ProxyTypeName 设置为System.Collections.Generic.Mscorlib_CollectionDebugView'1。据我了解,这意味着在监视窗口中您实际上看到的是代理类型,而不是原始类型。也许这可以为您指明正确的方向。

为了获得我所做的属性:

myList.GetType().GetCustomAttributes(false);

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);
愿得七秒忆 2024-10-13 02:27:29

不,你就是不能。你必须自己动手。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文