Natvis file for visual studio debugger #1569

Closed
opened 2018-01-24 17:43:09 +00:00 by ocornut · 5 comments
ocornut commented 2018-01-24 17:43:09 +00:00 (Migrated from github.com)

Informational post (will close in a few days)

If you are frequently using imgui types or debugging dear imgui, I have pushed a .natvis file in examples/libs/imgui.natvis and used in the examples visual studio solutions. When included in your project you'll get the debugger to display ImVector<> properly and other readability tweaks.

<?xml version="1.0" encoding="utf-8"?>

<!-- natvis file for Visual Studio debugger (you can include this in a project file, or install in visual studio folder) -->

<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">

<Type Name="ImVector&lt;*&gt;">
  <DisplayString>{{Size={Size} Capacity={Capacity}}}</DisplayString>
  <Expand>
    <ArrayItems>
      <Size>Size</Size>
      <ValuePointer>Data</ValuePointer>
    </ArrayItems>
  </Expand>
</Type>

<Type Name="ImVec2">
  <DisplayString>{{x={x,g} y={y,g}}}</DisplayString>
</Type>

<Type Name="ImVec4">
  <DisplayString>{{x={x,g} y={y,g} z={z,g} w={w,g}}}</DisplayString>
</Type>

<Type Name="ImRect">
  <DisplayString>{{Min=({Min.x,g} {Min.y,g}) Max=({Max.x,g} {Max.y,g}) Size=({Max.x-Min.x,g} {Max.y-Min.y,g})}}</DisplayString>
  <Expand>
    <Item Name="Min">Min</Item>
    <Item Name="Max">Max</Item>
    <Item Name="[Width]">Max.x - Min.x</Item>
    <Item Name="[Height]">Max.y - Min.y</Item>
  </Expand>
</Type>
  
<Type Name="ImGuiWindow">
  <DisplayString Condition="Active||WasActive">{{Name={Name,s}}}</DisplayString>
  <DisplayString Condition="!(Active||WasActive)">{{Name={Name,s}} Inactive}</DisplayString>
</Type>

</AutoVisualizer>

EDIT Fixed a typo in ImRect block.

Informational post (will close in a few days) If you are frequently using imgui types or debugging dear imgui, I have pushed a .natvis file in examples/libs/imgui.natvis and used in the examples visual studio solutions. When included in your project you'll get the debugger to display `ImVector<>` properly and other readability tweaks. ``` <?xml version="1.0" encoding="utf-8"?> <!-- natvis file for Visual Studio debugger (you can include this in a project file, or install in visual studio folder) --> <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> <Type Name="ImVector&lt;*&gt;"> <DisplayString>{{Size={Size} Capacity={Capacity}}}</DisplayString> <Expand> <ArrayItems> <Size>Size</Size> <ValuePointer>Data</ValuePointer> </ArrayItems> </Expand> </Type> <Type Name="ImVec2"> <DisplayString>{{x={x,g} y={y,g}}}</DisplayString> </Type> <Type Name="ImVec4"> <DisplayString>{{x={x,g} y={y,g} z={z,g} w={w,g}}}</DisplayString> </Type> <Type Name="ImRect"> <DisplayString>{{Min=({Min.x,g} {Min.y,g}) Max=({Max.x,g} {Max.y,g}) Size=({Max.x-Min.x,g} {Max.y-Min.y,g})}}</DisplayString> <Expand> <Item Name="Min">Min</Item> <Item Name="Max">Max</Item> <Item Name="[Width]">Max.x - Min.x</Item> <Item Name="[Height]">Max.y - Min.y</Item> </Expand> </Type> <Type Name="ImGuiWindow"> <DisplayString Condition="Active||WasActive">{{Name={Name,s}}}</DisplayString> <DisplayString Condition="!(Active||WasActive)">{{Name={Name,s}} Inactive}</DisplayString> </Type> </AutoVisualizer> ``` *EDIT* Fixed a typo in ImRect block.
pdoane commented 2018-01-24 17:53:19 +00:00 (Migrated from github.com)

Thanks Omar, this is great but it would be easier for us to use if the file were in the root directory. We don't use the code in the examples directory currently so it isn't included/updated when a new version comes out.

Thanks Omar, this is great but it would be easier for us to use if the file were in the root directory. We don't use the code in the examples directory currently so it isn't included/updated when a new version comes out.
ocornut commented 2018-01-24 18:06:59 +00:00 (Migrated from github.com)

Hmm, this file is unlikely to change, or ever so rarely, so perhaps it could be grabbed manually?
Does your update process allows for extra files to be added in the folder?

I'm trying to keep the root directory as platform/toolkit neutral as possible and this particular .natvis file isn't really important for regular users as most of the types are internal stuff.

Hmm, this file is unlikely to change, or ever so rarely, so perhaps it could be grabbed manually? Does your update process allows for extra files to be added in the folder? I'm trying to keep the root directory as platform/toolkit neutral as possible and this particular .natvis file isn't really important for regular users as most of the types are internal stuff.
pdoane commented 2018-01-24 20:05:05 +00:00 (Migrated from github.com)

Yeah I'm sure we can find a way around it. I understand/agree with the motivations - this is unusual in that it's the first thing in that directory that isn't example code but rather visual studio specific source code. From that view, putting it in extra_fonts makes just about as much sense. :)

Yeah I'm sure we can find a way around it. I understand/agree with the motivations - this is unusual in that it's the first thing in that directory that isn't example code but rather visual studio specific source code. From that view, putting it in extra_fonts makes just about as much sense. :)
ocornut commented 2018-01-24 20:23:58 +00:00 (Migrated from github.com)

I agree it is a little weird. Maybe the folders can be rearranged and extra_fonts/ would become a more general purpose misc/fonts/ folder then we have flexibility for other folders. Since I added the .natvis five seconds ago I didn’t want to push for more refactor just yet but i’ll surely keep that in mind.

I agree it is a little weird. Maybe the folders can be rearranged and extra_fonts/ would become a more general purpose misc/fonts/ folder then we have flexibility for other folders. Since I added the .natvis five seconds ago I didn’t want to push for more refactor just yet but i’ll surely keep that in mind.
ocornut commented 2018-01-31 15:01:52 +00:00 (Migrated from github.com)

I have made a little reorganization of the folder and moved the Natvis file to misc/natvis/ which hopefully should also now be more visible.

Closing this too :)

I have made a little reorganization of the folder and moved the Natvis file to misc/natvis/ which hopefully should also now be more visible. Closing this too :)
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#1569
No description provided.