本文介绍了在 VSCode/Natvis 中使用 CustomListItems的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Natvis 在 VSCode 中为我的自定义类开发一些调试可视化.将 CustomListItems 与一个简单的例子一起使用,但我无法让它工作.基本上,我认为下面的代码应该显示 16 个值都为 1 的项目,但我只得到了类的基本类型..

I am developing some debug visualizations for my custom classes in VSCode using Natvis.Using CustomListItems with a simple example and I can't get it to work.Basically, I think the following code should display 16 items all with value 1 but I get only the basic type of the class..

  <Type Name="vq23_t">
    <DisplayString>16 x q23 Array</DisplayString>
    <Expand>
        <CustomListItems>
            <Size>16</Size>
            <Variable Name="ind" InitialValue="0" />
            <Loop Condition="ind &lt; 16">
                <Item Name="{ind}"> 1 </Item>
                <exec> ++ind </exec>
            </Loop>
        </CustomListItems>
    </Expand>
  </Type>

我得到了什么:

噘嘴:16 x q23 阵列
>[原始视图]:0x56594b40

花了很多时间尝试各种事情,所以我将问题简化到这个基本级别,但无法让它发挥作用.

Spent a lot of time trying various things out so I reduced the problem to this basic level and can't get it to work.

推荐答案

MSDN 您可以激活日志记录以调试 natvis.

As described on MSDN you can activate logging for debugging natvis.

您的情况的解决方案是更改SizeVariable 的顺序并将exec 更改为Exec>.

The solution for your case is to change the order of Size and Variable and to change exec to Exec.

  <Type Name="vq23_t">
    <DisplayString>16 x q23 Array</DisplayString>
    <Expand>
      <CustomListItems>
        <Variable Name="ind" InitialValue="0" />
        <Size>16</Size>
        <Loop Condition="ind &lt; 16">
          <Item Name="{ind}"> 1 </Item>
          <Exec> ++ind </Exec>
        </Loop>
      </CustomListItems>
    </Expand>
  </Type>

这篇关于在 VSCode/Natvis 中使用 CustomListItems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 14:58