具有 DebuggerDisplay 属性的 DataTable 后代失去 DebuggerVisualizer

发布于 2024-08-07 00:15:19 字数 565 浏览 5 评论 0原文

我有一个 DataTable 的后代,它定义了 DebuggerDisplay 属性。当我添加 DebuggerDisplay 属性时,DataTable 的默认可视化工具将被删除。如果我删除 DebuggerDisplay 属性,DataTable 可视化工具将返回。我想要默认的 DataTable 可视化工具和 DebuggerDisplay 的覆盖。

你们知道如何让它发挥作用吗?

    //does not work
//[DebuggerVisualizer("Microsoft.VisualStudio.Debugger.DataSetVisualizer", typeof(DataTable))]

//DebuggerDisplay attribute removes DataTable visualizer. Odd behavior to me.
[DebuggerDisplay("{TableName}, Count = {Rows.Count}, {GetColumnNames()}")] 
public class MyTable<T> : DataTable where T : class{}

I have a descendant of DataTable that has the DebuggerDisplay attribute defined. The default visualizer for DataTable is removed when I add the DebuggerDisplay attribute. If I remove the DebuggerDisplay attribute, the DataTable visualizer returns. I want the default DataTable visualizer and my override for DebuggerDisplay.

Do you guys know how to get it working?

    //does not work
//[DebuggerVisualizer("Microsoft.VisualStudio.Debugger.DataSetVisualizer", typeof(DataTable))]

//DebuggerDisplay attribute removes DataTable visualizer. Odd behavior to me.
[DebuggerDisplay("{TableName}, Count = {Rows.Count}, {GetColumnNames()}")] 
public class MyTable<T> : DataTable where T : class{}

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

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

发布评论

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

评论(1

神爱温柔 2024-08-14 00:15:19

只是为了澄清,我不知道为什么派生和指定不同的属性会禁用可视化工具。

我尝试过类似的方法,没有什么可以阻止您同时拥有 DebuggerDisplay 和应用于类型的 DebuggerVisualizer。下图显示了两者,左边的圆圈是调试器可视化器,右边的圆圈是调试器显示:

调试器显示和可视化器都可见

但是,尝试在类上使用 DataSetVisualizer 类型时可能会遇到问题。它花费了大量的技巧,但我最终为我的类得到了以下定义:

[Serializable]
[DebuggerVisualizer(typeof(EnhancedDataSetVisualizer.DataSetVisualizer), 
                    typeof(EnhancedDataSetVisualizer.DataSetVisualizerSource))]
[DebuggerDisplay("{Name}")]
public sealed class SpecFlowTableWrapper : DataSet
{
    // Body omitted, not important.
}

我经常需要更改我在DebuggerVisualizer中指定的参数。事实证明,我缺少的部分是指定 VisualizerObjectSource

然后,我得到显示我的数据集名称的调试器显示屏,当我单击放大镜时,它会加载 DataSetVisualizer

其中重要的部分是两个引用:

  • Microsoft.VisualStudio.Debugger.DataSetVisualizer

这包含 DataSetVisualizerDataSetVisualizerSource 类型。

  • Microsoft.VisualStudio。 DebuggerVisualizers

这是另一个引用的依赖项。

第二项通常可在 Visual Studio 的“添加引用...”对话框中找到,但第一项可在 VS 安装目录中找到。

对我来说(VS 版本可能有所不同):

C:\Program Files (x86)\Microsoft Visual Studio
10.0\Common7\Packages\调试器\可视化工具\

调用:

Microsoft.VisualStudio.Debugger.DataSetVisualizer.dll

确保第一个引用的“Copy Local”也为 true(无论如何默认情况下都应该为 true)。请注意,对于调试,此引用现在是一个依赖项,因此您需要确保它位于您正在调试的任何项目的工作目录中,否则您会收到 VS 调试器错误。

重新构建,启动调试器,享受吧。抱歉晚了2年。

Just to clarify, I've got no idea why deriving and specifying a different attribute disables the visualizer.

I've tried something similar and nothing stops you from having both DebuggerDisplay and DebuggerVisualizer applied to a type. The image below shows both, the left circle is the debugger visualizer, the right circle is the debugger display:

Debugger Display and Visualizer both visible

However, you may get issues with trying to use the DataSetVisualizer type on your class. It took a lot of jiggery-pokery, but I ended up with the following definition for my class:

[Serializable]
[DebuggerVisualizer(typeof(EnhancedDataSetVisualizer.DataSetVisualizer), 
                    typeof(EnhancedDataSetVisualizer.DataSetVisualizerSource))]
[DebuggerDisplay("{Name}")]
public sealed class SpecFlowTableWrapper : DataSet
{
    // Body omitted, not important.
}

I was constantly having to change what arguments I specified in DebuggerVisualizer. It turns out the missing piece for me was specifying the VisualizerObjectSource.

I then get the debugger display showing my data set name, and when I click the magnifying glass it loads the DataSetVisualizer.

The important part in all this is two references:

  • Microsoft.VisualStudio.Debugger.DataSetVisualizer

This contains the DataSetVisualizer and DataSetVisualizerSource types.

  • Microsoft.VisualStudio.DebuggerVisualizers

This is a dependency of the other reference.

The second item is generally available in the "Add References..." dialog in Visual Studio, however the first item is found in the VS installation directory.

For me (VS version may vary):

C:\Program Files (x86)\Microsoft Visual Studio
10.0\Common7\Packages\Debugger\Visualizers\

Called:

Microsoft.VisualStudio.Debugger.DataSetVisualizer.dll

Make sure "Copy Local" is true for the first reference as well (it should be true by default anyway). Note that for debugging, this reference is now a dependency so you need to make sure it is in the working directory of whatever project you are debugging, otherwise you get VS debugger errors.

Re-build, start debugger, enjoy. Sorry it was 2 years late.

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