Skip to content

Commit

Permalink
add .natvis for MSVC debug view
Browse files Browse the repository at this point in the history
  • Loading branch information
TinyTinni committed Nov 26, 2017
1 parent 5b4855d commit 48d7a32
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ target_include_directories(
${NLOHMANN_JSON_TARGET_NAME}
INTERFACE $<INSTALL_INTERFACE:include/>
)


target_sources(
${NLOHMANN_JSON_TARGET_NAME}
INTERFACE
$<INSTALL_INTERFACE:include/json.natvis>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${NLOHMANN_JSON_SOURCE_DIR}/json.natvis>
)

##
## TESTS
## create and configure the unit test target
Expand Down
32 changes: 32 additions & 0 deletions src/json.natvis
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="nlohmann::basic_json&lt;*&gt;">
<DisplayString Condition="m_type == nlohmann::detail::value_t::null">null</DisplayString>
<DisplayString Condition="m_type == nlohmann::detail::value_t::object">{*(m_value.object)}</DisplayString>
<DisplayString Condition="m_type == nlohmann::detail::value_t::array">{*(m_value.array)}</DisplayString>
<DisplayString Condition="m_type == nlohmann::detail::value_t::string">{*(m_value.string)}</DisplayString>
<DisplayString Condition="m_type == nlohmann::detail::value_t::boolean">{m_value.boolean}</DisplayString>
<DisplayString Condition="m_type == nlohmann::detail::value_t::number_integer">{m_value.number_integer}</DisplayString>
<DisplayString Condition="m_type == nlohmann::detail::value_t::number_unsigned">{m_value.number_unsigned}</DisplayString>
<DisplayString Condition="m_type == nlohmann::detail::value_t::number_float">{m_value.number_float}</DisplayString>
<DisplayString Condition="m_type == nlohmann::detail::value_t::discarded">discarded</DisplayString>
<Expand>
<ExpandedItem Condition="m_type == nlohmann::detail::value_t::object">
*(m_value.object),view(simple)
</ExpandedItem>
<ExpandedItem Condition="m_type == nlohmann::detail::value_t::array">
*(m_value.array),view(simple)
</ExpandedItem>
</Expand>
</Type>

<!-- skip the pair first/second members in the treeview while traversing a map.
Only works in VS 2015 Update 2 and beyond using the new visualization -->
<Type Name="std::pair&lt;*, nlohmann::basic_json&lt;*&gt;&gt;" IncludeView="MapHelper">
<DisplayString>{second}</DisplayString>
<Expand>
<ExpandedItem>second</ExpandedItem>
</Expand>
</Type>

</AutoVisualizer>

0 comments on commit 48d7a32

Please sign in to comment.