Skip to content

Commit

Permalink
Standalone and Component Visualizers/VSIXes (#823)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Scottj1s authored Dec 15, 2020
1 parent a1db3fc commit 329b104
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 35 deletions.
3 changes: 2 additions & 1 deletion build_test_all.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ if "%target_platform%"=="arm64" goto :eof

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

call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test
Expand Down
9 changes: 8 additions & 1 deletion build_vsix.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
set this_dir=%~dp0
set target_configuration=%1
set target_version=%2
set target_deployment=%3

if "%target_configuration%"=="" set target_configuration=Release
if "%target_version%"=="" set target_version=1.2.3.4
if "%target_deployment%"=="" set target_deployment=Standalone

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

call .nuget\nuget.exe restore cppwinrt.sln"
call .nuget\nuget.exe restore natvis\cppwinrtvisualizer.sln
call .nuget\nuget.exe restore test\nuget\NugetTest.sln

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

rem Build cppwinrt visualizer dll for x86 and x64
call msbuild /p:Configuration=%target_configuration%,Platform=x64,Deployment=%target_deployment%,CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln
call msbuild /p:Configuration=%target_configuration%,Platform=x86,Deployment=%target_deployment%,CppWinRTBuildVersion=%target_version% natvis\cppwinrtvisualizer.sln

rem Build nuget
.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

rem Build vsix
call msbuild /p:Configuration=%target_configuration%,Platform=x86,CppWinRTVersion=%target_version%,NupkgDir=%this_dir%_build vsix\vsix.sln
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
21 changes: 13 additions & 8 deletions natvis/cppwinrtvisualizer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>x86\$(Configuration)\</OutDir>
<IntDir>x86\$(Configuration)\</IntDir>
<OutDir>x86\$(Configuration)\$(Deployment)\</OutDir>
<IntDir>x86\$(Configuration)\$(Deployment)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>x64\$(Configuration)\</OutDir>
<IntDir>x64\$(Configuration)\</IntDir>
<OutDir>x64\$(Configuration)\$(Deployment)\</OutDir>
<IntDir>x64\$(Configuration)\$(Deployment)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>x86\$(Configuration)\</OutDir>
<IntDir>x86\$(Configuration)\</IntDir>
<OutDir>x86\$(Configuration)\$(Deployment)\</OutDir>
<IntDir>x86\$(Configuration)\$(Deployment)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>x64\$(Configuration)\</OutDir>
<IntDir>x64\$(Configuration)\</IntDir>
<OutDir>x64\$(Configuration)\$(Deployment)\</OutDir>
<IntDir>x64\$(Configuration)\$(Deployment)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down Expand Up @@ -204,6 +204,11 @@
<DelayLoadDLLs>vsdebugeng.dll</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Deployment)'=='Component'">
<ClCompile>
<AdditionalOptions>%(AdditionalOptions) /DCOMPONENT_DEPLOYMENT</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="object_visualizer.h" />
<ClInclude Include="cppwinrt_visualizer.h" />
Expand Down
56 changes: 51 additions & 5 deletions natvis/object_visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,14 @@ static HRESULT ObjectToString(
_In_ DkmVisualizedExpression* pExpression,
_In_ DkmPointerValueHome* pObject,
bool isAbiObject,
_Out_ com_ptr<DkmString>& pValue
_Out_ com_ptr<DkmString>& pValue,
bool* unavailable = nullptr
)
{
if (unavailable)
{
*unavailable = false;
}
if (SUCCEEDED(EvaluatePropertyString({ IID_IStringable, 0, PropertyCategory::String }, pExpression, pObject, isAbiObject, pValue)))
{
if (pValue && pValue->Length() > 0)
Expand All @@ -232,6 +237,10 @@ static HRESULT ObjectToString(

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

Expand Down Expand Up @@ -534,26 +543,63 @@ HRESULT object_visualizer::CreateEvaluationResult(_In_ DkmVisualizedExpression*
return S_OK;
}

#ifdef COMPONENT_DEPLOYMENT
static std::set<UINT64> g_refresh_cache;
bool requires_refresh(UINT64 address, DkmEvaluationFlags_t evalFlags)
{
auto refreshed = g_refresh_cache.find(address) != g_refresh_cache.end();
return !refreshed && ((evalFlags & DkmEvaluationFlags::EnableExtendedSideEffects) != DkmEvaluationFlags::EnableExtendedSideEffects);
}
void cache_refresh(UINT64 address)
{
g_refresh_cache.insert(address);
}
#else
bool requires_refresh(UINT64, DkmEvaluationFlags_t)
{
return false;
}
void cache_refresh(UINT64)
{
}
#endif

HRESULT object_visualizer::CreateEvaluationResult(_Deref_out_ DkmEvaluationResult** ppResultObject)
{
com_ptr<DkmRootVisualizedExpression> pRootVisualizedExpression = m_pVisualizedExpression.as<DkmRootVisualizedExpression>();

auto valueHome = make_com_ptr(m_pVisualizedExpression->ValueHome());
com_ptr<DkmPointerValueHome> pPointerValueHome = valueHome.as<DkmPointerValueHome>();

auto address = pPointerValueHome->Address();

com_ptr<DkmString> pValue;
IF_FAIL_RET(ObjectToString(m_pVisualizedExpression.get(), pPointerValueHome.get(), m_isAbiObject, pValue));
DkmEvaluationResultFlags_t evalResultFlags = DkmEvaluationResultFlags::ReadOnly;
if (requires_refresh(address, m_pVisualizedExpression->InspectionContext()->EvaluationFlags()))
{
IF_FAIL_RET(DkmString::Create(L"<Refresh to view properties>", pValue.put()));
evalResultFlags |= DkmEvaluationResultFlags::EnableExtendedSideEffectsUponRefresh | DkmEvaluationResultFlags::CanEvaluateNow;
}
else
{
cache_refresh(address);
bool unavailable;
IF_FAIL_RET(ObjectToString(m_pVisualizedExpression.get(), pPointerValueHome.get(), m_isAbiObject, pValue, &unavailable));
if (!unavailable)
{
evalResultFlags |= DkmEvaluationResultFlags::Expandable;
}
}

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

com_ptr<DkmSuccessEvaluationResult> pSuccessEvaluationResult;
IF_FAIL_RET(DkmSuccessEvaluationResult::Create(
m_pVisualizedExpression->InspectionContext(),
m_pVisualizedExpression->StackFrame(),
pRootVisualizedExpression->Name(),
pRootVisualizedExpression->FullName(),
DkmEvaluationResultFlags::Expandable | DkmEvaluationResultFlags::ReadOnly,
evalResultFlags,
pValue.get(),
pValue.get(),
pRootVisualizedExpression->Type(),
Expand Down
Binary file removed vsix/UpgradeLog.htm
Binary file not shown.
2 changes: 2 additions & 0 deletions vsix/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Assets>
<Asset Type="NativeVisualizer" Path="cppwinrt.natvis" />
<Asset Type="DebuggerEngineExtension" Path="CppWinrtVisualizer.vsdconfig" />
<Asset Type="Microsoft.VisualStudio.ItemTemplate" Path="ItemTemplates" />
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" Path="ProjectTemplates" />
<Asset Type="Microsoft.Windows.CppWinRT.|%CurrentProject%;GetCppWinRTVersion|.nupkg" Source="File" Path="Microsoft.Windows.CppWinRT.|%CurrentProject%;GetCppWinRTVersion|.nupkg" VsixSubPath="Packages" />
Expand Down
40 changes: 20 additions & 20 deletions vsix/vsix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<OutputPath>bin\x86\Debug\$(Deployment)\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<OutputPath>bin\x86\Release\$(Deployment)\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -46,24 +46,6 @@
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
<CopyOutputSymbolsToOutputDirectory>false</CopyOutputSymbolsToOutputDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\$(Deployment)\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CopyVsixExtensionFiles>False</CopyVsixExtensionFiles>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\$(Deployment)\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Content Include="LICENSE">
<IncludeInVSIX>true</IncludeInVSIX>
Expand Down Expand Up @@ -108,6 +90,22 @@
<Link>Packages\Microsoft.Windows.CppWinRT.$(CppWinRTVersion).nupkg</Link>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="..\natvis\cppwinrt.natvis">
<Link>%(Filename)%(Extension)</Link>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="$(NatvisDirx86)\cppwinrtvisualizer.vsdconfig">
<Link>%(Filename)%(Extension)</Link>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="$(NatvisDirx86)\cppwinrtvisualizer.dll">
<Link>x86\%(Filename)%(Extension)</Link>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="$(NatvisDirx64)\cppwinrtvisualizer.dll">
<Link>x64\%(Filename)%(Extension)</Link>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<None Include="source.extension.vsixmanifest">
<SubType>Designer</SubType>
</None>
Expand Down Expand Up @@ -139,6 +137,8 @@
<Target Name="GetCppWinRTVersion" Outputs="$(CppWinRTVersion)" />
<Target Name="PrepareBuild" BeforeTargets="PrepareForBuild">
<Error Condition="'$(CppWinRTVersion)' == ''" Text="The project must be supplied with a CppWinRTVersion property value" />
<Error Condition="'$(NatvisDirx86)' == ''" Text="The project must be supplied with a NatvisDirx86 property value" />
<Error Condition="'$(NatvisDirx64)' == ''" Text="The project must be supplied with a NatvisDirx64 property value" />
<Error Condition="'$(NupkgDir)' == ''" Text="The project must be supplied with a NupkgDir property value" />
<Copy SourceFiles="..\LICENSE" DestinationFolder="$(MSBuildProjectDirectory)" />
<ItemGroup>
Expand Down

0 comments on commit 329b104

Please sign in to comment.