Support for FileTypeAssociation registration. (#308)

Initial implementation of file type association registrations for Win32. Also have basic functional tests up and running for both Win32 and Packaged Win32.

The tests now require elevation, in order to install the test apps cert. Also with this change we switch to TAEF for our test harness.
This commit is contained in:
Scott Darnell 2020-11-30 10:13:20 -08:00 коммит произвёл GitHub
Родитель 4b62b4c143
Коммит 727a326cba
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
57 изменённых файлов: 1958 добавлений и 839 удалений

Просмотреть файл

@ -19,9 +19,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppShared", "test\CppShared
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProjectReunion_DLL", "dev\ProjectReunion_DLL\ProjectReunion_DLL.vcxproj", "{B73AD907-6164-4294-88FB-F3C9C10DA1F1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppTest_Win32", "test\CppTest\CppTest.vcxproj", "{C62688A1-16A0-4729-B6ED-842F4FAA29F3}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppTest_UWP", "test\CppTest_UWP\CppTest_UWP.vcxproj", "{B1A6F5EC-5418-4354-BACF-F7D998EE960D}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppTest", "test\CppTest\CppTest.vcxproj", "{C62688A1-16A0-4729-B6ED-842F4FAA29F3}"
ProjectSection(ProjectDependencies) = postProject
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9} = {A3FBA80D-5B35-471F-9A45-DB4B29E195B9}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AppLifecycle", "AppLifecycle", "{3DE93B2F-F887-437D-B512-6B1024ABA290}"
EndProject
@ -29,12 +30,25 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppLifecycle", "dev\AppLife
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppLifecycle", "test\AppLifecycle\AppLifecycle.vcxitems", "{80E07022-9E99-44FE-B875-901FB6C82F52}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestApps", "TestApps", "{AC5FFC80-92FE-4933-BED2-EC5519AC4440}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppLifecycleTestApp", "test\TestApps\AppLifecycleTestApp\AppLifecycleTestApp.vcxproj", "{7C502995-59C3-483B-86BA-815985353633}"
EndProject
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "AppLifecycleTestPackage", "test\TestApps\AppLifecycleTestPackage\AppLifecycleTestPackage.wapproj", "{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}"
ProjectSection(ProjectDependencies) = postProject
{B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "inc", "test\inc\inc.vcxitems", "{B567FE2E-3A03-48D0-B2B5-760CDEC35891}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
test\CppShared\CppShared.vcxitems*{682ded8c-3a27-48cd-866d-e853ea2024de}*SharedItemsImports = 9
test\inc\inc.vcxitems*{7c502995-59c3-483b-86ba-815985353633}*SharedItemsImports = 4
test\AppLifecycle\AppLifecycle.vcxitems*{80e07022-9e99-44fe-b875-901fb6c82f52}*SharedItemsImports = 9
test\CppShared\CppShared.vcxitems*{b1a6f5ec-5418-4354-bacf-f7d998ee960d}*SharedItemsImports = 4
test\inc\inc.vcxitems*{b567fe2e-3a03-48d0-b2b5-760cdec35891}*SharedItemsImports = 9
test\CppShared\CppShared.vcxitems*{c62688a1-16a0-4729-b6ed-842f4faa29f3}*SharedItemsImports = 4
test\inc\inc.vcxitems*{c62688a1-16a0-4729-b6ed-842f4faa29f3}*SharedItemsImports = 4
dev\AppLifecycle\AppLifecycle.vcxitems*{e3a522a3-6635-4a42-bded-1af46a15f63c}*SharedItemsImports = 9
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -109,45 +123,75 @@ Global
{C62688A1-16A0-4729-B6ED-842F4FAA29F3}.Release|x64.Build.0 = Release|x64
{C62688A1-16A0-4729-B6ED-842F4FAA29F3}.Release|x86.ActiveCfg = Release|Win32
{C62688A1-16A0-4729-B6ED-842F4FAA29F3}.Release|x86.Build.0 = Release|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|Any CPU.ActiveCfg = Release|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|Any CPU.Build.0 = Release|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|Any CPU.Deploy.0 = Release|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|ARM.ActiveCfg = Debug|ARM
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|ARM.Build.0 = Debug|ARM
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|ARM.Deploy.0 = Debug|ARM
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|ARM64.ActiveCfg = Debug|ARM64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|ARM64.Build.0 = Debug|ARM64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|ARM64.Deploy.0 = Debug|ARM64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|x64.ActiveCfg = Debug|x64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|x64.Build.0 = Debug|x64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|x64.Deploy.0 = Debug|x64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|x86.ActiveCfg = Debug|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|x86.Build.0 = Debug|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug_test|x86.Deploy.0 = Debug|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug|Any CPU.ActiveCfg = Debug|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug|ARM.ActiveCfg = Debug|ARM
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug|ARM.Build.0 = Debug|ARM
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug|ARM.Deploy.0 = Debug|ARM
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug|ARM64.ActiveCfg = Debug|ARM64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug|ARM64.Deploy.0 = Debug|ARM64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug|x64.ActiveCfg = Debug|x64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug|x64.Build.0 = Debug|x64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug|x64.Deploy.0 = Debug|x64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug|x86.ActiveCfg = Debug|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug|x86.Build.0 = Debug|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Debug|x86.Deploy.0 = Debug|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Release|Any CPU.ActiveCfg = Release|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Release|ARM.ActiveCfg = Release|ARM
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Release|ARM.Build.0 = Release|ARM
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Release|ARM.Deploy.0 = Release|ARM
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Release|ARM64.ActiveCfg = Release|ARM64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Release|ARM64.Deploy.0 = Release|ARM64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Release|x64.ActiveCfg = Release|x64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Release|x64.Build.0 = Release|x64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Release|x64.Deploy.0 = Release|x64
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Release|x86.ActiveCfg = Release|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Release|x86.Build.0 = Release|Win32
{B1A6F5EC-5418-4354-BACF-F7D998EE960D}.Release|x86.Deploy.0 = Release|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug_test|Any CPU.ActiveCfg = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug_test|Any CPU.Build.0 = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug_test|ARM.ActiveCfg = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug_test|ARM.Build.0 = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug_test|ARM64.ActiveCfg = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug_test|ARM64.Build.0 = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug_test|x64.ActiveCfg = Debug|x64
{7C502995-59C3-483B-86BA-815985353633}.Debug_test|x64.Build.0 = Debug|x64
{7C502995-59C3-483B-86BA-815985353633}.Debug_test|x86.ActiveCfg = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug_test|x86.Build.0 = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug|Any CPU.ActiveCfg = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug|ARM.ActiveCfg = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug|ARM64.ActiveCfg = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug|x64.ActiveCfg = Debug|x64
{7C502995-59C3-483B-86BA-815985353633}.Debug|x64.Build.0 = Debug|x64
{7C502995-59C3-483B-86BA-815985353633}.Debug|x86.ActiveCfg = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Debug|x86.Build.0 = Debug|Win32
{7C502995-59C3-483B-86BA-815985353633}.Release|Any CPU.ActiveCfg = Release|Win32
{7C502995-59C3-483B-86BA-815985353633}.Release|ARM.ActiveCfg = Release|Win32
{7C502995-59C3-483B-86BA-815985353633}.Release|ARM64.ActiveCfg = Release|Win32
{7C502995-59C3-483B-86BA-815985353633}.Release|x64.ActiveCfg = Release|x64
{7C502995-59C3-483B-86BA-815985353633}.Release|x64.Build.0 = Release|x64
{7C502995-59C3-483B-86BA-815985353633}.Release|x86.ActiveCfg = Release|Win32
{7C502995-59C3-483B-86BA-815985353633}.Release|x86.Build.0 = Release|Win32
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|Any CPU.ActiveCfg = Debug|Any CPU
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|Any CPU.Build.0 = Debug|Any CPU
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|Any CPU.Deploy.0 = Debug|Any CPU
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|ARM.ActiveCfg = Debug|ARM
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|ARM.Build.0 = Debug|ARM
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|ARM.Deploy.0 = Debug|ARM
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|ARM64.ActiveCfg = Debug|ARM64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|ARM64.Build.0 = Debug|ARM64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|ARM64.Deploy.0 = Debug|ARM64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|x64.ActiveCfg = Debug|x64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|x64.Build.0 = Debug|x64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|x64.Deploy.0 = Debug|x64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|x86.ActiveCfg = Debug|x86
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|x86.Build.0 = Debug|x86
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug_test|x86.Deploy.0 = Debug|x86
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|ARM.ActiveCfg = Debug|ARM
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|ARM.Build.0 = Debug|ARM
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|ARM.Deploy.0 = Debug|ARM
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|ARM64.ActiveCfg = Debug|ARM64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|ARM64.Build.0 = Debug|ARM64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|ARM64.Deploy.0 = Debug|ARM64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|x64.ActiveCfg = Debug|x64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|x64.Build.0 = Debug|x64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|x64.Deploy.0 = Debug|x64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|x86.ActiveCfg = Debug|x86
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|x86.Build.0 = Debug|x86
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Debug|x86.Deploy.0 = Debug|x86
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|Any CPU.Build.0 = Release|Any CPU
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|Any CPU.Deploy.0 = Release|Any CPU
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|ARM.ActiveCfg = Release|ARM
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|ARM.Build.0 = Release|ARM
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|ARM.Deploy.0 = Release|ARM
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|ARM64.ActiveCfg = Release|ARM64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|ARM64.Build.0 = Release|ARM64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|ARM64.Deploy.0 = Release|ARM64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|x64.ActiveCfg = Release|x64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|x64.Build.0 = Release|x64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|x64.Deploy.0 = Release|x64
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|x86.ActiveCfg = Release|x86
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|x86.Build.0 = Release|x86
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -156,10 +200,13 @@ Global
{682DED8C-3A27-48CD-866D-E853EA2024DE} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
{B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
{C62688A1-16A0-4729-B6ED-842F4FAA29F3} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
{B1A6F5EC-5418-4354-BACF-F7D998EE960D} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
{3DE93B2F-F887-437D-B512-6B1024ABA290} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
{E3A522A3-6635-4A42-BDED-1AF46A15F63C} = {3DE93B2F-F887-437D-B512-6B1024ABA290}
{80E07022-9E99-44FE-B875-901FB6C82F52} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
{AC5FFC80-92FE-4933-BED2-EC5519AC4440} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
{7C502995-59C3-483B-86BA-815985353633} = {AC5FFC80-92FE-4933-BED2-EC5519AC4440}
{A3FBA80D-5B35-471F-9A45-DB4B29E195B9} = {AC5FFC80-92FE-4933-BED2-EC5519AC4440}
{B567FE2E-3A03-48D0-B2B5-760CDEC35891} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4B3D7591-CFEC-4762-9A07-ABE99938FB77}

Просмотреть файл

@ -6,71 +6,104 @@
#include "LaunchActivatedEventArgs.h"
#include "ProtocolActivatedEventArgs.h"
#include "Shared.h"
#include "FileActivatedEventArgs.h"
#include "Association.h"
namespace winrt::Microsoft::ProjectReunion::implementation
{
void ActivationRegistrationManager::RegisterForFileTypeActivation(hstring const& groupName,
hstring const& logo, array_view<hstring const> supportedFileTypes,
array_view<hstring const> supportedVerbs)
void ActivationRegistrationManager::RegisterForFileTypeActivation(
array_view<hstring const> supportedFileTypes, array_view<hstring const> supportedVerbs,
hstring const& applicationDisplayName, hstring const& logo)
{
throw hresult_not_implemented();
if (HasIdentity())
{
throw hresult_illegal_method_call();
}
auto appId = ComputeAppId();
auto type = AssociationType::File;
auto progId = ComputeProgId(appId, type);
if (supportedFileTypes.size())
{
RegisterProgId(progId.c_str(), L"", applicationDisplayName.c_str(), logo.c_str());
RegisterApplication(appId.c_str());
}
for (auto extension : supportedFileTypes)
{
RegisterFileExtension(extension.c_str());
for (auto verb : supportedVerbs)
{
auto command = GetModulePath();
command += L" ----" + c_fileArgumentString + L":" + verb.c_str() + L",%1";
RegisterVerb(progId, verb.c_str(), command);
}
RegisterAssociationHandler(appId, extension.c_str(), type);
}
}
void ActivationRegistrationManager::RegisterForProtocolActivation(hstring const& scheme,
hstring const& displayName)
hstring const& applicationDisplayName, hstring const& logo)
{
if (scheme.empty() || displayName.empty())
if (scheme.empty())
{
throw winrt::hresult_invalid_argument();
throw hresult_invalid_argument();
}
if (HasIdentity())
{
throw hresult_not_implemented();
throw hresult_illegal_method_call();
}
RegisterProtocol(scheme.c_str(), displayName.c_str());
RegisterProtocol(scheme.c_str());
auto appId = ComputeAppId();
auto type = AssociationType::Protocol;
auto progId = ComputeProgId(appId, type);
RegisterProgId(progId.c_str(), L"", applicationDisplayName.c_str(), logo.c_str());
auto command = GetModulePath();
command += L" ----" + c_protocolArgumentString + L":%1";
RegisterVerb(progId.c_str(), L"open", command);
RegisterApplication(appId.c_str());
RegisterAssociationHandler(appId, scheme.c_str(), type);
}
void ActivationRegistrationManager::RegisterForStartupActivation(hstring const& taskId,
bool isEnabled, hstring const& displayName)
void ActivationRegistrationManager::UnregisterForFileTypeActivation(hstring const& fileType)
{
throw hresult_not_implemented();
}
if (HasIdentity())
{
throw hresult_illegal_method_call();
}
void ActivationRegistrationManager::RegisterForToastActivation(hstring const& displayName)
{
throw hresult_not_implemented();
}
void ActivationRegistrationManager::UnregisterForFileTypeActivation(hstring const& groupName)
{
throw hresult_not_implemented();
auto appId = ComputeAppId();
auto type = AssociationType::File;
auto progId = ComputeProgId(appId, type);
UnregisterAssociationHandler(appId, fileType.c_str(), type);
UnregisterProgId(progId);
}
void ActivationRegistrationManager::UnregisterForProtocolActivation(hstring const& scheme)
{
if (scheme.empty())
{
throw winrt::hresult_invalid_argument();
throw hresult_invalid_argument();
}
if (HasIdentity())
{
throw hresult_not_implemented();
throw hresult_illegal_method_call();
}
UnregisterProtocol(scheme.c_str());
}
void ActivationRegistrationManager::UnregisterForStartupActivation()
{
throw hresult_not_implemented();
}
void ActivationRegistrationManager::UnregisterForToastActivation()
{
throw hresult_not_implemented();
auto appId = ComputeAppId();
auto type = AssociationType::Protocol;
auto progId = ComputeProgId(appId, type);
UnregisterAssociationHandler(appId, scheme.c_str(), type);
UnregisterProgId(progId);
}
}

Просмотреть файл

@ -10,17 +10,14 @@ namespace winrt::Microsoft::ProjectReunion::implementation
{
ActivationRegistrationManager() = default;
static void RegisterForFileTypeActivation(hstring const& groupName, hstring const& logo,
array_view<hstring const> supportedFileTypes, array_view<hstring const> supportedVerbs);
static void RegisterForProtocolActivation(hstring const& scheme, hstring const& displayName);
static void RegisterForStartupActivation(hstring const& taskId, bool isEnabled,
hstring const& displayName);
static void RegisterForToastActivation(hstring const& displayName);
static void RegisterForFileTypeActivation(array_view<hstring const> supportedFileTypes,
array_view<hstring const> supportedVerbs, hstring const& applicationDisplayName,
hstring const& logo);
static void RegisterForProtocolActivation(hstring const& scheme,
hstring const& applicationDisplayName, hstring const& logo);
static void UnregisterForFileTypeActivation(hstring const& groupName);
static void UnregisterForFileTypeActivation(hstring const& fileType);
static void UnregisterForProtocolActivation(hstring const& scheme);
static void UnregisterForStartupActivation();
static void UnregisterForToastActivation();
};
}

Просмотреть файл

@ -7,7 +7,8 @@
#include "LaunchActivatedEventArgs.h"
#include "ProtocolActivatedEventArgs.h"
#include "Shared.h"
#include "FileActivatedEventArgs.h"
#include "Association.h"
namespace winrt::Microsoft::ProjectReunion::implementation
{
@ -51,12 +52,19 @@ namespace winrt::Microsoft::ProjectReunion::implementation
auto commandLine = std::wstring(GetCommandLine());
std::tie(contractId, contractData) = ParseCommandLine(commandLine);
if (!contractId.empty() && contractId == c_protocolArgumentString)
if (!contractId.empty())
{
return winrt::make<ProtocolActivatedEventArgs>(contractData);
if (contractId == c_protocolArgumentString)
{
return make<ProtocolActivatedEventArgs>(contractData);
}
else if (contractId == c_fileArgumentString)
{
return make<FileActivatedEventArgs>(contractData);
}
}
return winrt::make<LaunchActivatedEventArgs>(commandLine);
return make<LaunchActivatedEventArgs>(commandLine);
}
}
}

Просмотреть файл

@ -10,14 +10,11 @@ namespace Microsoft.ProjectReunion
static runtimeclass ActivationRegistrationManager
{
static void RegisterForFileTypeActivation(String groupName, String logo, String[] supportedFileTypes, String[] supportedVerbs);
static void RegisterForProtocolActivation(String scheme, String displayName);
static void RegisterForStartupActivation(String taskId, Boolean isEnabled, String displayName);
static void RegisterForToastActivation(String displayName);
static void RegisterForFileTypeActivation(String[] supportedFileTypes, String[] supportedVerbs,
String applicationDisplayName, String logo);
static void RegisterForProtocolActivation(String scheme, String applicationDisplayName, String logo);
static void UnregisterForFileTypeActivation(String groupName);
static void UnregisterForFileTypeActivation(String fileType);
static void UnregisterForProtocolActivation(String scheme);
static void UnregisterForStartupActivation();
static void UnregisterForToastActivation();
};
}

Просмотреть файл

@ -16,10 +16,11 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)ActivationRegistrationManager.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)Shared.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)Association.cpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)ActivatedEventArgsBase.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)ActivationRegistrationManager.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Shared.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Association.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)FileActivatedEventArgs.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)LaunchActivatedEventArgs.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)ProtocolActivatedEventArgs.h" />
<Midl Include="$(MSBuildThisFileDirectory)AppLifecycle.idl" />

Просмотреть файл

@ -0,0 +1,453 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#include <pch.h>
#include "Association.h"
namespace winrt::Microsoft::ProjectReunion::implementation
{
HKEY GetRegistrationRoot()
{
return HKEY_CURRENT_USER;
}
bool IsFileExtension(const std::wstring& extension)
{
return (extension.at(0) == L'.');
}
std::wstring GetFullIdentityString()
{
std::wstring identityString;
WCHAR idNameBuffer[PACKAGE_FULL_NAME_MAX_LENGTH+1];
UINT32 idNameBufferLen = ARRAYSIZE(idNameBuffer);
if (::GetCurrentPackageFullName(&idNameBufferLen, idNameBuffer) == ERROR_SUCCESS)
{
identityString = idNameBuffer;
}
return identityString;
}
bool HasIdentity()
{
return !(GetFullIdentityString()).empty();
}
std::wstring GetModulePath()
{
std::wstring path(100, L'?');
uint32_t path_size{};
DWORD actual_size{};
do
{
path_size = static_cast<uint32_t>(path.size());
actual_size = ::GetModuleFileName(nullptr, path.data(), path_size);
if (actual_size + 1 > path_size)
{
path.resize(path_size * 2, L'?');
}
} while (actual_size + 1 > path_size);
path.resize(actual_size);
return path;
}
std::wstring ComputeAppId()
{
// PRF = Project Reunion Framework. A simple prefix to help identify ProgIds we compute here.
// AppId = Prefix + Hash(modulePath)
auto modulePath = GetModulePath();
std::hash<std::wstring> hasher;
auto hash = hasher(modulePath);
;
wchar_t hashString[17]{}; // 16 + 1 characters for 64bit value represented as a string with a null terminator.
THROW_IF_FAILED(StringCchPrintf(hashString, _countof(hashString), L"%I64x", hash));
std::wstring result{ c_progIdPrefix };
result += hashString;
return result;
}
// Compute a stable progId.
std::wstring ComputeProgId(AssociationType type)
{
return ComputeProgId(ComputeAppId(), type);
}
std::wstring ComputeProgId(const std::wstring& appId, AssociationType type)
{
std::wstring typeSuffix;
if (type == AssociationType::File)
{
typeSuffix = c_fileTypeProgIdSuffix;
}
else if (type == AssociationType::Protocol)
{
typeSuffix = c_protocolProgIdSuffix;
}
return std::wstring(appId + typeSuffix.c_str());
}
std::wstring CreateAssocKeyPath(const std::wstring& assoc)
{
// Example: Software\Classes\<assoc>
std::wstring path = c_softwareClassesKeyPath + assoc;
return path;
}
wil::unique_hkey CreateAssocKey(const std::wstring& assoc, REGSAM samDesired)
{
auto path = CreateAssocKeyPath(assoc.c_str());
wil::unique_hkey key;
THROW_IF_WIN32_ERROR(::RegCreateKeyEx(GetRegistrationRoot(), path.c_str(), 0, nullptr, 0,
samDesired, nullptr, key.put(), nullptr));
return key;
}
wil::unique_hkey OpenAssocKey(const std::wstring& assoc, REGSAM samDesired)
{
auto path = CreateAssocKeyPath(assoc.c_str());
wil::unique_hkey key;
THROW_IF_WIN32_ERROR(::RegOpenKeyEx(GetRegistrationRoot(), path.c_str(), 0, samDesired,
key.put()));
return key;
}
bool AssocExists(const std::wstring& assoc)
{
auto path = CreateAssocKeyPath(assoc.c_str());
wil::unique_hkey key;
if (::RegOpenKeyEx(GetRegistrationRoot(), path.c_str(), 0, KEY_READ,
key.put()) == ERROR_SUCCESS)
{
return true;
}
return false;
}
bool AssocValueExists(const std::wstring& assoc, const std::wstring& value)
{
auto path = CreateAssocKeyPath(assoc.c_str());
wil::unique_hkey key;
if (::RegOpenKeyEx(GetRegistrationRoot(), path.c_str(), 0, KEY_READ, key.put())
== ERROR_SUCCESS)
{
if (::RegQueryValueEx(key.get(), value.c_str(), 0, nullptr, nullptr, nullptr)
== ERROR_SUCCESS)
{
return true;
}
}
return false;
}
void DeleteAssocKey(const std::wstring& assoc)
{
auto path = CreateAssocKeyPath(assoc);
::RegDeleteTree(GetRegistrationRoot(), path.c_str());
}
// Registers a ProgId definition under the classes root in the registry.
wil::unique_hkey RegisterProgId(const std::wstring& progId, const std::wstring& defaultValue,
const std::wstring& applicationDisplayName, const std::wstring& logo)
{
// Example: HKEY_CURRENT_USER\Software\Classes\<progId>
auto key = CreateAssocKey(progId, KEY_WRITE);
if (!defaultValue.empty())
{
// Example: HKEY_CURRENT_USER\Software\Classes\<progId>\(Default)
THROW_IF_WIN32_ERROR(::RegSetValueEx(key.get(), nullptr, 0, REG_SZ,
reinterpret_cast<BYTE const*>(defaultValue.c_str()),
static_cast<uint32_t>((defaultValue.size() + 1) * sizeof(wchar_t))));
}
if (!applicationDisplayName.empty())
{
// Example: HKEY_CURRENT_USER\Software\Classes\<progId>\Application\ApplicationName
wil::unique_hkey applicationKey;
THROW_IF_WIN32_ERROR(::RegCreateKeyEx(key.get(), c_applicationKeyName.c_str(), 0,
nullptr, 0, KEY_WRITE, nullptr, applicationKey.put(), nullptr));
THROW_IF_WIN32_ERROR(::RegSetValueEx(applicationKey.get(), c_applicationNameKeyName.c_str(),
0, REG_SZ, reinterpret_cast<BYTE const*>(applicationDisplayName.c_str()),
static_cast<uint32_t>((applicationDisplayName.size() + 1) * sizeof(wchar_t))));
}
if (!logo.empty())
{
// Example: HKEY_CURRENT_USER\Software\Classes\<progId>\DefaultIcon\(Default)
wil::unique_hkey defaultIconKey;
THROW_IF_WIN32_ERROR(::RegCreateKeyEx(key.get(), c_defaultIconKeyName.c_str(), 0,
nullptr, 0, KEY_WRITE, nullptr, defaultIconKey.put(), nullptr));
THROW_IF_WIN32_ERROR(::RegSetValueEx(defaultIconKey.get(), nullptr, 0, REG_SZ,
reinterpret_cast<BYTE const*>(logo.c_str()),
static_cast<uint32_t>((logo.size() + 1) * sizeof(wchar_t))));
}
return key;
}
void UnregisterProgId(const std::wstring& progId)
{
DeleteAssocKey(progId);
}
std::wstring CreateApplicationKeyPath(const std::wstring& appId)
{
// Example: HKEY_CURRENT_USER\Software\Microsoft\ReunionApplications\<appId>
return std::wstring(c_applicationsKeyPath + appId + c_capabilitiesKeyPath);
}
// Creates application defined capabilities key, and registers it as a RegisteredApplication.
wil::unique_hkey CreateApplicationKey(const std::wstring& appId, REGSAM samDesired)
{
// Example: HKEY_CURRENT_USER\Software\RegisterApplications\<appId>
wil::unique_hkey registeredAppsKey;
THROW_IF_WIN32_ERROR(::RegCreateKeyEx(GetRegistrationRoot(), c_registeredApplicationsKeyPath.c_str(),
0, nullptr, 0, samDesired, nullptr, registeredAppsKey.put(), nullptr));
std::wstring applicationKeyPath = CreateApplicationKeyPath(appId);
wil::unique_hkey applicationKey;
THROW_IF_WIN32_ERROR(::RegCreateKeyEx(GetRegistrationRoot(), applicationKeyPath.c_str(),
0, nullptr, 0, samDesired, nullptr, applicationKey.put(), nullptr));
THROW_IF_WIN32_ERROR(::RegSetValueEx(registeredAppsKey.get(), appId.c_str(), 0, REG_SZ,
reinterpret_cast<BYTE const*>(applicationKeyPath.c_str()),
static_cast<uint32_t>((applicationKeyPath.size() + 1) * sizeof(wchar_t))));
return applicationKey;
}
// Looks up and opens a RegisteredApplication's capability key based on the AppId.
wil::unique_hkey OpenApplicationKey(const std::wstring& appId, REGSAM samDesired)
{
wil::unique_hkey registeredAppsKey;
THROW_IF_WIN32_ERROR(::RegOpenKeyEx(GetRegistrationRoot(), c_registeredApplicationsKeyPath.c_str(),
0, samDesired, registeredAppsKey.put()));
DWORD pathSize{ 0 };
THROW_IF_WIN32_ERROR(::RegQueryValueEx(registeredAppsKey.get(), appId.c_str(), 0, nullptr,
nullptr, &pathSize));
std::wstring applicationKeyPath(pathSize, L'\0');
THROW_IF_WIN32_ERROR(::RegQueryValueEx(registeredAppsKey.get(), appId.c_str(), 0, nullptr,
reinterpret_cast<BYTE*>(applicationKeyPath.data()),
&pathSize));
wil::unique_hkey applicationKey;
THROW_IF_WIN32_ERROR(::RegOpenKeyEx(GetRegistrationRoot(), applicationKeyPath.c_str(),
0, samDesired, applicationKey.put()));
return applicationKey;
}
void RegisterApplication(const std::wstring& appId)
{
CreateApplicationKey(appId);
}
void UnregisterApplication(const std::wstring& appId)
{
// Example: HKEY_CURRENT_USER\Software\Microsoft\ReunionApplications\<appId>\Capabilities
std::wstring capabilitiesKeyPath = c_applicationsKeyPath + appId + c_capabilitiesKeyPath;
::RegDeleteTree(GetRegistrationRoot(), capabilitiesKeyPath.c_str());
wil::unique_hkey registeredAppsKey;
if (::RegOpenKeyEx(GetRegistrationRoot(), c_registeredApplicationsKeyPath.c_str(), 0,
KEY_WRITE, registeredAppsKey.put()) == ERROR_SUCCESS)
{
::RegDeleteValue(registeredAppsKey.get(), appId.c_str());
}
}
void RegisterVerb(const std::wstring& progId, const std::wstring& verb, const std::wstring& command,
_In_opt_ const GUID* delegateExecute)
{
// Example: HKEY_CURRENT_USER\Software\Classes\<progId>\shell\<verb>\command
auto assocKey = OpenAssocKey(progId, KEY_WRITE);
auto key_path = c_shellKeyName + L"\\" + verb + L"\\" + c_commandKeyName;
wil::unique_hkey key;
THROW_IF_WIN32_ERROR(::RegCreateKeyEx(assocKey.get(), key_path.c_str(), 0, nullptr, 0,
KEY_WRITE, nullptr, key.put(), nullptr));
THROW_IF_WIN32_ERROR(::RegSetValueEx(key.get(), nullptr, 0, REG_SZ,
reinterpret_cast<BYTE const*>(command.c_str()),
static_cast<uint32_t>((command.size() + 1) * sizeof(wchar_t))));
if (delegateExecute)
{
std::wstring delegateClsid{ LR"({????????-????-????-????-????????????})" };
::StringFromGUID2(*delegateExecute, delegateClsid.data(), 39);
THROW_IF_WIN32_ERROR(::RegSetValueEx(key.get(), c_delegateExecuteValueName.c_str(), 0, REG_SZ,
reinterpret_cast<BYTE const*>(delegateClsid.c_str()),
static_cast<uint32_t>((delegateClsid.size() + 1) * sizeof(wchar_t))));
}
}
void UnregisterVerb(const std::wstring& progId, const std::wstring& verb)
{
// Example: HKEY_CURRENT_USER\Software\Classes\<progId>\shell\<verb>\command
auto key_path = CreateAssocKeyPath(progId) + L"\\" + c_shellKeyName + L"\\" + verb +
L"\\" + c_commandKeyName;
::RegDeleteTree(GetRegistrationRoot(), key_path.c_str());
}
void RegisterProtocol(const std::wstring& scheme)
{
if (AssocExists(scheme) && AssocValueExists(scheme, c_urlProtocolValueName))
{
// Protocol already exists.
return;
}
if (AssocExists(scheme))
{
// ProgId exists, but isn't a protocol.
throw std::invalid_argument("scheme");
}
// A protocol is defined as a special progId that contains a value at the root named
// "URL Protocol". This is similar to how file types are defined in the same location,
// but always start with a period.
// Example: HKEY_CURRENT_USER\Software\Classes\<scheme>
std::wstring defaultValue = c_urlDefaultValuePrefix + scheme;
auto key = RegisterProgId(scheme, defaultValue);
// Example: HKEY_CURRENT_USER\Software\Classes\<scheme>\URL Protocol
std::wstring emptyValue{ L"" };
THROW_IF_WIN32_ERROR(::RegSetValueEx(key.get(), c_urlProtocolValueName.c_str(), 0,
REG_SZ, reinterpret_cast<BYTE const*>(emptyValue.c_str()),
static_cast<uint32_t>((emptyValue.size() + 1) * sizeof(wchar_t))));
}
void UnregisterProtocol(const std::wstring& scheme)
{
DeleteAssocKey(scheme);
}
void RegisterFileExtension(const std::wstring& extension)
{
if (!IsFileExtension(extension))
{
throw winrt::hresult_invalid_argument();
}
CreateAssocKey(extension, KEY_WRITE);
}
void UnregisterFileExtension(const std::wstring& extension)
{
if (!IsFileExtension(extension))
{
throw winrt::hresult_invalid_argument();
}
DeleteAssocKey(extension);
}
std::wstring CreateCapabilitySubKeyPath(AssociationType type)
{
std::wstring subKeyPath;
if (type == AssociationType::File)
{
subKeyPath = L"FileAssociations";
}
else if (type == AssociationType::Protocol)
{
subKeyPath = L"UrlAssociations";
}
else
{
throw winrt::hresult_illegal_method_call();
}
return subKeyPath;
}
void RegisterAssociationHandler(const std::wstring& handlerAppId, const std::wstring& association,
AssociationType type)
{
if (type == AssociationType::File && !IsFileExtension(association))
{
throw std::invalid_argument("association");
}
if (!AssocExists(association))
{
throw std::invalid_argument("association");
}
// Enable the handler to be a part of user choice.
auto subKeyPath = CreateCapabilitySubKeyPath(type);
auto applicationKey = OpenApplicationKey(handlerAppId, KEY_READ | KEY_WRITE);
// Example: HKEY_CURRENT_USER\Software\Microsoft\ReunionApplications\<appId>\Capabilities\[URLAssociations/FileAssociations]
wil::unique_hkey subKey;
THROW_IF_WIN32_ERROR(::RegCreateKeyEx(applicationKey.get(), subKeyPath.c_str(), 0, nullptr,
0, KEY_WRITE, nullptr, subKey.put(), nullptr));
// The entries here link a file extension or protocol scheme to a specific ProgId that handles the activation.
// Example: Name: <association>
// Example: Value: <progId>
auto progId = ComputeProgId(handlerAppId, type);
THROW_IF_WIN32_ERROR(::RegSetValueEx(subKey.get(), association.c_str(), 0, REG_SZ,
reinterpret_cast<BYTE const*>(progId.c_str()),
static_cast<uint32_t>((progId.size() + 1) * sizeof(wchar_t))));
// If it's a file type handler, it needs additional entries in order to be enumerated.
if (type == AssociationType::File)
{
wil::unique_hkey openWithKey;
auto assocKey = OpenAssocKey(association, KEY_WRITE);
// Example: HKEY_CURRENT_USER\Software\Classes\<association>\OpenWithProgids
THROW_IF_WIN32_ERROR(::RegCreateKeyEx(assocKey.get(), c_openWithProgIdsKeyName.c_str(),
0, nullptr, 0, KEY_WRITE, nullptr, openWithKey.put(), nullptr));
// Example: Name: <progId>
// Value is unused.
THROW_IF_WIN32_ERROR(::RegSetValueEx(openWithKey.get(), progId.c_str(), 0, REG_SZ,
nullptr, 0));
}
}
void UnregisterAssociationHandler(const std::wstring& handlerAppId, const std::wstring& association,
AssociationType type)
{
if (type == AssociationType::File && !IsFileExtension(association))
{
throw std::invalid_argument("association");
}
// Example: HKEY_CURRENT_USER\Software\Microsoft\ReunionApplications\<appId>\Capabilities\[URLAssociations/FileAssociations]\<association>
auto subKeyPath = CreateCapabilitySubKeyPath(type);
auto applicationKey = OpenApplicationKey(handlerAppId, KEY_READ | KEY_WRITE);
wil::unique_hkey subKey;
if (::RegOpenKeyEx(applicationKey.get(), subKeyPath.c_str(), 0, KEY_WRITE,
subKey.put()) == ERROR_SUCCESS)
{
::RegDeleteValue(subKey.get(), association.c_str());
}
// Remove file type handler specific values.
if (type == AssociationType::File)
{
// Example: HKEY_CURRENT_USER\Software\Classes\<association>\OpenWithProgids
wil::unique_hkey openWithKey;
auto assocKey = OpenAssocKey(association, KEY_WRITE);
if (::RegOpenKeyEx(assocKey.get(), c_openWithProgIdsKeyName.c_str(), 0, KEY_WRITE,
openWithKey.put()) == ERROR_SUCCESS)
{
auto progId = ComputeProgId(handlerAppId, type);
::RegDeleteValue(openWithKey.get(), progId.c_str());
}
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
namespace winrt::Microsoft::ProjectReunion::implementation
{
static const std::wstring c_protocolArgumentString = L"ms-protocol";
static const std::wstring c_fileArgumentString = L"ms-file";
static const std::wstring c_openWithProgIdsKeyName = L"OpenWithProgids";
static const std::wstring c_softwareClassesKeyPath = LR"(Software\Classes\)";
static const std::wstring c_progIdPrefix = L"PRF";
static const std::wstring c_fileTypeProgIdSuffix = L".File";
static const std::wstring c_protocolProgIdSuffix = L".Protocol";
static const std::wstring c_applicationKeyName = L"Application";
static const std::wstring c_applicationNameKeyName = L"ApplicationName";
static const std::wstring c_defaultIconKeyName = L"DefaultIcon";
static const std::wstring c_applicationsKeyPath = LR"(Software\Microsoft\ReunionApplications\)";
static const std::wstring c_capabilitiesKeyPath = LR"(\Capabilties)";
static const std::wstring c_registeredApplicationsKeyPath = LR"(Software\RegisteredApplications\)";
static const std::wstring c_shellKeyName = L"shell";
static const std::wstring c_commandKeyName = L"command";
static const std::wstring c_delegateExecuteValueName = L"DelegateExecute";
static const std::wstring c_urlProtocolValueName = L"URL Protocol";
static const std::wstring c_urlDefaultValuePrefix = L"URL:";
enum AssociationType
{
File,
Protocol
};
bool IsFileExtension(const std::wstring& extension);
std::wstring GetFullIdentityString();
bool HasIdentity();
std::wstring GetModulePath();
std::wstring ComputeAppId();
std::wstring ComputeProgId(AssociationType type);
std::wstring ComputeProgId(const std::wstring& appId, AssociationType type);
std::wstring CreateAssocKeyPath(const std::wstring& assoc);
wil::unique_hkey CreateAssocKey(const std::wstring& assoc, REGSAM samDesired = KEY_WRITE);
wil::unique_hkey OpenAssocKey(const std::wstring& assoc, REGSAM samDesired = KEY_READ);
void DeleteAssocKey(const std::wstring& assoc);
wil::unique_hkey RegisterProgId(const std::wstring& progId, const std::wstring& displayName = L"",
const std::wstring& applicationDisplayName = L"", const std::wstring& logo = L"");
void UnregisterProgId(const std::wstring& progId);
std::wstring CreateApplicationKeyPath();
wil::unique_hkey CreateApplicationKey(const std::wstring& progId, REGSAM samDesired = KEY_WRITE);
wil::unique_hkey OpenApplicationKey(const std::wstring& progId, REGSAM samDesired = KEY_READ);
void RegisterApplication(const std::wstring& appId);
void UnregisterApplication(const std::wstring& appId);
void RegisterVerb(const std::wstring& progId, const std::wstring& verb, const std::wstring& command,
_In_opt_ const GUID* delegateExecute = nullptr);
void UnregisterVerb(const std::wstring& progId, const std::wstring& verb);
void RegisterProtocol(const std::wstring& scheme);
void UnregisterProtocol(const std::wstring& scheme);
void RegisterFileExtension(const std::wstring& extension);
void UnregisterFileExtension(const std::wstring& extension);
void RegisterAssociationHandler(const std::wstring& handlerAppId, const std::wstring& association,
AssociationType type);
void UnregisterAssociationHandler(const std::wstring& handlerAppId, const std::wstring& association,
AssociationType type);
}

Просмотреть файл

@ -0,0 +1,53 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
#include "ActivatedEventArgsBase.h"
namespace winrt::Microsoft::ProjectReunion::implementation
{
using namespace winrt::Windows::Foundation::Collections;
using namespace winrt::Windows::ApplicationModel::Activation;
using namespace winrt::Windows::Storage;
class FileActivatedEventArgs : public winrt::implements<FileActivatedEventArgs,
ActivatedEventArgsBase, IFileActivatedEventArgs>
{
public:
FileActivatedEventArgs(const std::wstring contractData)
{
if (contractData.empty())
{
throw std::invalid_argument("contractData");
}
m_kind = ActivationKind::File;
auto delimPos = contractData.find_first_of(L",");
m_verb = contractData.substr(0, delimPos);
m_paths = contractData.substr(delimPos + 1);
m_files = winrt::single_threaded_vector<IStorageItem>();
// Currently we only support one file in the array, because the
// activation method forces a new process for each item in the array.
m_files.Append(StorageFile::GetFileFromPathAsync(m_paths.c_str()).get());
}
// IFileActivatedEventArgs
IVectorView<IStorageItem> Files()
{
return m_files.GetView();
}
winrt::hstring Verb()
{
return m_verb.c_str();
}
private:
std::wstring m_verb;
std::wstring m_paths;
IVector<IStorageItem> m_files;
};
}

Просмотреть файл

@ -12,8 +12,7 @@ namespace winrt::Microsoft::ProjectReunion::implementation
ActivatedEventArgsBase, ILaunchActivatedEventArgs>
{
public:
LaunchActivatedEventArgs(const std::wstring& args) :
m_args(args)
LaunchActivatedEventArgs(const std::wstring& args) : m_args(args)
{
m_kind = ActivationKind::Launch;
}

Просмотреть файл

@ -1,101 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#include <pch.h>
#include "Shared.h"
namespace winrt::Microsoft::ProjectReunion::implementation
{
std::wstring GetFullIdentityString()
{
std::wstring identityString;
WCHAR idNameBuffer[PACKAGE_FULL_NAME_MAX_LENGTH+1];
UINT32 idNameBufferLen = ARRAYSIZE(idNameBuffer);
if (::GetCurrentPackageFullName(&idNameBufferLen, idNameBuffer) == ERROR_SUCCESS)
{
identityString = idNameBuffer;
}
return identityString;
}
bool HasIdentity()
{
return !(GetFullIdentityString()).empty();
}
std::wstring GetModulePath()
{
std::wstring path(100, L'?');
uint32_t path_size{};
DWORD actual_size{};
do
{
path_size = static_cast<uint32_t>(path.size());
actual_size = ::GetModuleFileName(nullptr, path.data(), path_size);
if (actual_size + 1 > path_size)
{
path.resize(path_size * 2, L'?');
}
} while (actual_size + 1 > path_size);
path.resize(actual_size);
return path;
}
std::wstring CreateAssocKeyPath(PCWSTR assocName)
{
std::wstring path{ LR"(SOFTWARE\Classes\)" };
path += assocName;
return path;
}
void RegisterProtocol(PCWSTR scheme, PCWSTR displayName, _In_opt_ const GUID* delegateExecute)
{
std::wstring key_path{ CreateAssocKeyPath(scheme) };
wil::unique_hkey key;
THROW_IF_WIN32_ERROR(::RegCreateKeyEx(HKEY_CURRENT_USER, key_path.c_str(), 0, nullptr, 0,
KEY_WRITE, nullptr, key.put(), nullptr));
std::wstring defaultValue{ L"URL:" };
defaultValue += displayName;
THROW_IF_WIN32_ERROR(::RegSetValueEx(key.get(), nullptr, 0, REG_SZ,
reinterpret_cast<BYTE const*>(defaultValue.c_str()),
static_cast<uint32_t>((defaultValue.size() + 1) * sizeof(wchar_t))));
std::wstring urlProtocolValue{ L"" };
defaultValue += displayName;
THROW_IF_WIN32_ERROR(::RegSetValueEx(key.get(), L"URL Protocol", 0, REG_SZ,
reinterpret_cast<BYTE const*>(urlProtocolValue.c_str()),
static_cast<uint32_t>((urlProtocolValue.size() + 1) * sizeof(wchar_t))));
key_path += LR"(\shell\open\command)";
key.reset();
THROW_IF_WIN32_ERROR(::RegCreateKeyEx(HKEY_CURRENT_USER, key_path.c_str(), 0, nullptr, 0,
KEY_WRITE, nullptr, key.put(), nullptr));
auto command = GetModulePath();
command += L" ----" + c_protocolArgumentString + L":%1";
THROW_IF_WIN32_ERROR(::RegSetValueEx(key.get(), nullptr, 0, REG_SZ,
reinterpret_cast<BYTE const*>(command.c_str()),
static_cast<uint32_t>((command.size() + 1) * sizeof(wchar_t))));
if (delegateExecute)
{
std::wstring delegateClsid{ LR"({????????-????-????-????-????????????})" };
::StringFromGUID2(*delegateExecute, delegateClsid.data(), 39);
THROW_IF_WIN32_ERROR(::RegSetValueEx(key.get(), L"DelegateExecute", 0, REG_SZ,
reinterpret_cast<BYTE const*>(delegateClsid.c_str()),
static_cast<uint32_t>((delegateClsid.size() + 1) * sizeof(wchar_t))));
}
}
void UnregisterProtocol(PCWSTR scheme)
{
std::wstring key_path{ CreateAssocKeyPath(scheme) };
::RegDeleteTree(HKEY_CURRENT_USER, key_path.c_str());
}
}

Просмотреть файл

@ -1,16 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
namespace winrt::Microsoft::ProjectReunion::implementation
{
static const std::wstring c_protocolArgumentString = L"ms-protocol"; //L"ms-protocol"
std::wstring GetFullIdentityString();
bool HasIdentity();
std::wstring GetModulePath();
std::wstring CreateAssocKeyPath(PCWSTR assocName);
void RegisterProtocol(PCWSTR scheme, PCWSTR displayName, _In_opt_ const GUID* delegateExecute = nullptr);
void UnregisterProtocol(PCWSTR scheme);
}

Просмотреть файл

@ -14,4 +14,5 @@
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.ApplicationModel.Activation.h>
#include <winrt/Windows.Storage.h>
#include <NotificationActivationCallback.h>

Просмотреть файл

@ -9,5 +9,7 @@
<add key="ProjectReunion-Dependencies" value="https://pkgs.dev.azure.com/ms/ProjectReunion/_packaging/ProjectReunion-Dependencies/nuget/v3/index.json" />
<add key="localpackages" value="localpackages" />
<add key="MUX-Dependencies" value="https://pkgs.dev.azure.com/ms/microsoft-ui-xaml/_packaging/MUX-Dependencies/nuget/v3/index.json" />
<add key="WindowsES-External" value="https://microsoft.pkgs.visualstudio.com/_packaging/WindowsES-External/nuget/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -1,38 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#include "pch.h"
using namespace winrt::Windows::ApplicationModel;
using namespace winrt::Windows::ApplicationModel::Activation;
using namespace winrt::Microsoft::ProjectReunion;
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace ProjectReunionCppTest
{
TEST_CLASS(AppLifecycleApiTests)
{
#if PRTEST_MODE_UWP
// UWP currently is not supported by these tests.
TEST_METHOD(GetActivatedEventArgsIsNull)
{
Assert::IsTrue(winrt::Microsoft::ProjectReunion::AppLifecycle::GetActivatedEventArgs() == nullptr);
}
#else
TEST_METHOD(GetActivatedEventArgsIsNotNull)
{
Assert::IsTrue(winrt::Microsoft::ProjectReunion::AppLifecycle::GetActivatedEventArgs() != nullptr);
}
TEST_METHOD(GetActivatedEventArgsForLaunch)
{
auto args = winrt::Microsoft::ProjectReunion::AppLifecycle::GetActivatedEventArgs();
Assert::IsTrue(args != nullptr);
Assert::IsTrue(args.Kind() == ActivationKind::Launch);
auto launchArgs = args.as<LaunchActivatedEventArgs>();
Assert::IsTrue(launchArgs != nullptr);
}
#endif
};
}

Просмотреть файл

@ -14,6 +14,15 @@
<ProjectCapability Include="SourceItemsFromImports" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)ApiTests.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)FunctionalTests.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)Shared.cpp" />
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="$(TargetDir)..\AppLifecycleTestApp\AppLifecycleTestApp.exe" DestinationFolders="$(TargetDir)" TreatOutputAsContent="true" />
<CopyFileToFolders Include="$(TargetDir)..\AppLifecycleTestPackage\AppPackages\AppLifecycleTestPackage_1.0.0.0_$(Configuration)_Test\AppLifecycleTestPackage_1.0.0.0_$(Platform)_$(Configuration).msixbundle" DestinationFolders="$(TargetDir)" DestinationFileName="AppLifecycleTestPackage.msixbundle" TreatOutputAsContent="true" />
<CopyFileToFolders Include="$(TargetDir)..\AppLifecycleTestPackage\AppPackages\AppLifecycleTestPackage_1.0.0.0_$(Configuration)_Test\AppLifecycleTestPackage_1.0.0.0_$(Platform)_$(Configuration).cer" DestinationFolders="$(TargetDir)" DestinationFileName="AppLifecycleTestPackage.cer" TreatOutputAsContent="true" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)Shared.h" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<CopyFileToFolders Include="$(TargetDir)..\AppLifecycleTestApp\AppLifecycleTestApp.exe" />
<CopyFileToFolders Include="$(TargetDir)..\AppLifecycleTestPackage\AppPackages\AppLifecycleTestPackage_1.0.0.0_$(Configuration)_Test\AppLifecycleTestPackage_1.0.0.0_$(Platform)_$(Configuration).msixbundle" />
<CopyFileToFolders Include="$(TargetDir)..\AppLifecycleTestPackage\AppPackages\AppLifecycleTestPackage_1.0.0.0_$(Configuration)_Test\AppLifecycleTestPackage_1.0.0.0_$(Platform)_$(Configuration).cer" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)FunctionalTests.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)Shared.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)Shared.h" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,204 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#include "pch.h"
#include <testdef.h>
#include "Shared.h"
using namespace WEX::Common;
using namespace WEX::Logging;
using namespace WEX::TestExecution;
using namespace winrt;
using namespace winrt::Microsoft::ProjectReunion;
using namespace winrt::Windows::ApplicationModel;
using namespace winrt::Windows::ApplicationModel::Activation;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Foundation::Collections;
using namespace winrt::Windows::Management::Deployment;
using namespace winrt::Windows::Storage;
using namespace winrt::Windows::System;
// TODO: Write Register/Unregister tests that utilize the Assoc APIs to validate results.
namespace ProjectReunionCppTest
{
class AppLifecycleFunctionalTests
{
private:
wil::unique_event m_failed;
const std::wstring c_testDataFileName = L"testfile" + c_testFileExtension;
const std::wstring c_testDataFileName_Packaged = L"testfile" + c_testFileExtension_Packaged;
const std::wstring c_testPackageFile = g_deploymentDir + L"AppLifecycleTestPackage.msixbundle";
const std::wstring c_testPackageCertFile = g_deploymentDir + L"AppLifecycleTestPackage.cer";
const std::wstring c_testPackageFullName = L"AppLifecycleTestPackage_1.0.0.0_x64__ph1m9x8skttmg";
public:
BEGIN_TEST_CLASS(AppLifecycleFunctionalTests)
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"RunFixtureAs:Class", L"InteractiveUser")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassInit)
{
// Deploy packaged app to register handler through the manifest.
RunCertUtil(c_testPackageCertFile);
InstallPackage(c_testPackageFile);
// Write out some test content.
WriteContentFile(c_testDataFileName);
WriteContentFile(c_testDataFileName_Packaged);
return true;
}
TEST_CLASS_CLEANUP(ClassUninit)
{
// Swallow errors in cleanup.
try
{
DeleteContentFile(c_testDataFileName_Packaged);
DeleteContentFile(c_testDataFileName);
UninstallPackage(c_testPackageFullName);
RunCertUtil(c_testPackageCertFile, true);
}
catch (const std::exception&)
{
}
catch (const winrt::hresult_error&)
{
}
return true;
}
TEST_METHOD_SETUP(MethodInit)
{
m_failed = CreateTestEvent(c_testFailureEventName);
return true;
}
// Validate that UWP is not a supported scenario.
TEST_METHOD(GetActivatedEventArgsIsNull)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_METHOD_PROPERTY(L"RunAs", L"UAP")
END_TEST_METHOD_PROPERTIES();
VERIFY_IS_NULL(AppLifecycle::GetActivatedEventArgs());
}
TEST_METHOD(GetActivatedEventArgsIsNotNull)
{
BEGIN_TEST_METHOD_PROPERTIES()
// Run this test for both PackagedWin32 and Win32.
TEST_METHOD_PROPERTY(L"RunAs", L"{UAP,InteractiveUser}")
// UAP:Host/UAP:AppXManifest are ignored when RunAs != UAP.
TEST_METHOD_PROPERTY(L"UAP:Host", L"PackagedCwa")
TEST_METHOD_PROPERTY(L"UAP:AppXManifest", L"PackagedCwaFullTrust")
END_TEST_METHOD_PROPERTIES();
VERIFY_IS_NOT_NULL(AppLifecycle::GetActivatedEventArgs());
}
TEST_METHOD(GetActivatedEventArgsForLaunch)
{
BEGIN_TEST_METHOD_PROPERTIES()
// Run this test for both PackagedWin32 and Win32.
TEST_METHOD_PROPERTY(L"RunAs", L"{UAP,InteractiveUser}")
// UAP:Host/UAP:AppXManifest are ignored when RunAs != UAP.
TEST_METHOD_PROPERTY(L"UAP:Host", L"PackagedCwa")
TEST_METHOD_PROPERTY(L"UAP:AppXManifest", L"PackagedCwaFullTrust")
END_TEST_METHOD_PROPERTIES();
auto args = AppLifecycle::GetActivatedEventArgs();
VERIFY_IS_NOT_NULL(args);
VERIFY_ARE_EQUAL(args.Kind(), ActivationKind::Launch);
auto launchArgs = args.as<LaunchActivatedEventArgs>();
VERIFY_IS_NOT_NULL(launchArgs);
}
TEST_METHOD(GetActivatedEventArgsForProtocol_Win32)
{
// Create a named event for communicating with test app.
auto event = CreateTestEvent(c_testProtocolPhaseEventName);
// Launch the test app to register for protocol launches.
Execute(L"AppLifecycleTestApp.exe", L"/RegisterProtocol", g_deploymentDir);
// Wait for the register event.
WaitForEvent(event, m_failed);
// Launch a protocol and wait for the event to fire.
Uri launchUri{ c_testProtocolScheme + L"://this_is_a_test" };
auto launchResult = Launcher::LaunchUriAsync(launchUri).get();
VERIFY_IS_TRUE(launchResult);
// Wait for the protocol activation.
WaitForEvent(event, m_failed);
Execute(L"AppLifecycleTestApp.exe", L"/RegisterProtocol", g_deploymentDir);
// Wait for the unregister event.
WaitForEvent(event, m_failed);
}
TEST_METHOD(GetActivatedEventArgsForProtocol_PackagedWin32)
{
// Create a named event for communicating with test app.
auto event = CreateTestEvent(c_testProtocolPhaseEventName);
RunCertUtil(L"AppLifecycleTestPackage.cer");
// Deploy packaged app to register handler through the manifest.
std::wstring packagePath{ g_deploymentDir + L"\\AppLifecycleTestPackage.msixbundle" };
InstallPackage(packagePath);
// Launch a protocol and wait for the event to fire.
Uri launchUri{ c_testProtocolScheme_Packaged + L"://this_is_a_test" };
auto launchResult = Launcher::LaunchUriAsync(launchUri).get();
VERIFY_IS_TRUE(launchResult);
// Wait for the protocol activation.
WaitForEvent(event, m_failed);
}
TEST_METHOD(GetActivatedEventArgsForFile_Win32)
{
// Create a named event for communicating with test app.
auto event = CreateTestEvent(c_testFilePhaseEventName);
// Launch the test app to register for protocol launches.
Execute(L"AppLifecycleTestApp.exe", L"/RegisterFile", g_deploymentDir);
// Wait for the register event.
WaitForEvent(event, m_failed);
// Launch the file and wait for the event to fire.
auto file = OpenDocFile(c_testDataFileName);
auto launchResult = Launcher::LaunchFileAsync(file).get();
VERIFY_IS_TRUE(launchResult);
// Wait for the protocol activation.
WaitForEvent(event, m_failed);
}
TEST_METHOD(GetActivatedEventArgsForFile_PackagedWin32)
{
// Create a named event for communicating with test app.
auto event = CreateTestEvent(c_testFilePhaseEventName);
// Launch the file and wait for the event to fire.
auto file = OpenDocFile(c_testDataFileName_Packaged);
auto launchResult = Launcher::LaunchFileAsync(file).get();
VERIFY_IS_TRUE(launchResult);
// Wait for the protocol activation.
WaitForEvent(event, m_failed);
}
};
}

Просмотреть файл

@ -0,0 +1,155 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#include <pch.h>
#include <TestDef.h>
#include "Shared.h"
using namespace WEX::Common;
using namespace WEX::Logging;
using namespace WEX::TestExecution;
using namespace winrt;
using namespace winrt::Microsoft::ProjectReunion;
using namespace winrt::Windows::ApplicationModel;
using namespace winrt::Windows::ApplicationModel::Activation;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Foundation::Collections;
using namespace winrt::Windows::Management::Deployment;
using namespace winrt::Windows::Storage;
using namespace winrt::Windows::System;
namespace ProjectReunionCppTest
{
StorageFile CreateDocFile(std::wstring filename)
{
return KnownFolders::DocumentsLibrary().CreateFileAsync(filename,
CreationCollisionOption::OpenIfExists).get();
}
StorageFile OpenDocFile(std::wstring filename)
{
return KnownFolders::DocumentsLibrary().GetFileAsync(filename).get();
}
wil::unique_handle Execute(const std::wstring& command, const std::wstring& args,
const std::wstring& directory)
{
SHELLEXECUTEINFO ei{};
ei.cbSize = sizeof(SHELLEXECUTEINFO);
ei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_DOENVSUBST;
ei.lpFile = command.c_str();
ei.lpParameters = args.c_str();
ei.lpDirectory = directory.c_str();
if (!ShellExecuteEx(&ei))
{
auto lastError = GetLastError();
VERIFY_WIN32_SUCCEEDED(lastError);
}
wil::unique_handle process{ ei.hProcess };
return process;
}
void RunCertUtil(const std::wstring& path, bool removeCert)
{
std::wstring action = (removeCert ? L"-delstore" : L"-addstore");
std::wstring args{ action + L" TrustedPeople " + path };
auto process = Execute(L"%SystemRoot%\\system32\\certutil.exe",
args.c_str(), g_deploymentDir);
// Wait for the cer to be installed.
auto waitResult = WaitForSingleObject(process.get(), c_phaseTimeout);
if (waitResult != WAIT_OBJECT_0)
{
auto lastError = GetLastError();
VERIFY_WIN32_FAILED(lastError);
}
// Make sure the exitcode for the tool is success.
DWORD exitCode{};
THROW_IF_WIN32_BOOL_FALSE(GetExitCodeProcess(process.get(), &exitCode));
VERIFY_ARE_EQUAL(exitCode, 0);
}
void InstallPackage(const std::wstring& packagePath)
{
// Deploy packaged app to register handler through the manifest.
PackageManager manager;
IVector<Uri> depPackagePaths;
auto result = manager.AddPackageAsync(Uri(packagePath), depPackagePaths,
DeploymentOptions::ForceApplicationShutdown).get();
auto errorText = result.ErrorText();
auto errorCode = result.ExtendedErrorCode();
VERIFY_SUCCEEDED(errorCode, errorText.c_str());
}
void UninstallPackage(const std::wstring& packageFullName)
{
// Deploy packaged app to register handler through the manifest.
PackageManager manager;
IVector<Uri> depPackagePaths;
auto result = manager.RemovePackageAsync(packageFullName).get();
auto errorText = result.ErrorText();
auto errorCode = result.ExtendedErrorCode();
VERIFY_SUCCEEDED(errorCode, errorText.c_str());
}
wil::unique_event CreateTestEvent(const std::wstring& eventName)
{
bool alreadyExists = false;
SECURITY_ATTRIBUTES attributes = {};
wil::unique_hlocal_security_descriptor descriptor;
// Grant access to world and appcontainer.
THROW_IF_WIN32_BOOL_FALSE(ConvertStringSecurityDescriptorToSecurityDescriptor(
L"D:(A;;GA;;;WD)(A;;GA;;;AC)", SDDL_REVISION_1, &descriptor, nullptr));
attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
attributes.lpSecurityDescriptor = descriptor.get();
wil::unique_event event;
event.create(wil::EventOptions::None, eventName.c_str(), &attributes, &alreadyExists);
return event;
}
void WaitForEvent(const wil::unique_event& successEvent, const wil::unique_event& failedEvent)
{
HANDLE waitEvents[2] = { successEvent.get(), failedEvent.get() };
auto waitResult = WaitForMultipleObjects(_countof(waitEvents), waitEvents, FALSE,
c_phaseTimeout);
// If waitResult == failureEventIndex, it means the remote test process signaled a
// failure event while we were waiting for a different event.
auto failureEventIndex = WAIT_OBJECT_0 + 1;
VERIFY_ARE_NOT_EQUAL(waitResult, failureEventIndex);
VERIFY_ARE_NOT_EQUAL(waitResult, WAIT_TIMEOUT);
if (waitResult == WAIT_FAILED)
{
auto lastError = GetLastError();
VERIFY_WIN32_FAILED(lastError);
}
successEvent.ResetEvent();
failedEvent.ResetEvent();
}
const std::wstring GetDeploymentDir()
{
WEX::Common::String testDeploymentDir;
WEX::TestExecution::RuntimeParameters::TryGetValue(L"TestDeploymentDir", testDeploymentDir);
return reinterpret_cast<LPCWSTR>(testDeploymentDir.GetBuffer());
}
void WriteContentFile(std::wstring filename)
{
auto file = CreateDocFile(filename);
FileIO::WriteTextAsync(file, L"Hello, World!").get();
}
void DeleteContentFile(std::wstring filename)
{
auto file = CreateDocFile(filename);
file.DeleteAsync().get();
}
}

Просмотреть файл

@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
namespace ProjectReunionCppTest
{
winrt::Windows::Storage::StorageFile CreateDocFile(std::wstring filename);
winrt::Windows::Storage::StorageFile OpenDocFile(std::wstring filename);
wil::unique_handle Execute(const std::wstring& command, const std::wstring& args,
const std::wstring& directory);
void RunCertUtil(const std::wstring& path, bool removeCert = false);
void InstallPackage(const std::wstring& packagePath);
void UninstallPackage(const std::wstring& packageFullName);
wil::unique_event CreateTestEvent(const std::wstring& eventName);
void WaitForEvent(const wil::unique_event& successEvent, const wil::unique_event& failedEvent);
const std::wstring GetDeploymentDir();
void WriteContentFile(std::wstring filename);
void DeleteContentFile(std::wstring filename);
const std::wstring g_deploymentDir = GetDeploymentDir();
}

Просмотреть файл

@ -3,8 +3,6 @@
#include "pch.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace ProjectReunionCppTest
{
}

Просмотреть файл

@ -42,7 +42,7 @@
<RootNamespace>ProjectReunionCppTest</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectSubType>NativeUnitTestProject</ProjectSubType>
<ProjectName>CppTest_Win32</ProjectName>
<ProjectName>CppTest</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -110,6 +110,7 @@
</ImportGroup>
<ImportGroup Label="Shared">
<Import Project="..\CppShared\CppShared.vcxitems" Label="Shared" />
<Import Project="..\inc\inc.vcxitems" Label="Shared" />
</ImportGroup>
<ImportGroup Label="AppLifecycle">
<Import Project="..\AppLifecycle\AppLifecycle.vcxitems" Label="AppLifecycle" />
@ -170,8 +171,8 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions);PRTEST_MODE_UWP=0</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
@ -180,7 +181,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
@ -190,8 +191,8 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions);PRTEST_MODE_UWP=0</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
@ -200,7 +201,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@ -208,15 +209,15 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions);PRTEST_MODE_UWP=0</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
@ -224,15 +225,15 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions);PRTEST_MODE_UWP=0</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -240,15 +241,15 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);PRTEST_MODE_UWP=0</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
@ -256,15 +257,15 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);PRTEST_MODE_UWP=0</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -274,8 +275,8 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);PRTEST_MODE_UWP=0</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
@ -284,7 +285,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
@ -294,8 +295,8 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);PRTEST_MODE_UWP=0</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);;INLINE_TEST_METHOD_MARKUP</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
@ -304,7 +305,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@ -323,18 +324,28 @@
<Project>{b73ad907-6164-4294-88fb-f3c9c10da1f1}</Project>
<Private>true</Private>
</ProjectReference>
<ProjectReference Include="..\TestApps\AppLifecycleTestApp\AppLifecycleTestApp.vcxproj">
<Project>{7c502995-59c3-483b-86ba-815985353633}</Project>
</ProjectReference>
<ProjectReference Include="..\TestApps\AppLifecycleTestPackage\AppLifecycleTestPackage.wapproj">
<Project>{a3fba80d-5b35-471f-9a45-db4b29e195b9}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200519.2\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200519.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\..\packages\Taef.Redist.Wlk.10.52.200221001\build\Taef.Redist.Wlk.targets" Condition="Exists('..\..\packages\Taef.Redist.Wlk.10.52.200221001\build\Taef.Redist.Wlk.targets')" />
<Import Project="..\..\packages\Taef.TestAdapter.10.57.201103002-develop\build\Taef.TestAdapter.targets" Condition="Exists('..\..\packages\Taef.TestAdapter.10.57.201103002-develop\build\Taef.TestAdapter.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200519.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200519.2\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\..\packages\Taef.Redist.Wlk.10.52.200221001\build\Taef.Redist.Wlk.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Taef.Redist.Wlk.10.52.200221001\build\Taef.Redist.Wlk.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\..\packages\Taef.TestAdapter.10.57.201103002-develop\build\Taef.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Taef.TestAdapter.10.57.201103002-develop\build\Taef.TestAdapter.targets'))" />
</Target>
</Project>

Просмотреть файл

@ -13,6 +13,9 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="CopyFiles">
<UniqueIdentifier>{e4c26904-6433-42c2-8fea-50a89d626af1}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
@ -27,4 +30,15 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="$(TargetDir)..\AppLifecycleTestPackage\AppPackages\AppLifecycleTestPackage_1.0.0.0_$(Configuration)_Test\AppLifecycleTestPackage_1.0.0.0_$(Platform)_$(Configuration).cer">
<Filter>CopyFiles</Filter>
</CopyFileToFolders>
<CopyFileToFolders Include="$(TargetDir)..\AppLifecycleTestPackage\AppPackages\AppLifecycleTestPackage_1.0.0.0_$(Configuration)_Test\AppLifecycleTestPackage_1.0.0.0_$(Platform)_$(Configuration).msixbundle">
<Filter>CopyFiles</Filter>
</CopyFileToFolders>
<CopyFileToFolders Include="$(TargetDir)..\AppLifecycleTestApp\AppLifecycleTestApp.exe">
<Filter>CopyFiles</Filter>
</CopyFileToFolders>
</ItemGroup>
</Project>

Просмотреть файл

@ -2,4 +2,6 @@
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.200703.9" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.200519.2" targetFramework="native" />
<package id="Taef.Redist.Wlk" version="10.52.200221001" targetFramework="native" />
<package id="Taef.TestAdapter" version="10.57.201103002-develop" targetFramework="native" />
</packages>

Просмотреть файл

@ -5,12 +5,19 @@
#define PCH_H
#endif //PCH_H
#include <windows.h>
#include <sddl.h>
#include <wil/result.h>
#include <wil/cppwinrt.h>
#include <wil/resource.h>
#include "CppUnitTest.h"
#include <WexTestClass.h>
#include <winrt/Windows.ApplicationModel.Activation.h>
#include <string>
// Test-specific headers, lifted here
#include <winrt/Microsoft.ProjectReunion.h>
#include <winrt/Windows.ApplicationModel.Activation.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Management.Deployment.h>
#include <winrt/Windows.Storage.h>
#include <winrt/Windows.System.h>

Просмотреть файл

@ -1,122 +0,0 @@
#include "pch.h"
#include "App.h"
#include "MainPage.h"
using namespace winrt;
using namespace Windows::ApplicationModel;
using namespace Windows::ApplicationModel::Activation;
using namespace Windows::Foundation;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Navigation;
using namespace ProjectReunionCppTest_UWP;
using namespace ProjectReunionCppTest_UWP::implementation;
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
App::App()
{
InitializeComponent();
Suspending({ this, &App::OnSuspending });
#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException([this](IInspectable const&, UnhandledExceptionEventArgs const& e)
{
if (IsDebuggerPresent())
{
auto errorMessage = e.Message();
__debugbreak();
}
});
#endif
}
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
void App::OnLaunched(LaunchActivatedEventArgs const& e)
{
Frame rootFrame{ nullptr };
if (auto content = Window::Current().Content())
{
rootFrame = content.try_as<Frame>();
}
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (!rootFrame)
{
// Create a Frame to act as the navigation context and associate it with
// a SuspensionManager key
rootFrame = Frame();
rootFrame.NavigationFailed({ this, &App::OnNavigationFailed });
if (e.PreviousExecutionState() == ApplicationExecutionState::Terminated)
{
// Restore the saved session state only when appropriate, scheduling the
// final launch steps after the restore is complete
}
if (!e.PrelaunchActivated())
{
if (!rootFrame.Content())
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(xaml_typename<ProjectReunionCppTest_UWP::MainPage>(), box_value(e.Arguments()));
}
// Place the frame in the current Window
Window::Current().Content(rootFrame);
// Ensure the current window is active
winrt::Microsoft::VisualStudio::TestPlatform::TestExecutor::WinRTCore::UnitTestClient::CreateDefaultUI();
Window::Current().Activate();
}
}
else
{
if (!e.PrelaunchActivated())
{
if (!rootFrame.Content() )
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(xaml_typename<ProjectReunionCppTest_UWP::MainPage>(), box_value(e.Arguments()));
}
// Ensure the current window is active
winrt::Microsoft::VisualStudio::TestPlatform::TestExecutor::WinRTCore::UnitTestClient::CreateDefaultUI();
Window::Current().Activate();
}
}
winrt::Microsoft::VisualStudio::TestPlatform::TestExecutor::WinRTCore::UnitTestClient::Run(e.Arguments());
}
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
void App::OnSuspending([[maybe_unused]] IInspectable const& sender, [[maybe_unused]] SuspendingEventArgs const& e)
{
// Save application state and stop any background activity
}
/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void App::OnNavigationFailed(IInspectable const&, NavigationFailedEventArgs const& e)
{
throw hresult_error(E_FAIL, hstring(L"Failed to load Page ") + e.SourcePageType().Name);
}

Просмотреть файл

@ -1,14 +0,0 @@
#pragma once
#include "App.xaml.g.h"
namespace winrt::ProjectReunionCppTest_UWP::implementation
{
struct App : AppT<App>
{
App();
void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs const&);
void OnSuspending(IInspectable const&, Windows::ApplicationModel::SuspendingEventArgs const&);
void OnNavigationFailed(IInspectable const&, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs const&);
};
}

Просмотреть файл

@ -1,3 +0,0 @@
namespace ProjectReunionCppTest_UWP
{
}

Просмотреть файл

@ -1,7 +0,0 @@
<Application
x:Class="ProjectReunionCppTest_UWP.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ProjectReunionCppTest_UWP">
</Application>

Просмотреть файл

@ -1,210 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<ProjectGuid>{b1a6f5ec-5418-4354-bacf-f7d998ee960d}</ProjectGuid>
<RootNamespace>ProjectReunionCppTest_UWP</RootNamespace>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
<MinimalCoreWin>true</MinimalCoreWin>
<ProjectName>CppTest_UWP</ProjectName>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.18362.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17134.0</WindowsTargetPlatformMinVersion>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
<UnitTestPlatformVersion Condition="'$(UnitTestPlatformVersion)' == ''">15.0</UnitTestPlatformVersion>
<ProjectSubType>NativeUnitTestProject</ProjectSubType>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
<Import Project="..\CppShared\CppShared.vcxitems" Label="Shared" />
</ImportGroup>
<ImportGroup Label="AppLifecycle">
<Import Project="..\AppLifecycle\AppLifecycle.vcxitems" Label="AppLifecycle" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="PropertySheet.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<WarningLevel>Level4</WarningLevel>
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
<!--Temporarily disable cppwinrt heap enforcement to work around xaml compiler generated std::shared_ptr use -->
<AdditionalOptions Condition="'$(CppWinRTHeapEnforcement)'==''">/DWINRT_NO_MAKE_DETECTION %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>
</DisableSpecificWarnings>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);PRTEST_MODE_UWP=1</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory);$(OutDir)\..\ProjectReunion_DLL</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>WindowsApp.lib;%(AdditionalDependencies);Microsoft.ProjectReunion.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);PRTEST_MODE_UWP=1</PreprocessorDefinitions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory);$(OutDir)\..\ProjectReunion_DLL</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>WindowsApp.lib;%(AdditionalDependencies);Microsoft.ProjectReunion.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
<ClInclude Include="App.h">
<DependentUpon>App.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="MainPage.h">
<DependentUpon>MainPage.xaml</DependentUpon>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainPage.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Image Include="Assets\LockScreenLogo.scale-200.png" />
<Image Include="Assets\SplashScreen.scale-200.png" />
<Image Include="Assets\Square150x150Logo.scale-200.png" />
<Image Include="Assets\Square44x44Logo.scale-200.png" />
<Image Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Image Include="Assets\StoreLogo.png" />
<Image Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="App.cpp">
<DependentUpon>App.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="MainPage.cpp">
<DependentUpon>MainPage.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
</ItemGroup>
<ItemGroup>
<Midl Include="App.idl">
<DependentUpon>App.xaml</DependentUpon>
</Midl>
<Midl Include="MainPage.idl">
<DependentUpon>MainPage.xaml</DependentUpon>
</Midl>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="PropertySheet.props" />
<Text Include="readme.txt">
<DeploymentContent>false</DeploymentContent>
</Text>
</ItemGroup>
<!-- Manually added to work around Visual Studio issue -->
<ItemGroup>
<ProjectReference Include="..\..\dev\ProjectReunion_DLL\ProjectReunion_DLL.vcxproj">
<Project>{b73ad907-6164-4294-88fb-f3c9c10da1f1}</Project>
<Private>true</Private>
</ProjectReference>
</ItemGroup>
<!-- Manually added (and also the UnitTestPlatformVersion above) -->
<ItemGroup>
<SDKReference Include="CppUnitTestFramework.Universal, Version=$(UnitTestPlatformVersion)" />
<SDKReference Include="TestPlatform.Universal, Version=$(UnitTestPlatformVersion)" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200519.2\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200519.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200519.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200519.2\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>

Просмотреть файл

@ -1,60 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ApplicationDefinition Include="App.xaml" />
</ItemGroup>
<ItemGroup>
<Page Include="MainPage.xaml" />
</ItemGroup>
<ItemGroup>
<Midl Include="App.idl" />
<Midl Include="MainPage.idl" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp" />
<ClCompile Include="App.cpp" />
<ClCompile Include="MainPage.cpp" />
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<Image Include="Assets\Wide310x150Logo.scale-200.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\StoreLogo.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\Square150x150Logo.scale-200.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\Square44x44Logo.scale-200.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\SplashScreen.scale-200.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\LockScreenLogo.scale-200.png">
<Filter>Assets</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest" />
</ItemGroup>
<ItemGroup>
<Filter Include="Assets">
<UniqueIdentifier>{e48dc53e-40b1-40cb-970a-f89935452892}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Text Include="readme.txt" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,29 +0,0 @@
#include "pch.h"
#include "MainPage.h"
#include "MainPage.g.cpp"
using namespace winrt;
using namespace Windows::UI::Xaml;
namespace winrt::ProjectReunionCppTest_UWP::implementation
{
MainPage::MainPage()
{
InitializeComponent();
}
int32_t MainPage::MyProperty()
{
throw hresult_not_implemented();
}
void MainPage::MyProperty(int32_t /* value */)
{
throw hresult_not_implemented();
}
void MainPage::ClickHandler(IInspectable const&, RoutedEventArgs const&)
{
myButton().Content(box_value(L"Clicked"));
}
}

Просмотреть файл

@ -1,23 +0,0 @@
#pragma once
#include "MainPage.g.h"
namespace winrt::ProjectReunionCppTest_UWP::implementation
{
struct MainPage : MainPageT<MainPage>
{
MainPage();
int32_t MyProperty();
void MyProperty(int32_t value);
void ClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
};
}
namespace winrt::ProjectReunionCppTest_UWP::factory_implementation
{
struct MainPage : MainPageT<MainPage, implementation::MainPage>
{
};
}

Просмотреть файл

@ -1,9 +0,0 @@
namespace ProjectReunionCppTest_UWP
{
[default_interface]
runtimeclass MainPage : Windows.UI.Xaml.Controls.Page
{
MainPage();
Int32 MyProperty;
}
}

Просмотреть файл

@ -1,13 +0,0 @@
<Page
x:Class="ProjectReunionCppTest_UWP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ProjectReunionCppTest_UWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button x:Name="myButton" Click="ClickHandler">Click Me</Button>
</StackPanel>
</Page>

Просмотреть файл

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity
Name="ProjectReunionCppTestUWP"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="1ea68fdd-88ac-47b0-ba8a-747427ad986c" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Properties>
<DisplayName>ProjectReunionCppTest_UWP</DisplayName>
<PublisherDisplayName>ProjectReunion</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="ProjectReunionCppTest_UWP.App">
<uap:VisualElements DisplayName="ProjectReunionCppTest_UWP" Description="Project for a single page C++/WinRT Universal Windows Platform (UWP) app with no predefined layout"
Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>

Двоичные данные
test/CppTest_UWP/log.txt

Двоичный файл не отображается.

Просмотреть файл

@ -1 +0,0 @@
#include "pch.h"

Просмотреть файл

@ -1,25 +0,0 @@
#pragma once
#include <windows.h>
#include <unknwn.h>
#include <wil/cppwinrt.h>
#include <wil/resource.h>
#include <wil/result_macros.h>
#include <restrictederrorinfo.h>
#include <hstring.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.ApplicationModel.Activation.h>
#include <winrt/Windows.UI.Xaml.h>
#include <winrt/Windows.UI.Xaml.Controls.h>
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
#include <winrt/Windows.UI.Xaml.Data.h>
#include <winrt/Windows.UI.Xaml.Interop.h>
#include <winrt/Windows.UI.Xaml.Markup.h>
#include <winrt/Windows.UI.Xaml.Navigation.h>
#include <winrt/Microsoft.VisualStudio.TestPlatform.TestExecutor.WinRTCore.h>
#include <CppUnitTest.h>
#include <winrt/Windows.ApplicationModel.Activation.h>
// Test-specific headers, lifted here
#include <winrt/Microsoft.ProjectReunion.h>

Просмотреть файл

@ -0,0 +1,338 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{7C502995-59C3-483B-86BA-815985353633}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>AppLifecycleTestApp</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectSubType>NativeUnitTestProject</ProjectSubType>
<ProjectName>AppLifecycleTestApp</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
<Import Project="..\..\inc\inc.vcxitems" Label="Shared" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\ProjectReunion_DLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\ProjectReunion_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.ProjectReunion.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\dev\ProjectReunion_DLL\ProjectReunion_DLL.vcxproj">
<Project>{b73ad907-6164-4294-88fb-f3c9c10da1f1}</Project>
<Private>true</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200519.2\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200519.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200519.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200519.2\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

Просмотреть файл

@ -2,7 +2,7 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<!--
<!--
To customize common C++/WinRT project properties:
* right-click the project node
* expand the Common Properties item

Просмотреть файл

@ -0,0 +1,131 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#include "pch.h"
#include <testdef.h>
using namespace winrt;
using namespace winrt::Windows::Storage;
using namespace winrt::Windows::Storage::Streams;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::ApplicationModel::Activation;
using namespace winrt::Microsoft::ProjectReunion;
void SignalPhase(const std::wstring& phaseEventName)
{
wil::unique_event phaseEvent;
if(phaseEvent.try_open(phaseEventName.c_str(), EVENT_MODIFY_STATE, false))
{
phaseEvent.SetEvent();
}
}
bool IsPackagedProcess()
{
WCHAR idNameBuffer[PACKAGE_FULL_NAME_MAX_LENGTH + 1];
UINT32 idNameBufferLen = ARRAYSIZE(idNameBuffer);
if (::GetCurrentPackageFullName(&idNameBufferLen, idNameBuffer) == ERROR_SUCCESS)
{
return true;
}
return false;
}
int main()
{
auto succeeded = false;
auto args = AppLifecycle::GetActivatedEventArgs();
auto kind = args.Kind();
if (kind == ActivationKind::Launch)
{
auto launchArgs = args.as<ILaunchActivatedEventArgs>();
auto commandLine = std::wstring(launchArgs.Arguments().c_str());
auto argStart = commandLine.rfind(L"/") + 1;
if (argStart != std::wstring::npos)
{
auto argument = commandLine.substr(argStart);
if (argument.compare(L"RegisterProtocol") == 0)
{
ActivationRegistrationManager::RegisterForProtocolActivation(c_testProtocolScheme,
L"Project Reunion Test Protocol", L"logo");
// Signal event that protocol was registered.
SignalPhase(c_testProtocolPhaseEventName);
succeeded = true;
}
else if (argument.compare(L"UnregisterProtocol") == 0)
{
ActivationRegistrationManager::UnregisterForProtocolActivation(c_testProtocolScheme);
// Signal event that protocol was unregistered.
SignalPhase(c_testProtocolPhaseEventName);
succeeded = true;
}
else if (argument.compare(L"RegisterFile") == 0)
{
ActivationRegistrationManager::RegisterForFileTypeActivation({ c_testFileExtension.c_str() },
{ L"open" }, L"Project Reunion Test File Type", L"logo");
// Signal event that file was registered.
SignalPhase(c_testFilePhaseEventName);
succeeded = true;
}
else if (argument.compare(L"UnregisterFile") == 0)
{
ActivationRegistrationManager::UnregisterForFileTypeActivation(c_testFileExtension);
// Signal event that file was unregistered.
SignalPhase(c_testFilePhaseEventName);
succeeded = true;
}
}
}
else if (kind == ActivationKind::Protocol)
{
auto protocolArgs = args.as<IProtocolActivatedEventArgs>();
std::wstring expectedUri;
if (IsPackagedProcess())
{
expectedUri = c_testProtocolScheme_Packaged + L"://this_is_a_test";
}
else
{
expectedUri = c_testProtocolScheme + L"://this_is_a_test";
}
auto actualUri = protocolArgs.Uri();
if (actualUri.Equals(Uri(expectedUri)))
{
// Signal event that protocol was activated and valid.
SignalPhase(c_testProtocolPhaseEventName);
succeeded = true;
}
}
else if (kind == ActivationKind::File)
{
// Validate access to the files on the arguments.
auto fileArgs = args.as<IFileActivatedEventArgs>();
for (auto const& item : fileArgs.Files())
{
auto file = item.as<StorageFile>();
auto stream = file.OpenAsync(FileAccessMode::Read).get();
const uint32_t streamSize = static_cast<unsigned int>(stream.Size());
Buffer buffer(streamSize);
stream.ReadAsync(buffer, streamSize, InputStreamOptions::None).get();
}
// Signal event that file was activated.
SignalPhase(c_testFilePhaseEventName);
succeeded = true;
}
if (!succeeded)
{
SignalPhase(c_testFailureEventName);
}
return 0;
}

Просмотреть файл

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.200703.9" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.201113.7" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.200519.2" targetFramework="native" />
</packages>

Просмотреть файл

@ -0,0 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#include "pch.h"

Просмотреть файл

@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
#include <windows.h>
#include <unknwn.h>
#include <appmodel.h>
#include <wil/result.h>
#include <wil/cppwinrt.h>
#include <wil/resource.h>
#include <winrt/Windows.ApplicationModel.Activation.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Storage.h>
#include <winrt/Windows.Storage.Streams.h>
#include <winrt/Microsoft.ProjectReunion.h>

Просмотреть файл

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
<PropertyGroup>
<ProjectGuid>a3fba80d-5b35-471f-9a45-db4b29e195b9</ProjectGuid>
<TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<EntryPointProjectUniqueName>..\AppLifecycleTestApp\AppLifecycleTestApp.vcxproj</EntryPointProjectUniqueName>
<GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<PackageCertificateKeyFile>AppLifecycleTestPackage_TemporaryKey.pfx</PackageCertificateKeyFile>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<None Include="AppLifecycleTestPackage_TemporaryKey.pfx" />
<Content Include="Images\SplashScreen.scale-200.png" />
<Content Include="Images\LockScreenLogo.scale-200.png" />
<Content Include="Images\Square150x150Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Images\StoreLogo.png" />
<Content Include="Images\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AppLifecycleTestApp\AppLifecycleTestApp.vcxproj" />
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
</Project>

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.4 KiB

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 7.5 KiB

После

Ширина:  |  Высота:  |  Размер: 7.5 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 2.9 KiB

После

Ширина:  |  Высота:  |  Размер: 2.9 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.6 KiB

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.2 KiB

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.4 KiB

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 3.1 KiB

После

Ширина:  |  Высота:  |  Размер: 3.1 KiB

Просмотреть файл

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">
<Identity
Name="AppLifecycleTestPackage"
Publisher="CN=Microsoft"
Version="1.0.0.0" />
<Properties>
<DisplayName>AppLifecycleTestPackage</DisplayName>
<PublisherDisplayName>aelor</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.17763.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="AppLifecycleTestPackage"
Description="AppLifecycleTestPackage"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<uap:Extension Category="windows.fileTypeAssociation">
<uap:FileTypeAssociation Name="testfiletypeassociations">
<uap:SupportedFileTypes>
<uap:FileType>.reuniontestfile-packaged</uap:FileType>
</uap:SupportedFileTypes>
</uap:FileTypeAssociation>
</uap:Extension>
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="reuniontestprotocol-packaged"/>
</uap:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

14
test/inc/TestDef.h Normal file
Просмотреть файл

@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
static const int c_phaseTimeout = (30 * 1000); // 30 seconds
static const std::wstring c_testFailureEventName = L"ReunionTestFailureEventName";
static const std::wstring c_testProtocolScheme = L"reuniontestprotocol";
static const std::wstring c_testProtocolScheme_Packaged = L"reuniontestprotocol-packaged";
static const std::wstring c_testProtocolPhaseEventName = L"ReunionTestProtocolPhaseEventName";
static const std::wstring c_testFileExtension = L".reuniontestfile";
static const std::wstring c_testFileExtension_Packaged = L".reuniontestfile-packaged";
static const std::wstring c_testFilePhaseEventName = L"ReunionTestFilePhaseEventName";

19
test/inc/inc.vcxitems Normal file
Просмотреть файл

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<ItemsProjectGuid>{b567fe2e-3a03-48d0-b2b5-760cdec35891}</ItemsProjectGuid>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectCapability Include="SourceItemsFromImports" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)TestDef.h" />
</ItemGroup>
</Project>