Skip to content

Commit 4df17bd

Browse files
authored
New Custom Visualizer Sample (#87)
This PR add a second custom visualizer sample to show how to support child nodes and evaluating expressions in a custom visualizer. This sample visualizes a struct like: ```cpp struct Sample { std::vector<int> a; std::vector<int> b; }; Sample sample; ``` which is by default visualized with a format similar to: ``` sample -- a ---- a[0] ---- a[1] ---- ... -- b ---- b[0] ---- b[1] ---- ... ``` as an array like: ```cpp struct Temp { int a; int b; } std::vector<Temp> sample; ``` which has a format similar to: ``` sample -- sample[0] ---- a ---- b -- sample[1] ---- a ---- b ... ```
1 parent 3cdc705 commit 4df17bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2058
-48
lines changed

CppCustomVisualizer/CppCustomVisualizer.sln

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ VisualStudioVersion = 17.65535.65535.65535
55
MinimumVisualStudioVersion = 17.0.0.0
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1375CB4F-7AD1-4269-927D-54AA9052B9BF}"
77
ProjectSection(SolutionItems) = preProject
8-
Cpp.props = Cpp.props
98
README.md = README.md
109
EndProjectSection
1110
EndProject

CppCustomVisualizer/TargetApp/TargetApp.vcxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<Keyword>Win32Proj</Keyword>
2525
<RootNamespace>TargetApp</RootNamespace>
2626
</PropertyGroup>
27-
<Import Project="..\Cpp.props" />
27+
<Import Project="..\..\build\targets\Cpp.props" />
2828
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2929
<ConfigurationType>Application</ConfigurationType>
3030
<UseDebugLibraries>true</UseDebugLibraries>

CppCustomVisualizer/dll/CppCustomVisualizer.vcxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<NugetPackagesDirectory>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\packages\))</NugetPackagesDirectory>
1919
</PropertyGroup>
2020
<Import Project="packages.version.props" />
21-
<Import Project="..\Cpp.props" />
21+
<Import Project="..\..\build\targets\Cpp.props" />
2222
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
2323
<ConfigurationType>DynamicLibrary</ConfigurationType>
2424
<UseOfAtl>Dynamic</UseOfAtl>

CppCustomVisualizer/vsix/vsix.vcxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<Keyword>Win32Proj</Keyword>
3131
<RootNamespace>vsix</RootNamespace>
3232
</PropertyGroup>
33-
<Import Project="..\Cpp.props" />
33+
<Import Project="..\..\build\targets\Cpp.props" />
3434
<PropertyGroup Label="Configuration">
3535
<ConfigurationType>NONE</ConfigurationType>
3636
<CharacterSet>Unicode</CharacterSet>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ChildProcessDebuggingSettings IsEnabled="true" xmlns="http://schemas.microsoft.com/vstudio/ChildProcessDebuggingSettings/2014">
3+
<DefaultRule Attach="false" />
4+
<Rule IsEnabled="true" ProcessName="msvsmon.exe" EngineFilter="[inherit]" />
5+
</ChildProcessDebuggingSettings>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.65535.65535.65535
5+
MinimumVisualStudioVersion = 17.0.0.0
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1375CB4F-7AD1-4269-927D-54AA9052B9BF}"
7+
ProjectSection(SolutionItems) = preProject
8+
README.md = README.md
9+
EndProjectSection
10+
EndProject
11+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vsix", "vsix\vsix.vcxproj", "{0E22D156-940B-431D-945D-51B7DFA08AEF}"
12+
ProjectSection(ProjectDependencies) = postProject
13+
{F7062FB7-42BB-4FEF-8E9B-2F65FFC7EAFA} = {F7062FB7-42BB-4FEF-8E9B-2F65FFC7EAFA}
14+
EndProjectSection
15+
EndProject
16+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppCustomVisualizer", "dll\CppCustomVisualizer.vcxproj", "{F7062FB7-42BB-4FEF-8E9B-2F65FFC7EAFA}"
17+
EndProject
18+
Global
19+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
20+
Debug|x64 = Debug|x64
21+
Release|x64 = Release|x64
22+
EndGlobalSection
23+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
24+
{0E22D156-940B-431D-945D-51B7DFA08AEF}.Debug|x64.ActiveCfg = Debug|x64
25+
{0E22D156-940B-431D-945D-51B7DFA08AEF}.Debug|x64.Build.0 = Debug|x64
26+
{0E22D156-940B-431D-945D-51B7DFA08AEF}.Release|x64.ActiveCfg = Release|x64
27+
{0E22D156-940B-431D-945D-51B7DFA08AEF}.Release|x64.Build.0 = Release|x64
28+
{F7062FB7-42BB-4FEF-8E9B-2F65FFC7EAFA}.Debug|x64.ActiveCfg = Debug|x64
29+
{F7062FB7-42BB-4FEF-8E9B-2F65FFC7EAFA}.Debug|x64.Build.0 = Debug|x64
30+
{F7062FB7-42BB-4FEF-8E9B-2F65FFC7EAFA}.Release|x64.ActiveCfg = Release|x64
31+
{F7062FB7-42BB-4FEF-8E9B-2F65FFC7EAFA}.Release|x64.Build.0 = Release|x64
32+
EndGlobalSection
33+
GlobalSection(SolutionProperties) = preSolution
34+
HideSolutionNode = FALSE
35+
EndGlobalSection
36+
GlobalSection(ExtensibilityGlobals) = postSolution
37+
SolutionGuid = {F7958AE6-3B1E-4AD4-81CD-C64BFA61D418}
38+
EndGlobalSection
39+
EndGlobal

CppCustomVisualizer2/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## C/C++ Custom Visualizer
2+
This directory contains an example C/C++ Custom Visualizer.
3+
4+
## What is a Custom Visualizer?
5+
The Visual Studio C/C++ Expression Evaluator allows customization of the display of variables in
6+
the debugger based on the type of that variable (example: change the way CExampleClass variables
7+
are displayed) using .natvis files. Natvis files add rules to format a type either declaratively or
8+
by running custom code in the debugger. This custom code is called a Custom Visualizer. Most of
9+
the time it is easier and much less error prone to use the declarative approach. But
10+
Custom Visualizers are useful when formatting a type is too complicated to be done declaratively.
11+
12+
Natvis documentation can be found on [docs.microsoft.com](https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects).
13+
14+
## How to use this sample
15+
More information about this sample can be found in the [Wiki for this project](https://github.com/Microsoft/ConcordExtensibilitySamples/wiki/Cpp-Custom-Visualizer-Sample).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
// TargetApp.cpp : Example application which will be debuggeed
5+
6+
#include <iostream>
7+
#include <windows.h>
8+
#include "TargetApp.h"
9+
10+
int wmain(int argc, WCHAR* argv[])
11+
{
12+
Sample sample;
13+
sample.a = { 1, 2, 3, 4, 5 };
14+
sample.b = { 5, 4, 3, 2, 1 };
15+
16+
__debugbreak(); // program will stop here. Evaluate 'creationTime' and 'pPointerTest' in the locals or watch window.
17+
std::cout << "Test complete\n";
18+
19+
return 0;
20+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#include <vector>
4+
5+
class Sample
6+
{
7+
public:
8+
// Expecting a.size() == b.size()
9+
std::vector<int> a;
10+
std::vector<int> b;
11+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.65535.65535.65535
5+
MinimumVisualStudioVersion = 17.0.0.0
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TargetApp", "TargetApp.vcxproj", "{CFE3A899-F357-4721-B717-9BB5F6A108E3}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{CFE3A899-F357-4721-B717-9BB5F6A108E3}.Debug|x64.ActiveCfg = Debug|x64
17+
{CFE3A899-F357-4721-B717-9BB5F6A108E3}.Debug|x64.Build.0 = Debug|x64
18+
{CFE3A899-F357-4721-B717-9BB5F6A108E3}.Debug|x86.ActiveCfg = Debug|Win32
19+
{CFE3A899-F357-4721-B717-9BB5F6A108E3}.Debug|x86.Build.0 = Debug|Win32
20+
{CFE3A899-F357-4721-B717-9BB5F6A108E3}.Release|x64.ActiveCfg = Release|x64
21+
{CFE3A899-F357-4721-B717-9BB5F6A108E3}.Release|x64.Build.0 = Release|x64
22+
{CFE3A899-F357-4721-B717-9BB5F6A108E3}.Release|x86.ActiveCfg = Release|Win32
23+
{CFE3A899-F357-4721-B717-9BB5F6A108E3}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {D847E1DD-8E07-4838-B494-8508FF6A0BF0}
30+
EndGlobalSection
31+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>15.0</VCProjectVersion>
23+
<ProjectGuid>{CFE3A899-F357-4721-B717-9BB5F6A108E3}</ProjectGuid>
24+
<Keyword>Win32Proj</Keyword>
25+
<RootNamespace>TargetApp</RootNamespace>
26+
</PropertyGroup>
27+
<Import Project="..\..\build\targets\Cpp.props" />
28+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
29+
<ConfigurationType>Application</ConfigurationType>
30+
<UseDebugLibraries>true</UseDebugLibraries>
31+
<CharacterSet>Unicode</CharacterSet>
32+
</PropertyGroup>
33+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
34+
<ConfigurationType>Application</ConfigurationType>
35+
<UseDebugLibraries>false</UseDebugLibraries>
36+
<WholeProgramOptimization>true</WholeProgramOptimization>
37+
<CharacterSet>Unicode</CharacterSet>
38+
</PropertyGroup>
39+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
40+
<ConfigurationType>Application</ConfigurationType>
41+
<UseDebugLibraries>true</UseDebugLibraries>
42+
<CharacterSet>Unicode</CharacterSet>
43+
</PropertyGroup>
44+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
45+
<ConfigurationType>Application</ConfigurationType>
46+
<UseDebugLibraries>false</UseDebugLibraries>
47+
<WholeProgramOptimization>true</WholeProgramOptimization>
48+
<CharacterSet>Unicode</CharacterSet>
49+
</PropertyGroup>
50+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
51+
<ImportGroup Label="ExtensionSettings">
52+
</ImportGroup>
53+
<ImportGroup Label="Shared">
54+
</ImportGroup>
55+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
56+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
57+
</ImportGroup>
58+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
59+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
60+
</ImportGroup>
61+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
62+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
63+
</ImportGroup>
64+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
65+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
66+
</ImportGroup>
67+
<PropertyGroup Label="UserMacros" />
68+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
69+
<LinkIncremental>true</LinkIncremental>
70+
</PropertyGroup>
71+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
72+
<LinkIncremental>true</LinkIncremental>
73+
</PropertyGroup>
74+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
75+
<LinkIncremental>false</LinkIncremental>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
78+
<LinkIncremental>false</LinkIncremental>
79+
</PropertyGroup>
80+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
81+
<ClCompile>
82+
<PrecompiledHeader>
83+
</PrecompiledHeader>
84+
<WarningLevel>Level3</WarningLevel>
85+
<Optimization>Disabled</Optimization>
86+
<SDLCheck>true</SDLCheck>
87+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
88+
<ConformanceMode>true</ConformanceMode>
89+
</ClCompile>
90+
<Link>
91+
<SubSystem>Console</SubSystem>
92+
<GenerateDebugInformation>true</GenerateDebugInformation>
93+
</Link>
94+
</ItemDefinitionGroup>
95+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
96+
<ClCompile>
97+
<PrecompiledHeader>
98+
</PrecompiledHeader>
99+
<WarningLevel>Level3</WarningLevel>
100+
<Optimization>Disabled</Optimization>
101+
<SDLCheck>true</SDLCheck>
102+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
103+
<ConformanceMode>true</ConformanceMode>
104+
</ClCompile>
105+
<Link>
106+
<SubSystem>Console</SubSystem>
107+
<GenerateDebugInformation>true</GenerateDebugInformation>
108+
</Link>
109+
</ItemDefinitionGroup>
110+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
111+
<ClCompile>
112+
<PrecompiledHeader>
113+
</PrecompiledHeader>
114+
<WarningLevel>Level3</WarningLevel>
115+
<Optimization>MaxSpeed</Optimization>
116+
<FunctionLevelLinking>true</FunctionLevelLinking>
117+
<IntrinsicFunctions>true</IntrinsicFunctions>
118+
<SDLCheck>true</SDLCheck>
119+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
120+
<ConformanceMode>true</ConformanceMode>
121+
</ClCompile>
122+
<Link>
123+
<SubSystem>Console</SubSystem>
124+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
125+
<OptimizeReferences>true</OptimizeReferences>
126+
<GenerateDebugInformation>true</GenerateDebugInformation>
127+
</Link>
128+
</ItemDefinitionGroup>
129+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
130+
<ClCompile>
131+
<PrecompiledHeader>
132+
</PrecompiledHeader>
133+
<WarningLevel>Level3</WarningLevel>
134+
<Optimization>MaxSpeed</Optimization>
135+
<FunctionLevelLinking>true</FunctionLevelLinking>
136+
<IntrinsicFunctions>true</IntrinsicFunctions>
137+
<SDLCheck>true</SDLCheck>
138+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
139+
<ConformanceMode>true</ConformanceMode>
140+
</ClCompile>
141+
<Link>
142+
<SubSystem>Console</SubSystem>
143+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
144+
<OptimizeReferences>true</OptimizeReferences>
145+
<GenerateDebugInformation>true</GenerateDebugInformation>
146+
</Link>
147+
</ItemDefinitionGroup>
148+
<ItemGroup>
149+
<ClCompile Include="TargetApp.cpp" />
150+
</ItemGroup>
151+
<ItemGroup>
152+
<ClInclude Include="TargetApp.h" />
153+
</ItemGroup>
154+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
155+
<ImportGroup Label="ExtensionTargets">
156+
</ImportGroup>
157+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="TargetApp.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
<ItemGroup>
23+
<ClInclude Include="TargetApp.h">
24+
<Filter>Header Files</Filter>
25+
</ClInclude>
26+
</ItemGroup>
27+
</Project>

0 commit comments

Comments
 (0)