适用于任何 ICollection 和 ICollection的调试器可视化工具类型
我创建了带有网格的表单来可视化任何集合(ICollection
、ICollection
)对象。
之后,我创建了调试器可视化工具类(继承自 Microsoft.VisualStudio.DebuggerVisualizers.DialogDebuggerVisualizer
)。
可视化工具已正确安装(我在 System.Collections.ArrayList 类上尝试过)。
但我无法将可视化工具推广到任何 ICollection
/ICollection
类型。
我指定了属性:
[assembly: DebuggerVisualizer( typeof( DebugerSide ), typeof( VisualizerObjectSource ), Target = typeof( System.Collections.Generic.ICollection<> ), Description = "Collection visualizer" )]
[assembly: DebuggerVisualizer( typeof( DebugerSide ), typeof( VisualizerObjectSource ), Target = typeof( System.Collections.ICollection ), Description = "Collection visualizer" )]
但VS在调试中不提供可视化工具。
如果我指定精确的类名,则可视化工具在 VS 中可用。有没有办法,如何实现我的意图或者没有办法,如何实现?
谢谢!
I created form with grid to visualize any collection (ICollection
, ICollection<T>
) object.
After that I created debugger visualizer class (inherits from Microsoft.VisualStudio.DebuggerVisualizers.DialogDebuggerVisualizer
).
The visualizer is installed propertly (I tried it on System.Collections.ArrayList
class).
But I have problem with generalize the visualizer to any ICollection
/ICollection<T>
type.
I specified attribute:
[assembly: DebuggerVisualizer( typeof( DebugerSide ), typeof( VisualizerObjectSource ), Target = typeof( System.Collections.Generic.ICollection<> ), Description = "Collection visualizer" )]
[assembly: DebuggerVisualizer( typeof( DebugerSide ), typeof( VisualizerObjectSource ), Target = typeof( System.Collections.ICollection ), Description = "Collection visualizer" )]
but the visualizer is not offered by VS in debug.
If I specify exactl class name, the visualizer is available in VS. Is there way, how to perform my intention or there is no way, how to achieve it?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您已经遇到了与 在这个问题中概述。
解决方法是为 System.WeakReference 创建一个可视化工具,然后在“监视”窗口中键入“new WeakReference(myCollectionVariable)”,然后您将能够在弱引用上打开调试可视化工具。在调试可视化工具中,您可以使用反射来找出变量的确切类型,并对其执行任何您想要的操作。
另请参阅此。
I think you've stumbled into the same limitation of the Visualizers architecture as outlined in this question.
The workaround is to create a Visualizer for System.WeakReference, and then to type in the Watch window "new WeakReference(myCollectionVariable)", and then you will be able to open your debug visualizer on the weakreference. Inside your debug visualizer you can use reflection to find out what exactly the type of your variable is, and do whatever you want with it.
See also this.
我想这会很好地工作。
This will work fine i guess.