Skip to content

Commit 7c5f650

Browse files
authored
Remove public headers for Insights internal helpers and inline logic (#6285)
* refactor to remove public includes * Add comment referencing canonical source implementations
1 parent 43f4f39 commit 7c5f650

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

build/CopyFilesToStagingDir.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\decimalcppwinrt.h $NugetDir\i
165165
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\MsixDynamicDependency.h $NugetDir\include
166166
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\wil_msixdynamicdependency.h $NugetDir\include
167167
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\WindowsAppRuntimeInsights.h $NugetDir\include\
168-
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\AppModel.Identity.IsPackagedProcess.h $NugetDir\include\
169-
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\WindowsAppRuntime.SelfContained.h $NugetDir\include\
170168
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\Security.AccessControl.h $NugetDir\include\
171169
#
172170
# Libraries (*.lib)

dev/Common/Common.vcxitems

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,5 @@
3636
<ItemGroup>
3737
<PublicHeaders Include="$(MSBuildThisFileDirectory)WindowsAppRuntimeAutoInitializer.cs" />
3838
<PublicHeaders Include="$(MSBuildThisFileDirectory)WindowsAppRuntimeAutoInitializer.cpp" />
39-
<PublicHeaders Include="$(MSBuildThisFileDirectory)AppModel.Identity.IsPackagedProcess.h" />
40-
<PublicHeaders Include="$(MSBuildThisFileDirectory)WindowsAppRuntime.SelfContained.h" />
4139
</ItemGroup>
4240
</Project>

dev/WindowsAppRuntime_Insights/WindowsAppRuntimeInsights.h

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
#include <wil/resource.h>
1515
#include <string>
16-
#include "AppModel.Identity.IsPackagedProcess.h"
17-
#include "WindowsAppRuntime.SelfContained.h"
16+
#include <appmodel.h>
1817
namespace Microsoft::WindowsAppRuntime::Insights
1918
{
2019
enum class TraceLoggingInformationFlags : std::uint32_t
@@ -43,6 +42,10 @@
4342
return channel;
4443
}
4544

45+
// Inlined from the canonical implementations (see for reference):
46+
// IsPackagedProcess: dev/Common/AppModel.Identity.IsPackagedProcess.h
47+
// IsSelfContained: dev/Common/WindowsAppRuntime.SelfContained.h / .cpp
48+
// Duplicated here to avoid exposing those headers as public API.
4649
static std::uint32_t TraceLoggingInformationFlags()
4750
{
4851
static std::uint32_t flags{ []() -> std::uint32_t {
@@ -53,16 +56,34 @@
5356
f |= Insights::TraceLoggingInformationFlags::IsDebuggerPresent;
5457
}
5558

56-
bool isPackagedProcess{};
57-
if (SUCCEEDED_LOG(::AppModel::Identity::IsPackagedProcess_nothrow(isPackagedProcess)) && isPackagedProcess)
5859
{
59-
f |= Insights::TraceLoggingInformationFlags::IsPackagedProcess;
60+
UINT32 n{};
61+
const auto rc{ ::GetCurrentPackageFullName(&n, nullptr) };
62+
if ((rc != APPMODEL_ERROR_NO_PACKAGE) && (rc != ERROR_INSUFFICIENT_BUFFER))
63+
{
64+
LOG_HR(HRESULT_FROM_WIN32(rc));
65+
}
66+
else if (rc == ERROR_INSUFFICIENT_BUFFER)
67+
{
68+
f |= Insights::TraceLoggingInformationFlags::IsPackagedProcess;
69+
}
6070
}
6171

62-
bool isSelfContained{};
63-
if (SUCCEEDED_LOG(::WindowsAppRuntime::SelfContained::IsSelfContained_nothrow(isSelfContained)) && isSelfContained)
6472
{
65-
f |= Insights::TraceLoggingInformationFlags::IsSelfContained;
73+
auto module{ ::GetModuleHandleW(L"Microsoft.WindowsAppRuntime.dll") };
74+
if (module)
75+
{
76+
using IsSelfContainedFn = HRESULT(__stdcall*)(BOOL*);
77+
auto fn{ reinterpret_cast<IsSelfContainedFn>(::GetProcAddress(module, "WindowsAppRuntime_IsSelfContained")) };
78+
if (fn)
79+
{
80+
BOOL result{};
81+
if (SUCCEEDED_LOG(fn(&result)) && result)
82+
{
83+
f |= Insights::TraceLoggingInformationFlags::IsSelfContained;
84+
}
85+
}
86+
}
6687
}
6788

6889
return static_cast<std::uint32_t>(f);

0 commit comments

Comments
 (0)