Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime query'able version information #2889

Merged
merged 13 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions WindowsAppRuntime.sln
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,53 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test_DeploymentManagerAutoI
{B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VersionInfo", "VersionInfo", "{2A2D1131-273C-4E17-BCD3-8812170A4B95}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VersionInfo", "dev\VersionInfo\VersionInfo.vcxitems", "{E3EDEC7F-A24E-4766-BB1D-6BDFBA157C51}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VersionInfoTests", "test\VersionInfo\VersionInfoTests.vcxproj", "{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}"
ProjectSection(ProjectDependencies) = postProject
{34519337-9249-451E-B5A9-1ECACF9C3DA8} = {34519337-9249-451E-B5A9-1ECACF9C3DA8}
{9C1A6C58-52D6-4514-9120-5C339C5DF4BE} = {9C1A6C58-52D6-4514-9120-5C339C5DF4BE}
{0B01DB78-F115-4C90-B28F-7819071303C6} = {0B01DB78-F115-4C90-B28F-7819071303C6}
{5E2CC9D5-7C05-41D9-9DB5-EC5DF64BA1DC} = {5E2CC9D5-7C05-41D9-9DB5-EC5DF64BA1DC}
EndProjectSection
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
test\inc\inc.vcxitems*{08bc78e0-63c6-49a7-81b3-6afc3deac4de}*SharedItemsImports = 4
dev\PushNotifications\PushNotifications.vcxitems*{103c0c23-7ba8-4d44-a63c-83488e2e3a81}*SharedItemsImports = 9
test\inc\inc.vcxitems*{2cd5cd9b-cf45-4fa7-9769-ee4e02426bf0}*SharedItemsImports = 4
dev\EnvironmentManager\API\Microsoft.Process.Environment.vcxitems*{2f3fad1b-d3df-4866-a3a3-c2c777d55638}*SharedItemsImports = 9
test\inc\inc.vcxitems*{412d023e-8635-4ad2-a0ea-e19e08d36915}*SharedItemsImports = 4
test\inc\inc.vcxitems*{4b30c685-8490-440f-9879-a75d45daa361}*SharedItemsImports = 4
dev\UndockedRegFreeWinRT\UndockedRegFreeWinRT.vcxitems*{56371ca6-144b-4989-a4e9-391ad4fa7651}*SharedItemsImports = 9
test\inc\inc.vcxitems*{56a1d696-feda-4333-bf37-772ebececb10}*SharedItemsImports = 4
test\inc\inc.vcxitems*{5b2d17fe-c371-417f-860c-3d32397c2404}*SharedItemsImports = 4
test\inc\inc.vcxitems*{7c502995-59c3-483b-86ba-815985353633}*SharedItemsImports = 4
dev\Common\Common.vcxitems*{8828053c-d6ec-4744-8624-f8c676c2d4df}*SharedItemsImports = 9
dev\Licensing\Licensing.vcxitems*{885a43fa-052d-4b0d-a2dc-13ee15796435}*SharedItemsImports = 9
test\inc\inc.vcxitems*{8e52d7ea-a200-4a6b-ba74-8efb49468caf}*SharedItemsImports = 4
dev\AppNotifications\AppNotifications.vcxitems*{b4824897-88e0-4927-8fb9-e60106f01ed9}*SharedItemsImports = 9
test\inc\inc.vcxitems*{b567fe2e-3a03-48d0-b2b5-760cdec35891}*SharedItemsImports = 9
dev\Common\Common.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
dev\DynamicDependency\API\DynamicDependency.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
dev\Licensing\Licensing.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
dev\PowerNotifications\PowerNotifications.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
dev\UndockedRegFreeWinRT\UndockedRegFreeWinRT.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
dev\PowerNotifications\PowerNotifications.vcxitems*{b75c1b22-553c-40e4-b38e-6ab4d01fdb9d}*SharedItemsImports = 9
dev\DynamicDependency\API\DynamicDependency.vcxitems*{bf055a59-0919-4e34-9b76-dd055495cc5a}*SharedItemsImports = 9
test\inc\inc.vcxitems*{c62688a1-16a0-4729-b6ed-842f4faa29f3}*SharedItemsImports = 4
dev\AccessControl\AccessControl.vcxitems*{c91bcb93-9ed1-4acd-85f3-26f9f6ac52e3}*SharedItemsImports = 9
dev\Common\Common.vcxitems*{d45d4170-e055-4926-8b03-04daa5f02c6c}*SharedItemsImports = 4
test\inc\inc.vcxitems*{d5667df6-a151-4081-abc7-b93e8e5604ce}*SharedItemsImports = 4
dev\Deployment\Deployment.vcxitems*{db38fb4d-d04f-4c1d-93e0-f8ae259c5fd6}*SharedItemsImports = 9
dev\EnvironmentManager\ChangeTracker\ChangeTracker.vcxitems*{e15c3465-9d45-495d-92ce-b91ef45e8623}*SharedItemsImports = 9
dev\AppLifecycle\AppLifecycle.vcxitems*{e3a522a3-6635-4a42-bded-1af46a15f63c}*SharedItemsImports = 9
dev\VersionInfo\VersionInfo.vcxitems*{e3edec7f-a24e-4766-bb1d-6bdfba157c51}*SharedItemsImports = 9
test\inc\inc.vcxitems*{e5659a29-fe68-417b-9bc5-613073dd54df}*SharedItemsImports = 4
test\inc\inc.vcxitems*{e977b1bd-00dc-4085-a105-e0a18e0183d7}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM64 = Debug|ARM64
Expand Down Expand Up @@ -1509,6 +1555,20 @@ Global
{5A4FBF6D-04A2-4061-B11F-1A0E64129610}.Release|x64.Build.0 = Release|x64
{5A4FBF6D-04A2-4061-B11F-1A0E64129610}.Release|x86.ActiveCfg = Release|x86
{5A4FBF6D-04A2-4061-B11F-1A0E64129610}.Release|x86.Build.0 = Release|x86
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Debug|Any CPU.ActiveCfg = Debug|Win32
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Debug|ARM64.ActiveCfg = Debug|ARM64
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Debug|ARM64.Build.0 = Debug|ARM64
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Debug|x64.ActiveCfg = Debug|x64
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Debug|x64.Build.0 = Debug|x64
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Debug|x86.ActiveCfg = Debug|Win32
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Debug|x86.Build.0 = Debug|Win32
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Release|Any CPU.ActiveCfg = Release|Win32
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Release|ARM64.ActiveCfg = Release|ARM64
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Release|ARM64.Build.0 = Release|ARM64
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Release|x64.ActiveCfg = Release|x64
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Release|x64.Build.0 = Release|x64
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Release|x86.ActiveCfg = Release|Win32
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1637,6 +1697,9 @@ Global
{608A8D5A-A839-45F6-98E6-766FC096104A} = {3A37083C-AA67-461E-BA78-0E0A65FE0C22}
{676BA502-4220-465A-A9ED-ED22CDE4A24B} = {3A37083C-AA67-461E-BA78-0E0A65FE0C22}
{5A4FBF6D-04A2-4061-B11F-1A0E64129610} = {3A37083C-AA67-461E-BA78-0E0A65FE0C22}
{2A2D1131-273C-4E17-BCD3-8812170A4B95} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
{E3EDEC7F-A24E-4766-BB1D-6BDFBA157C51} = {2A2D1131-273C-4E17-BCD3-8812170A4B95}
{442FB943-1197-48FE-B3B6-8C1BCA1E81E4} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4B3D7591-CFEC-4762-9A07-ABE99938FB77}
Expand Down
34 changes: 19 additions & 15 deletions build/NuSpecs/AppxManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,25 @@
<ActivatableClass ActivatableClassId="Microsoft.Windows.ApplicationModel.DynamicDependency.PackageDependencyContext" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.ApplicationModel.DynamicDependency.PackageDependencyRank" ThreadingModel="both" />

<!-- Environment Manager -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.System.EnvironmentManager" ThreadingModel="both" />
<!-- Deployment -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManager" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentResult" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions" ThreadingModel="both" />

<!-- VersionInfo -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.ApplicationModel.WindowsAppRuntime.ReleaseInfo" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.ApplicationModel.WindowsAppRuntime.RuntimeInfo" ThreadingModel="both" />

<!-- AppLifecycle -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.AppLifecycle.ActivationRegistrationManager" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.AppLifecycle.AppInstance" ThreadingModel="both" />

<!-- AppNotifications -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.AppNotifications.AppNotificationManager" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.AppNotifications.AppNotification" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.AppNotifications.AppNotificationProgressData" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.AppNotifications.AppNotificationActivatedEventArgs" ThreadingModel="both" />

<!-- PushNotifications -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.PushNotifications.PushNotificationChannel" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.PushNotifications.PushNotificationCreateChannelResult" ThreadingModel="both" />
Expand All @@ -49,22 +61,14 @@
<ActivatableClass ActivatableClassId="Microsoft.Windows.PushNotifications.PushNotificationRegistrationToken" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.PushNotifications.PushNotificationManager" ThreadingModel="both" />

<!-- Deployment -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManager" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentResult" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions" ThreadingModel="both" />
<!-- AccessControl -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.Security.AccessControl.SecurityDescriptorHelpers" ThreadingModel="both" />

<!-- Environment Manager -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.System.EnvironmentManager" ThreadingModel="both" />

<!-- PowerNotifications -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.System.Power.PowerManager" ThreadingModel="both" />

<!-- AppNotifications -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.AppNotifications.AppNotificationManager" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.AppNotifications.AppNotification" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.AppNotifications.AppNotificationProgressData" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="Microsoft.Windows.AppNotifications.AppNotificationActivatedEventArgs" ThreadingModel="both" />
DrusTheAxe marked this conversation as resolved.
Show resolved Hide resolved

<!-- AccessControl -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.Security.AccessControl.SecurityDescriptorHelpers" ThreadingModel="both" />
</InProcessServer>
</Extension>
</Extensions>
Expand Down
28 changes: 28 additions & 0 deletions dev/Common/WindowsAppRuntime.VersionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@

#include "WindowsAppRuntime.VersionInfo.h"

// Function prototype of the function exported by the resource DLL
// (defined later in the build pipeline so we can't #include a header from there)
STDAPI_(const void*) WindowsAppRuntime_GetVersionInfo();

static std::wstring g_test_frameworkPackageFamilyName;
static std::wstring g_test_mainPackageFamilyName;
static std::atomic<const ::Microsoft::WindowsAppSDK::VersionInfo*> g_versionInfo{};

static const ::Microsoft::WindowsAppSDK::VersionInfo c_noVersionInfo{};

namespace Microsoft::WindowsAppRuntime::VersionInfo
{
Expand Down Expand Up @@ -39,6 +46,21 @@ class RuntimeInformation
return mainPackageFamilyName;
}

public:
static const ::Microsoft::WindowsAppSDK::VersionInfo* GetVersionInfo()
{
if (!g_versionInfo)
{
static wil::unique_hmodule module{ LoadResourceModule() };

auto getVersionInfo{ GetProcAddressByFunctionDeclaration(module.get(), WindowsAppRuntime_GetVersionInfo) };
THROW_LAST_ERROR_IF_NULL(getVersionInfo);

g_versionInfo = static_cast<const ::Microsoft::WindowsAppSDK::VersionInfo*>(getVersionInfo());
}
return g_versionInfo;
}

private:
static std::wstring LoadStringWFromResource(uint32_t id)
{
Expand Down Expand Up @@ -115,3 +137,9 @@ STDAPI WindowsAppRuntime_VersionInfo_TestInitialize(
return S_OK;
}
CATCH_RETURN();

const ::Microsoft::WindowsAppSDK::VersionInfo* Microsoft::WindowsAppSDK::GetVersionInfo()
{
const auto versionInfo{ ::Microsoft::WindowsAppRuntime::VersionInfo::RuntimeInformation::GetVersionInfo() };
return !versionInfo ? &c_noVersionInfo : versionInfo;
}
70 changes: 70 additions & 0 deletions dev/Common/WindowsAppRuntime.VersionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,76 @@ inline void TestShutdown()
WindowsAppRuntime_VersionInfo_TestInitialize(nullptr, nullptr);
}
}

namespace Microsoft::WindowsAppSDK
{
/// Run-time query'able version information for the Windows App SDK.
struct VersionInfo
{
/// Run-time query'able version information for the Windows App SDK release
struct Release
{
/// The major version of the Windows App SDK release.
uint16_t Major;

/// The minor version of the Windows App SDK release.
uint16_t Minor;

/// The patch version of the Windows App SDK release.
uint16_t Patch;

/// The major and minor version of the Windows App SDK release, encoded as a uint32_t (0xMMMMNNNN where M=major, N=minor).
uint32_t MajorMinor;

/// The Windows App SDK release's channel; for example, "preview", or empty string for stable.
PCWSTR Channel;

/// The Windows App SDK release's version tag; for example, "preview2", or empty string for stable.
PCWSTR VersionTag;

/// The Windows App SDK release's short-form version tag; for example, "p2", or empty string for stable.
PCWSTR VersionShortTag;
} Release;

/// Run-time query'able version information for the Windows App SDK runtime
struct Runtime
{
struct Identity
{
/// The Windows App SDK runtime's package identity's Publisher.
PCWSTR Publisher;

/// The Windows App SDK runtime's package identity's PublisherId.
PCWSTR PublisherId;
} Identity;

struct Version
{
/// The major version of the Windows App SDK runtime; for example, 1000.
uint16_t Major;

/// The minor version of the Windows App SDK runtime; for example, 446.
uint16_t Minor;

/// The build version of the Windows App SDK runtime; for example, 804.
uint16_t Build;

/// The revision version of the Windows App SDK runtime; for example, 0.
uint16_t Revision;

/// The version of the Windows App SDK runtime, as a uint64l for example, 0x03E801BE03240000.
uint64_t UInt64;

/// The version of the Windows App SDK runtime, as a string (const wchar_t*); for example, "1000.446.804.0".
PCWSTR DotQuadString;
} Version;
} Runtime;
};

/// Return the version information
/// @note the return value is never null.
const VersionInfo* GetVersionInfo();
}
#endif // defined(__cplusplus)

#endif // __MICROSFT_WINDOWSAPPRUNTIME_VERSIONINFO_H
52 changes: 52 additions & 0 deletions dev/VersionInfo/VersionInfo.ReleaseInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include <pch.h>

#include "VersionInfo.ReleaseInfo.h"

#include <Microsoft.Windows.ApplicationModel.WindowsAppRuntime.ReleaseInfo.g.cpp>

#include <WindowsAppRuntime.VersionInfo.h>

namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implementation
{
uint16_t ReleaseInfo::Major()
{
return GetVersionInfo().Release.Major;
}
uint16_t ReleaseInfo::Minor()
{
return GetVersionInfo().Release.Minor;
}
uint16_t ReleaseInfo::Patch()
{
return GetVersionInfo().Release.Patch;
}
hstring ReleaseInfo::VersionTag()
{
return GetVersionInfo().Release.VersionTag;
}
hstring ReleaseInfo::AsString()
{
WCHAR s[64]{};

const auto& release{ GetVersionInfo().Release };
PCWSTR versionTag{ release.VersionTag };
if (versionTag && (versionTag[0] != L'\0'))
{
THROW_IF_FAILED(StringCchPrintfW(s, ARRAYSIZE(s), L"%hu.%hu-%s", release.Major, release.Minor, versionTag));
}
else
{
THROW_IF_FAILED(StringCchPrintfW(s, ARRAYSIZE(s), L"%hu.%hu.%hu", release.Major, release.Minor, release.Patch));
}
return winrt::hstring{ s };
}

const ::Microsoft::WindowsAppSDK::VersionInfo& ReleaseInfo::GetVersionInfo()
{
const ::Microsoft::WindowsAppSDK::VersionInfo* versionInfo{ ::Microsoft::WindowsAppSDK::GetVersionInfo() };
return *versionInfo;
}
}
29 changes: 29 additions & 0 deletions dev/VersionInfo/VersionInfo.ReleaseInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#pragma once

#include <Microsoft.Windows.ApplicationModel.WindowsAppRuntime.ReleaseInfo.g.h>

namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implementation
{
struct ReleaseInfo
{
ReleaseInfo() = default;

static uint16_t Major();
static uint16_t Minor();
static uint16_t Patch();
static hstring VersionTag();
static hstring AsString();

private:
static const ::Microsoft::WindowsAppSDK::VersionInfo& GetVersionInfo();
};
}
namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::factory_implementation
{
struct ReleaseInfo : ReleaseInfoT<ReleaseInfo, implementation::ReleaseInfo>
{
};
}
35 changes: 35 additions & 0 deletions dev/VersionInfo/VersionInfo.RuntimeInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include <pch.h>

#include "VersionInfo.RuntimeInfo.h"

#include <Microsoft.Windows.ApplicationModel.WindowsAppRuntime.RuntimeInfo.g.cpp>

namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implementation
{
winrt::Windows::ApplicationModel::PackageVersion RuntimeInfo::Version()
{
const auto& version{ GetVersionInfo().Runtime.Version };
return winrt::Windows::ApplicationModel::PackageVersion{ version.Major, version.Minor, version.Build, version.Revision };
}
hstring RuntimeInfo::AsString()
{
PCWSTR dotQuadString{ GetVersionInfo().Runtime.Version.DotQuadString };
if (dotQuadString && (dotQuadString[0] != '\0'))
{
return winrt::hstring{ dotQuadString };
}
else
{
return winrt::hstring{};
}
}

const ::Microsoft::WindowsAppSDK::VersionInfo& RuntimeInfo::GetVersionInfo()
{
const ::Microsoft::WindowsAppSDK::VersionInfo* versionInfo{ ::Microsoft::WindowsAppSDK::GetVersionInfo() };
return *versionInfo;
}
}
Loading