diff --git a/Cpp.Build.props b/Cpp.Build.props index 5acfbdee1a..b6fa0ddecd 100644 --- a/Cpp.Build.props +++ b/Cpp.Build.props @@ -64,7 +64,6 @@ true stdcpplatest false - /await %(AdditionalOptions) _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING;_UNICODE;UNICODE;%(PreprocessorDefinitions) diff --git a/installer/PowerToysSetupCustomActionsVNext/PowerToysSetupCustomActionsVNext.vcxproj b/installer/PowerToysSetupCustomActionsVNext/PowerToysSetupCustomActionsVNext.vcxproj index 9e07a41049..bee5c02505 100644 --- a/installer/PowerToysSetupCustomActionsVNext/PowerToysSetupCustomActionsVNext.vcxproj +++ b/installer/PowerToysSetupCustomActionsVNext/PowerToysSetupCustomActionsVNext.vcxproj @@ -88,7 +88,7 @@ inc;..\..\src\;..\..\src\common\Telemetry;telemetry;%(AdditionalIncludeDirectories) - /await /Zc:twoPhase- /Wv:18 %(AdditionalOptions) + /Zc:twoPhase- /Wv:18 %(AdditionalOptions) Level4 ProgramDatabase diff --git a/src/Update/PowerToys.Update.cpp b/src/Update/PowerToys.Update.cpp index 1e16598c43..5be4a80d33 100644 --- a/src/Update/PowerToys.Update.cpp +++ b/src/Update/PowerToys.Update.cpp @@ -57,7 +57,7 @@ std::optional ObtainInstaller(bool& isUpToDate) auto state = UpdateState::read(); - const auto new_version_info = get_github_version_info_async().get(); + const auto new_version_info = std::move(get_github_version_info_async()).get(); if (std::holds_alternative(*new_version_info)) { isUpToDate = true; @@ -76,7 +76,7 @@ std::optional ObtainInstaller(bool& isUpToDate) // Cleanup old updates before downloading the latest updating::cleanup_updates(); - auto downloaded_installer = download_new_version(std::get(*new_version_info)).get(); + auto downloaded_installer = std::move(download_new_version_async(std::get(*new_version_info))).get(); if (!downloaded_installer) { Logger::error("Couldn't download new installer"); diff --git a/src/common/updating/installer.cpp b/src/common/updating/installer.cpp index 2be4a97c5f..0e491392d5 100644 --- a/src/common/updating/installer.cpp +++ b/src/common/updating/installer.cpp @@ -18,7 +18,7 @@ namespace // Strings in this namespace should not be localized namespace updating { - std::future uninstall_previous_msix_version_async() + winrt::Windows::Foundation::IAsyncOperation uninstall_previous_msix_version_async() { winrt::Windows::Management::Deployment::PackageManager package_manager; diff --git a/src/common/updating/installer.h b/src/common/updating/installer.h index 5f2ca4bbb9..0b3694e17d 100644 --- a/src/common/updating/installer.h +++ b/src/common/updating/installer.h @@ -2,11 +2,11 @@ #include #include -#include +#include #include namespace updating { - std::future uninstall_previous_msix_version_async(); -} \ No newline at end of file + winrt::Windows::Foundation::IAsyncOperation uninstall_previous_msix_version_async(); +} diff --git a/src/common/updating/pch.h b/src/common/updating/pch.h index 41408474c9..e57cdb04f9 100644 --- a/src/common/updating/pch.h +++ b/src/common/updating/pch.h @@ -33,6 +33,7 @@ #include #include +#include #endif //PCH_H diff --git a/src/common/updating/updating.cpp b/src/common/updating/updating.cpp index 9d80662d54..d4d6fc3a8c 100644 --- a/src/common/updating/updating.cpp +++ b/src/common/updating/updating.cpp @@ -82,11 +82,7 @@ namespace updating // prevent the warning that may show up depend on the value of the constants (#defines) #pragma warning(push) #pragma warning(disable : 4702) -#if USE_STD_EXPECTED - std::future> get_github_version_info_async(const bool prerelease) -#else - std::future> get_github_version_info_async(const bool prerelease) -#endif + wil::task get_github_version_info_async(const bool prerelease) { // If the current version starts with 0.0.*, it means we're on a local build from a farm and shouldn't check for updates. if constexpr (VERSION_MAJOR == 0 && VERSION_MINOR == 0) @@ -170,7 +166,7 @@ namespace updating return !ec ? std::optional{ installer_download_path } : std::nullopt; } - std::future> download_new_version(const new_version_download_info& new_version) + wil::task> download_new_version_async(new_version_download_info new_version) { auto installer_download_path = create_download_path(); if (!installer_download_path) diff --git a/src/common/updating/updating.h b/src/common/updating/updating.h index 148a5e5b25..4afedfa928 100644 --- a/src/common/updating/updating.h +++ b/src/common/updating/updating.h @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -16,6 +15,7 @@ #endif #include +#include namespace updating { @@ -32,13 +32,15 @@ namespace updating }; using github_version_info = std::variant; - std::future> download_new_version(const new_version_download_info& new_version); - std::filesystem::path get_pending_updates_path(); #if USE_STD_EXPECTED - std::future> get_github_version_info_async(const bool prerelease = false); + using github_version_result = std::expected; #else - std::future> get_github_version_info_async(const bool prerelease = false); + using github_version_result = nonstd::expected; #endif + + wil::task get_github_version_info_async(bool prerelease = false); + wil::task> download_new_version_async(new_version_download_info new_version); + std::filesystem::path get_pending_updates_path(); void cleanup_updates(); // non-localized diff --git a/src/common/utils/HttpClient.h b/src/common/utils/HttpClient.h index 8726368fbb..ff9b47917f 100644 --- a/src/common/utils/HttpClient.h +++ b/src/common/utils/HttpClient.h @@ -1,6 +1,7 @@ #pragma once -#include +#include +#include #include #include #include @@ -21,15 +22,15 @@ namespace http headers.UserAgent().TryParseAdd(USER_AGENT); } - std::future request(const winrt::Windows::Foundation::Uri& url) + winrt::Windows::Foundation::IAsyncOperation request(winrt::Windows::Foundation::Uri url) { auto response = co_await m_client.GetAsync(url); (void)response.EnsureSuccessStatusCode(); auto body = co_await response.Content().ReadAsStringAsync(); - co_return std::wstring(body); + co_return body; } - std::future download(const winrt::Windows::Foundation::Uri& url, const std::wstring& dstFilePath) + winrt::Windows::Foundation::IAsyncAction download(winrt::Windows::Foundation::Uri url, std::wstring dstFilePath) { auto response = co_await m_client.GetAsync(url); (void)response.EnsureSuccessStatusCode(); @@ -38,7 +39,7 @@ namespace http file_stream.Close(); } - std::future download(const winrt::Windows::Foundation::Uri& url, const std::wstring& dstFilePath, const std::function& progressUpdateCallback) + winrt::Windows::Foundation::IAsyncAction download(winrt::Windows::Foundation::Uri url, std::wstring dstFilePath, std::function progressUpdateCallback) { auto response = co_await m_client.GetAsync(url, HttpCompletionOption::ResponseHeadersRead); response.EnsureSuccessStatusCode(); diff --git a/src/modules/Workspaces/WorkspacesLauncher/WorkspacesLauncher.vcxproj b/src/modules/Workspaces/WorkspacesLauncher/WorkspacesLauncher.vcxproj index 8faf362704..046395f529 100644 --- a/src/modules/Workspaces/WorkspacesLauncher/WorkspacesLauncher.vcxproj +++ b/src/modules/Workspaces/WorkspacesLauncher/WorkspacesLauncher.vcxproj @@ -13,7 +13,6 @@ false true stdcpplatest - /await %(AdditionalOptions) _UNICODE;UNICODE;%(PreprocessorDefinitions) diff --git a/src/modules/Workspaces/WorkspacesSnapshotTool/WorkspacesSnapshotTool.vcxproj b/src/modules/Workspaces/WorkspacesSnapshotTool/WorkspacesSnapshotTool.vcxproj index 00f0633f11..85b4e2d79c 100644 --- a/src/modules/Workspaces/WorkspacesSnapshotTool/WorkspacesSnapshotTool.vcxproj +++ b/src/modules/Workspaces/WorkspacesSnapshotTool/WorkspacesSnapshotTool.vcxproj @@ -13,7 +13,6 @@ false true stdcpplatest - /await %(AdditionalOptions) _UNICODE;UNICODE;%(PreprocessorDefinitions) diff --git a/src/modules/Workspaces/WorkspacesWindowArranger/WorkspacesWindowArranger.vcxproj b/src/modules/Workspaces/WorkspacesWindowArranger/WorkspacesWindowArranger.vcxproj index 85d2c021ba..77b048edcb 100644 --- a/src/modules/Workspaces/WorkspacesWindowArranger/WorkspacesWindowArranger.vcxproj +++ b/src/modules/Workspaces/WorkspacesWindowArranger/WorkspacesWindowArranger.vcxproj @@ -13,7 +13,6 @@ false true stdcpplatest - /await %(AdditionalOptions) _UNICODE;UNICODE;%(PreprocessorDefinitions) diff --git a/src/modules/ZoomIt/ZoomIt/Zoomit.cpp b/src/modules/ZoomIt/ZoomIt/Zoomit.cpp index 68731f1a98..b3f736fd43 100644 --- a/src/modules/ZoomIt/ZoomIt/Zoomit.cpp +++ b/src/modules/ZoomIt/ZoomIt/Zoomit.cpp @@ -5140,7 +5140,7 @@ bool IsPenInverted( WPARAM wParam ) // Captures the specified screen using the capture APIs // //---------------------------------------------------------------------------- -std::future> CaptureScreenshotAsync(winrt::IDirect3DDevice const& device, winrt::GraphicsCaptureItem const& item, winrt::DirectXPixelFormat const& pixelFormat) +wil::task> CaptureScreenshotAsync(winrt::IDirect3DDevice const& device, winrt::GraphicsCaptureItem const& item, winrt::DirectXPixelFormat const& pixelFormat) { auto d3dDevice = GetDXGIInterfaceFromObject(device); winrt::com_ptr d3dContext; @@ -5176,9 +5176,7 @@ std::future> CaptureScreenshotAsync(winrt::IDire framePool.Close(); auto texture = GetDXGIInterfaceFromObject(frame.Surface()); - auto result = util::CopyD3DTexture(d3dDevice, texture, true); - - co_return result; + co_return util::CopyD3DTexture(d3dDevice, texture, true); } //---------------------------------------------------------------------------- @@ -5205,10 +5203,7 @@ winrt::com_ptrCaptureScreenshot(winrt::DirectXPixelFormat const auto item = util::CreateCaptureItemForMonitor(hMon); - auto capture = CaptureScreenshotAsync(device, item, pixelFormat); - capture.wait(); - - return capture.get(); + return CaptureScreenshotAsync(device, item, pixelFormat).get(); } diff --git a/src/modules/ZoomIt/ZoomIt/pch.h b/src/modules/ZoomIt/ZoomIt/pch.h index 12b0d326b2..42d134704d 100644 --- a/src/modules/ZoomIt/ZoomIt/pch.h +++ b/src/modules/ZoomIt/ZoomIt/pch.h @@ -69,6 +69,7 @@ // WIL #include #include +#include // DirectX #include diff --git a/src/modules/cmdpal/Microsoft.Terminal.UI/Microsoft.Terminal.UI.vcxproj b/src/modules/cmdpal/Microsoft.Terminal.UI/Microsoft.Terminal.UI.vcxproj index 208ad4166e..285904115d 100644 --- a/src/modules/cmdpal/Microsoft.Terminal.UI/Microsoft.Terminal.UI.vcxproj +++ b/src/modules/cmdpal/Microsoft.Terminal.UI/Microsoft.Terminal.UI.vcxproj @@ -201,7 +201,7 @@ - ..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\CmdPal\ + $(RepoRoot)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal\ obj\$(Platform)\$(Configuration)\ diff --git a/src/modules/fancyzones/FancyZones/FancyZones.vcxproj b/src/modules/fancyzones/FancyZones/FancyZones.vcxproj index cc0513799d..5ee124f77b 100644 --- a/src/modules/fancyzones/FancyZones/FancyZones.vcxproj +++ b/src/modules/fancyzones/FancyZones/FancyZones.vcxproj @@ -10,7 +10,6 @@ false true stdcpplatest - /await %(AdditionalOptions) _UNICODE;UNICODE;%(PreprocessorDefinitions) diff --git a/src/modules/keyboardmanager/KeyboardManagerEditor/KeyboardManagerEditor.vcxproj b/src/modules/keyboardmanager/KeyboardManagerEditor/KeyboardManagerEditor.vcxproj index ef6a9b29f5..880bbc7142 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEditor/KeyboardManagerEditor.vcxproj +++ b/src/modules/keyboardmanager/KeyboardManagerEditor/KeyboardManagerEditor.vcxproj @@ -14,7 +14,6 @@ false true stdcpplatest - /await %(AdditionalOptions) _UNICODE;UNICODE;_WINDOWS;%(PreprocessorDefinitions) diff --git a/src/modules/previewpane/common/PreviewHandlerCommon.csproj b/src/modules/previewpane/common/PreviewHandlerCommon.csproj index 0c3654e7ca..7e535eaa2a 100644 --- a/src/modules/previewpane/common/PreviewHandlerCommon.csproj +++ b/src/modules/previewpane/common/PreviewHandlerCommon.csproj @@ -15,6 +15,8 @@ enable {AF2349B8-E5B6-4004-9502-687C1C7730B1} PowerToys.PreviewHandlerCommon + + true diff --git a/src/runner/UpdateUtils.cpp b/src/runner/UpdateUtils.cpp index 820b926984..8c33d781a1 100644 --- a/src/runner/UpdateUtils.cpp +++ b/src/runner/UpdateUtils.cpp @@ -173,7 +173,8 @@ void ProcessNewVersionInfo(const github_version_info& version_info, // Cleanup old updates before downloading the latest updating::cleanup_updates(); - if (download_new_version(new_version_info).get()) + auto downloaded_installer = std::move(download_new_version_async(new_version_info)).get(); + if (downloaded_installer) { state.state = UpdateState::readyToInstall; state.downloadedInstallerFilename = new_version_info.installer_filename; @@ -232,7 +233,7 @@ void PeriodicUpdateWorker() bool version_info_obtained = false; try { - const auto new_version_info = get_github_version_info_async().get(); + const auto new_version_info = std::move(get_github_version_info_async()).get(); if (new_version_info.has_value()) { version_info_obtained = true; @@ -272,7 +273,7 @@ void CheckForUpdatesCallback() auto state = UpdateState::read(); try { - auto new_version_info = get_github_version_info_async().get(); + auto new_version_info = std::move(get_github_version_info_async()).get(); if (!new_version_info) { // We couldn't get a new version from github for some reason, log error diff --git a/src/runner/pch.h b/src/runner/pch.h index 537bef12d6..2c713c7099 100644 --- a/src/runner/pch.h +++ b/src/runner/pch.h @@ -32,3 +32,4 @@ #include #include +#include