Skip to content

Commit 329b104

Browse files
authored
Standalone and Component Visualizers/VSIXes (#823)
* Revert "Remove visualizer from vsix (#792)" This reverts commit d4635e3. * Reenabled standalone visualizer and forked component visualizer for VS installer integration * build component and standalone visualizers
1 parent a1db3fc commit 329b104

File tree

7 files changed

+96
-35
lines changed

7 files changed

+96
-35
lines changed

build_test_all.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ if "%target_platform%"=="arm64" goto :eof
2222

2323
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:cppwinrt
2424
_build\%target_platform%\%target_configuration%\cppwinrt.exe -in local -out _build\%target_platform%\%target_configuration% -verbose
25-
call msbuild /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln
25+
call msbuild /p:Configuration=%target_configuration%,Platform=%target_platform%,Deployment=Component;CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln
26+
call msbuild /p:Configuration=%target_configuration%,Platform=%target_platform%,Deployment=Standalone;CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln
2627
call msbuild /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% test\nuget\NugetTest.sln
2728

2829
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test

build_vsix.cmd

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
set this_dir=%~dp0
44
set target_configuration=%1
55
set target_version=%2
6+
set target_deployment=%3
67

78
if "%target_configuration%"=="" set target_configuration=Release
89
if "%target_version%"=="" set target_version=1.2.3.4
10+
if "%target_deployment%"=="" set target_deployment=Standalone
911

1012
if not exist ".\.nuget" mkdir ".\.nuget"
1113
if not exist ".\.nuget\nuget.exe" powershell -Command "Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile .\.nuget\nuget.exe"
1214

1315
call .nuget\nuget.exe restore cppwinrt.sln"
16+
call .nuget\nuget.exe restore natvis\cppwinrtvisualizer.sln
1417
call .nuget\nuget.exe restore test\nuget\NugetTest.sln
1518

1619
rem Build fast forwarder libs or all arches
@@ -22,8 +25,12 @@ call msbuild /m /p:Configuration=%target_configuration%,Platform=arm64,CppWinRTB
2225
rem Build cppwinrt.exe for x86 only
2326
call msbuild /m /p:Configuration=%target_configuration%,Platform=x86,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:cppwinrt
2427

28+
rem Build cppwinrt visualizer dll for x86 and x64
29+
call msbuild /p:Configuration=%target_configuration%,Platform=x64,Deployment=%target_deployment%,CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln
30+
call msbuild /p:Configuration=%target_configuration%,Platform=x86,Deployment=%target_deployment%,CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln
31+
2532
rem Build nuget
2633
.nuget\nuget.exe pack nuget\Microsoft.Windows.CppWinRT.nuspec -NonInteractive -OutputDirectory %this_dir%_build -Properties Configuration=%target_configuration%;cppwinrt_exe=%this_dir%_build\x86\%target_configuration%\cppwinrt.exe;cppwinrt_fast_fwd_x86=%this_dir%_build\x86\%target_configuration%\cppwinrt_fast_forwarder.lib;cppwinrt_fast_fwd_x64=%this_dir%_build\x64\%target_configuration%\cppwinrt_fast_forwarder.lib;cppwinrt_fast_fwd_arm=%this_dir%_build\arm\%target_configuration%\cppwinrt_fast_forwarder.lib;cppwinrt_fast_fwd_arm64=%this_dir%_build\arm64\%target_configuration%\cppwinrt_fast_forwarder.lib -version %target_version% -Verbosity Detailed
2734

2835
rem Build vsix
29-
call msbuild /p:Configuration=%target_configuration%,Platform=x86,CppWinRTVersion=%target_version%,NupkgDir=%this_dir%_build vsix\vsix.sln
36+
call msbuild /p:Configuration=%target_configuration%,Platform=x86,Deployment=%target_deployment%,CppWinRTVersion=%target_version%,NatvisDirx86=%this_dir%natvis\x86\%target_configuration%\%target_deployment%,NatvisDirx64=%this_dir%natvis\x64\%target_configuration%\%target_deployment%,NupkgDir=%this_dir%_build vsix\vsix.sln

natvis/cppwinrtvisualizer.vcxproj

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,23 @@
7777
<PropertyGroup Label="UserMacros" />
7878
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7979
<LinkIncremental>true</LinkIncremental>
80-
<OutDir>x86\$(Configuration)\</OutDir>
81-
<IntDir>x86\$(Configuration)\</IntDir>
80+
<OutDir>x86\$(Configuration)\$(Deployment)\</OutDir>
81+
<IntDir>x86\$(Configuration)\$(Deployment)\</IntDir>
8282
</PropertyGroup>
8383
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
8484
<LinkIncremental>true</LinkIncremental>
85-
<OutDir>x64\$(Configuration)\</OutDir>
86-
<IntDir>x64\$(Configuration)\</IntDir>
85+
<OutDir>x64\$(Configuration)\$(Deployment)\</OutDir>
86+
<IntDir>x64\$(Configuration)\$(Deployment)\</IntDir>
8787
</PropertyGroup>
8888
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
8989
<LinkIncremental>false</LinkIncremental>
90-
<OutDir>x86\$(Configuration)\</OutDir>
91-
<IntDir>x86\$(Configuration)\</IntDir>
90+
<OutDir>x86\$(Configuration)\$(Deployment)\</OutDir>
91+
<IntDir>x86\$(Configuration)\$(Deployment)\</IntDir>
9292
</PropertyGroup>
9393
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
9494
<LinkIncremental>false</LinkIncremental>
95-
<OutDir>x64\$(Configuration)\</OutDir>
96-
<IntDir>x64\$(Configuration)\</IntDir>
95+
<OutDir>x64\$(Configuration)\$(Deployment)\</OutDir>
96+
<IntDir>x64\$(Configuration)\$(Deployment)\</IntDir>
9797
</PropertyGroup>
9898
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
9999
<ClCompile>
@@ -204,6 +204,11 @@
204204
<DelayLoadDLLs>vsdebugeng.dll</DelayLoadDLLs>
205205
</Link>
206206
</ItemDefinitionGroup>
207+
<ItemDefinitionGroup Condition="'$(Deployment)'=='Component'">
208+
<ClCompile>
209+
<AdditionalOptions>%(AdditionalOptions) /DCOMPONENT_DEPLOYMENT</AdditionalOptions>
210+
</ClCompile>
211+
</ItemDefinitionGroup>
207212
<ItemGroup>
208213
<ClInclude Include="object_visualizer.h" />
209214
<ClInclude Include="cppwinrt_visualizer.h" />

natvis/object_visualizer.cpp

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,14 @@ static HRESULT ObjectToString(
211211
_In_ DkmVisualizedExpression* pExpression,
212212
_In_ DkmPointerValueHome* pObject,
213213
bool isAbiObject,
214-
_Out_ com_ptr<DkmString>& pValue
214+
_Out_ com_ptr<DkmString>& pValue,
215+
bool* unavailable = nullptr
215216
)
216217
{
218+
if (unavailable)
219+
{
220+
*unavailable = false;
221+
}
217222
if (SUCCEEDED(EvaluatePropertyString({ IID_IStringable, 0, PropertyCategory::String }, pExpression, pObject, isAbiObject, pValue)))
218223
{
219224
if (pValue && pValue->Length() > 0)
@@ -232,6 +237,10 @@ static HRESULT ObjectToString(
232237

233238
// VirtualQuery validation failed (as determined by no runtime class name) or an
234239
// exception escaped WINRT_abi_val (e.g, bad pointer, which we try to avoid via VirtualQuery)
240+
if (unavailable)
241+
{
242+
*unavailable = true;
243+
}
235244
return DkmString::Create(L"<Object uninitialized or information unavailable>", pValue.put());
236245
}
237246

@@ -534,26 +543,63 @@ HRESULT object_visualizer::CreateEvaluationResult(_In_ DkmVisualizedExpression*
534543
return S_OK;
535544
}
536545

546+
#ifdef COMPONENT_DEPLOYMENT
547+
static std::set<UINT64> g_refresh_cache;
548+
bool requires_refresh(UINT64 address, DkmEvaluationFlags_t evalFlags)
549+
{
550+
auto refreshed = g_refresh_cache.find(address) != g_refresh_cache.end();
551+
return !refreshed && ((evalFlags & DkmEvaluationFlags::EnableExtendedSideEffects) != DkmEvaluationFlags::EnableExtendedSideEffects);
552+
}
553+
void cache_refresh(UINT64 address)
554+
{
555+
g_refresh_cache.insert(address);
556+
}
557+
#else
558+
bool requires_refresh(UINT64, DkmEvaluationFlags_t)
559+
{
560+
return false;
561+
}
562+
void cache_refresh(UINT64)
563+
{
564+
}
565+
#endif
566+
537567
HRESULT object_visualizer::CreateEvaluationResult(_Deref_out_ DkmEvaluationResult** ppResultObject)
538568
{
539569
com_ptr<DkmRootVisualizedExpression> pRootVisualizedExpression = m_pVisualizedExpression.as<DkmRootVisualizedExpression>();
540570

541571
auto valueHome = make_com_ptr(m_pVisualizedExpression->ValueHome());
542572
com_ptr<DkmPointerValueHome> pPointerValueHome = valueHome.as<DkmPointerValueHome>();
543-
573+
auto address = pPointerValueHome->Address();
574+
544575
com_ptr<DkmString> pValue;
545-
IF_FAIL_RET(ObjectToString(m_pVisualizedExpression.get(), pPointerValueHome.get(), m_isAbiObject, pValue));
576+
DkmEvaluationResultFlags_t evalResultFlags = DkmEvaluationResultFlags::ReadOnly;
577+
if (requires_refresh(address, m_pVisualizedExpression->InspectionContext()->EvaluationFlags()))
578+
{
579+
IF_FAIL_RET(DkmString::Create(L"<Refresh to view properties>", pValue.put()));
580+
evalResultFlags |= DkmEvaluationResultFlags::EnableExtendedSideEffectsUponRefresh | DkmEvaluationResultFlags::CanEvaluateNow;
581+
}
582+
else
583+
{
584+
cache_refresh(address);
585+
bool unavailable;
586+
IF_FAIL_RET(ObjectToString(m_pVisualizedExpression.get(), pPointerValueHome.get(), m_isAbiObject, pValue, &unavailable));
587+
if (!unavailable)
588+
{
589+
evalResultFlags |= DkmEvaluationResultFlags::Expandable;
590+
}
591+
}
546592

547593
com_ptr<DkmDataAddress> pAddress;
548-
IF_FAIL_RET(DkmDataAddress::Create(m_pVisualizedExpression->StackFrame()->RuntimeInstance(), pPointerValueHome->Address(), nullptr, pAddress.put()));
594+
IF_FAIL_RET(DkmDataAddress::Create(m_pVisualizedExpression->StackFrame()->RuntimeInstance(), address, nullptr, pAddress.put()));
549595

550596
com_ptr<DkmSuccessEvaluationResult> pSuccessEvaluationResult;
551597
IF_FAIL_RET(DkmSuccessEvaluationResult::Create(
552598
m_pVisualizedExpression->InspectionContext(),
553599
m_pVisualizedExpression->StackFrame(),
554600
pRootVisualizedExpression->Name(),
555601
pRootVisualizedExpression->FullName(),
556-
DkmEvaluationResultFlags::Expandable | DkmEvaluationResultFlags::ReadOnly,
602+
evalResultFlags,
557603
pValue.get(),
558604
pValue.get(),
559605
pRootVisualizedExpression->Type(),

vsix/UpgradeLog.htm

-31 KB
Binary file not shown.

vsix/source.extension.vsixmanifest

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
2323
</Dependencies>
2424
<Assets>
25+
<Asset Type="NativeVisualizer" Path="cppwinrt.natvis" />
26+
<Asset Type="DebuggerEngineExtension" Path="CppWinrtVisualizer.vsdconfig" />
2527
<Asset Type="Microsoft.VisualStudio.ItemTemplate" Path="ItemTemplates" />
2628
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" Path="ProjectTemplates" />
2729
<Asset Type="Microsoft.Windows.CppWinRT.|%CurrentProject%;GetCppWinRTVersion|.nupkg" Source="File" Path="Microsoft.Windows.CppWinRT.|%CurrentProject%;GetCppWinRTVersion|.nupkg" VsixSubPath="Packages" />

vsix/vsix.csproj

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
</PropertyGroup>
1010
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
1111
<DebugSymbols>true</DebugSymbols>
12-
<OutputPath>bin\x86\Debug\</OutputPath>
12+
<OutputPath>bin\x86\Debug\$(Deployment)\</OutputPath>
1313
<DefineConstants>DEBUG;TRACE</DefineConstants>
1414
<DebugType>full</DebugType>
1515
<PlatformTarget>x86</PlatformTarget>
1616
<ErrorReport>prompt</ErrorReport>
1717
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
1818
</PropertyGroup>
1919
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
20-
<OutputPath>bin\x86\Release\</OutputPath>
20+
<OutputPath>bin\x86\Release\$(Deployment)\</OutputPath>
2121
<DefineConstants>TRACE</DefineConstants>
2222
<Optimize>true</Optimize>
2323
<DebugType>pdbonly</DebugType>
@@ -46,24 +46,6 @@
4646
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
4747
<CopyOutputSymbolsToOutputDirectory>false</CopyOutputSymbolsToOutputDirectory>
4848
</PropertyGroup>
49-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
50-
<DebugSymbols>true</DebugSymbols>
51-
<DebugType>full</DebugType>
52-
<Optimize>false</Optimize>
53-
<OutputPath>bin\Debug\$(Deployment)\</OutputPath>
54-
<DefineConstants>DEBUG;TRACE</DefineConstants>
55-
<ErrorReport>prompt</ErrorReport>
56-
<WarningLevel>4</WarningLevel>
57-
<CopyVsixExtensionFiles>False</CopyVsixExtensionFiles>
58-
</PropertyGroup>
59-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
60-
<DebugType>pdbonly</DebugType>
61-
<Optimize>true</Optimize>
62-
<OutputPath>bin\Release\$(Deployment)\</OutputPath>
63-
<DefineConstants>TRACE</DefineConstants>
64-
<ErrorReport>prompt</ErrorReport>
65-
<WarningLevel>4</WarningLevel>
66-
</PropertyGroup>
6749
<ItemGroup>
6850
<Content Include="LICENSE">
6951
<IncludeInVSIX>true</IncludeInVSIX>
@@ -108,6 +90,22 @@
10890
<Link>Packages\Microsoft.Windows.CppWinRT.$(CppWinRTVersion).nupkg</Link>
10991
<IncludeInVSIX>true</IncludeInVSIX>
11092
</Content>
93+
<Content Include="..\natvis\cppwinrt.natvis">
94+
<Link>%(Filename)%(Extension)</Link>
95+
<IncludeInVSIX>true</IncludeInVSIX>
96+
</Content>
97+
<Content Include="$(NatvisDirx86)\cppwinrtvisualizer.vsdconfig">
98+
<Link>%(Filename)%(Extension)</Link>
99+
<IncludeInVSIX>true</IncludeInVSIX>
100+
</Content>
101+
<Content Include="$(NatvisDirx86)\cppwinrtvisualizer.dll">
102+
<Link>x86\%(Filename)%(Extension)</Link>
103+
<IncludeInVSIX>true</IncludeInVSIX>
104+
</Content>
105+
<Content Include="$(NatvisDirx64)\cppwinrtvisualizer.dll">
106+
<Link>x64\%(Filename)%(Extension)</Link>
107+
<IncludeInVSIX>true</IncludeInVSIX>
108+
</Content>
111109
<None Include="source.extension.vsixmanifest">
112110
<SubType>Designer</SubType>
113111
</None>
@@ -139,6 +137,8 @@
139137
<Target Name="GetCppWinRTVersion" Outputs="$(CppWinRTVersion)" />
140138
<Target Name="PrepareBuild" BeforeTargets="PrepareForBuild">
141139
<Error Condition="'$(CppWinRTVersion)' == ''" Text="The project must be supplied with a CppWinRTVersion property value" />
140+
<Error Condition="'$(NatvisDirx86)' == ''" Text="The project must be supplied with a NatvisDirx86 property value" />
141+
<Error Condition="'$(NatvisDirx64)' == ''" Text="The project must be supplied with a NatvisDirx64 property value" />
142142
<Error Condition="'$(NupkgDir)' == ''" Text="The project must be supplied with a NupkgDir property value" />
143143
<Copy SourceFiles="..\LICENSE" DestinationFolder="$(MSBuildProjectDirectory)" />
144144
<ItemGroup>

0 commit comments

Comments
 (0)