-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Runtime query'able version information (#2889)
* VerisonInfo API * Compiles! * Slight simplification * Added C# projection. Added new bits to the Transport package * Tweak projection project name to avoid obj\... exceeding MAX_PATH (Still no LFN support? Sigh) * Added tests. Fixed package manifest definitions * Fix typo * Incorporated feedback * Incorporated API Review feedback * Drop the M.W.AM.WAR.VersionInfo projection and artifacts per the namespace change to M.W.AM.WAR (which already exists) * Changed ToString to AsString to avoid C#/WinRT warnings and language conflicts * Updated new VersionInfo test project to VS2022
- Loading branch information
1 parent
3b35a32
commit 0616493
Showing
21 changed files
with
736 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
{ | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.