调试器可视化工具 [Visual Studio 2010] - System.Linq.Expressions.Expression - 不显示放大镜
我一直在尝试为 linq 表达式构建调试器可视化工具。
我知道已经存在一个,但我想创建自己的并添加附加功能。
我制作了这个快速原型。 放大镜不会显示;但是,如果我将一行代码更改为“Target = typeof(System.String)”,则会显示放大镜。
任何帮助将不胜感激。
using System.IO;
using System.Windows.Forms;
using Microsoft.VisualStudio.DebuggerVisualizers;
[assembly: System.Diagnostics.DebuggerVisualizer(
typeof(VisualizerPrototype.MyDebuggerVisualizer),
typeof(VisualizerPrototype.MyDebuggerVisualizerObjectSource),
Target = typeof(System.Linq.Expressions.Expression),
Description = "My Debugger Visualizer")]
namespace VisualizerPrototype
{
public class MyDebuggerVisualizer : DialogDebuggerVisualizer
{
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
var text = string.Empty;
using (var sr = new StreamReader(objectProvider.GetData()))
{
text = sr.ReadToEnd();
}
MessageBox.Show(text);
}
}
public class MyDebuggerVisualizerObjectSource : VisualizerObjectSource
{
public override void GetData(object target, System.IO.Stream outgoingData)
{
var sw = new StreamWriter(outgoingData);
sw.WriteLine("YO");
sw.Flush();
}
}
}
I have been trying to build a debugger visualizer for a linq Expression.
I know one exists already, but I would like to create my own and add additional functionality.
I made this quick prototype.
The magnifying glass will not show up; however, if I change the one line of code to "Target = typeof(System.String)", the magnifying glass shows up.
Any help would be appreciated.
using System.IO;
using System.Windows.Forms;
using Microsoft.VisualStudio.DebuggerVisualizers;
[assembly: System.Diagnostics.DebuggerVisualizer(
typeof(VisualizerPrototype.MyDebuggerVisualizer),
typeof(VisualizerPrototype.MyDebuggerVisualizerObjectSource),
Target = typeof(System.Linq.Expressions.Expression),
Description = "My Debugger Visualizer")]
namespace VisualizerPrototype
{
public class MyDebuggerVisualizer : DialogDebuggerVisualizer
{
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
var text = string.Empty;
using (var sr = new StreamReader(objectProvider.GetData()))
{
text = sr.ReadToEnd();
}
MessageBox.Show(text);
}
}
public class MyDebuggerVisualizerObjectSource : VisualizerObjectSource
{
public override void GetData(object target, System.IO.Stream outgoingData)
{
var sw = new StreamWriter(outgoingData);
sw.WriteLine("YO");
sw.Flush();
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于将来读到这篇文章的人来说,我发现了问题的根源。
调试器可视化工具的目标类型必须是运行时类型而不是继承类型。
For anybody reading this in the future, I discovered the source of my problem.
The target type for a debugger visualizer must be the runtime type and not an inherited type.
尝试这个用于
VB:
或这个用于 C#:
Try this one for
VB:
Or this one for C#: