From 67e6b13841a6f0d6d615fcbf9bd034436bb13732 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 1 Nov 2023 00:29:40 -0700 Subject: [PATCH 1/8] C++ 20: Move vnext to C++ 20 and C++ 20 coroutines This moves projects in vnext to build with C++ 20 and C++ 20 coroutines. This should not impact the ABI of MSRN DLLs, but may need care for cases of Folly at legacy ABI boundary. 1. Set `stdcpp20` in `React.cpp.props` 2. Remove explicit usages of `/await` to opt into coroutines TS 3. Replace `std::experimental::coroutine_handle` with `std::coroutine_handle` --- .../React.Windows.Desktop.UnitTests.vcxproj | 1 - .../Microsoft.ReactNative.Cxx.UnitTests.vcxproj | 4 ++-- .../Microsoft.ReactNative.IntegrationTests.vcxproj | 2 +- vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj | 2 +- vnext/Mso.UnitTests/Mso.UnitTests.vcxproj | 4 ++-- vnext/PropertySheets/React.Cpp.props | 4 ++-- vnext/Shared/HermesSamplingProfiler.cpp | 8 +++----- vnext/Shared/Networking/WinRTWebSocketResource.cpp | 7 +++---- vnext/Shared/Utils/CppWinrtLessExceptions.h | 5 +++-- 9 files changed, 17 insertions(+), 20 deletions(-) diff --git a/vnext/Desktop.UnitTests/React.Windows.Desktop.UnitTests.vcxproj b/vnext/Desktop.UnitTests/React.Windows.Desktop.UnitTests.vcxproj index 695663f154a..7a1bb3dd518 100644 --- a/vnext/Desktop.UnitTests/React.Windows.Desktop.UnitTests.vcxproj +++ b/vnext/Desktop.UnitTests/React.Windows.Desktop.UnitTests.vcxproj @@ -68,7 +68,6 @@ $(VCInstallDir)UnitTest\include; %(AdditionalIncludeDirectories) - %(AdditionalOptions) /await diff --git a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj index ab14d39bdbe..9ee3d3f0284 100644 --- a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +++ b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj @@ -97,7 +97,7 @@ $(IntDir)pch.pch pch.h Level4 - /await %(AdditionalOptions) /bigobj /ZH:SHA_256 + %(AdditionalOptions) /bigobj /ZH:SHA_256 $(FmtDir)\include; $(ReactNativeWindowsDir)Microsoft.ReactNative; diff --git a/vnext/Mso.UnitTests/Mso.UnitTests.vcxproj b/vnext/Mso.UnitTests/Mso.UnitTests.vcxproj index 65e4c389605..bfda7bc3af2 100644 --- a/vnext/Mso.UnitTests/Mso.UnitTests.vcxproj +++ b/vnext/Mso.UnitTests/Mso.UnitTests.vcxproj @@ -62,7 +62,7 @@ $(IntDir)pch.pch _CONSOLE;MS_TARGET_WINDOWS;MSO_MOTIFCPP;%(PreprocessorDefinitions) Level4 - /await %(AdditionalOptions) /bigobj + %(AdditionalOptions) /bigobj true Cdecl @@ -148,4 +148,4 @@ - \ No newline at end of file + diff --git a/vnext/PropertySheets/React.Cpp.props b/vnext/PropertySheets/React.Cpp.props index e9de4b2bd5b..73d245dad13 100644 --- a/vnext/PropertySheets/React.Cpp.props +++ b/vnext/PropertySheets/React.Cpp.props @@ -79,7 +79,7 @@ - stdcpp17 + stdcpp20 @@ -143,4 +143,4 @@ - \ No newline at end of file + diff --git a/vnext/Shared/HermesSamplingProfiler.cpp b/vnext/Shared/HermesSamplingProfiler.cpp index f4e9f692d9b..2e1ea3515ce 100644 --- a/vnext/Shared/HermesSamplingProfiler.cpp +++ b/vnext/Shared/HermesSamplingProfiler.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include "HermesRuntimeHolder.h" #include "HermesSamplingProfiler.h" @@ -31,10 +31,8 @@ auto resume_in_dispatcher(const IReactDispatcher &dispatcher) noexcept { void await_resume() const noexcept {} - void await_suspend(std::experimental::coroutine_handle<> resume) noexcept { - callback_ = [context = resume.address()]() noexcept { - std::experimental::coroutine_handle<>::from_address(context)(); - }; + void await_suspend(std::coroutine_handle<> resume) noexcept { + callback_ = [context = resume.address()]() noexcept { std::coroutine_handle<>::from_address(context)(); }; dispatcher_.Post(std::move(callback_)); } diff --git a/vnext/Shared/Networking/WinRTWebSocketResource.cpp b/vnext/Shared/Networking/WinRTWebSocketResource.cpp index 24d8770caf8..7e7a9d93b55 100644 --- a/vnext/Shared/Networking/WinRTWebSocketResource.cpp +++ b/vnext/Shared/Networking/WinRTWebSocketResource.cpp @@ -17,6 +17,7 @@ #include // Standard Library +#include #include using Microsoft::Common::Utilities::CheckedReinterpretCast; @@ -64,10 +65,8 @@ auto resume_in_queue(const Mso::DispatchQueue &queue) noexcept { void await_resume() const noexcept {} - void await_suspend(std::experimental::coroutine_handle<> resume) noexcept { - m_callback = [context = resume.address()]() noexcept { - std::experimental::coroutine_handle<>::from_address(context)(); - }; + void await_suspend(std::coroutine_handle<> resume) noexcept { + m_callback = [context = resume.address()]() noexcept { std::coroutine_handle<>::from_address(context)(); }; m_queue.Post(std::move(m_callback)); } diff --git a/vnext/Shared/Utils/CppWinrtLessExceptions.h b/vnext/Shared/Utils/CppWinrtLessExceptions.h index 9bd4b4fc323..83eddc1bc13 100644 --- a/vnext/Shared/Utils/CppWinrtLessExceptions.h +++ b/vnext/Shared/Utils/CppWinrtLessExceptions.h @@ -22,6 +22,7 @@ #define SHARED_UTILS_CPPWINRTLESSEXCEPTIONS_H_ #include +#include // #define DEFAULT_CPPWINRT_EXCEPTIONS #ifndef DEFAULT_CPPWINRT_EXCEPTIONS @@ -35,7 +36,7 @@ struct lessthrow_await_adapter { return async.Status() == winrt::Windows::Foundation::AsyncStatus::Completed; } - void await_suspend(std::experimental::coroutine_handle<> handle) const { + void await_suspend(std::coroutine_handle<> handle) const { auto context = winrt::capture(WINRT_IMPL_CoGetObjectContext); async.Completed([handle, context = std::move(context)](auto const &, winrt::Windows::Foundation::AsyncStatus) { @@ -43,7 +44,7 @@ struct lessthrow_await_adapter { args.data = handle.address(); auto callback = [](winrt::impl::com_callback_args *args) noexcept -> int32_t { - std::experimental::coroutine_handle<>::from_address(args->data)(); + std::coroutine_handle<>::from_address(args->data)(); return S_OK; }; From 90774cad9e2913993f4b4c7bc74d656a6b9984c2 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 1 Nov 2023 03:04:35 -0700 Subject: [PATCH 2/8] Change files --- ...ative-windows-dce01c53-5395-463d-bbfd-9162cd9f309d.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/react-native-windows-dce01c53-5395-463d-bbfd-9162cd9f309d.json diff --git a/change/react-native-windows-dce01c53-5395-463d-bbfd-9162cd9f309d.json b/change/react-native-windows-dce01c53-5395-463d-bbfd-9162cd9f309d.json new file mode 100644 index 00000000000..6f9c48cce80 --- /dev/null +++ b/change/react-native-windows-dce01c53-5395-463d-bbfd-9162cd9f309d.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "C++ 20: Move vnext to C++ 20 and C++ 20 coroutines", + "packageName": "react-native-windows", + "email": "ngerlem@fb.com", + "dependentChangeType": "patch" +} From 7486891fa5b141802e4f68bb1d37e3c40ea69f9d Mon Sep 17 00:00:00 2001 From: Chiara Mooney <34109996+chiaramooney@users.noreply.github.com> Date: Mon, 4 Dec 2023 14:06:46 -0800 Subject: [PATCH 3/8] Finixh Cpp20 update --- .../playground-win32/Playground-win32.vcxproj | 2 +- .../Utils/ImageUtils.cpp | 2 +- .../Utils/LocalBundleReader.cpp | 10 ++++----- .../Utils/LocalBundleReader.h | 8 +++---- .../Utils/UwpScriptStore.cpp | 2 +- .../Utils/UwpScriptStore.h | 4 ++-- vnext/Shared/DevSupportManager.cpp | 20 +++++++++++------- vnext/Shared/DevSupportManager.h | 21 +++++++++++++++++++ vnext/Shared/HermesSamplingProfiler.cpp | 3 +-- 9 files changed, 48 insertions(+), 24 deletions(-) diff --git a/packages/playground/windows/playground-win32/Playground-win32.vcxproj b/packages/playground/windows/playground-win32/Playground-win32.vcxproj index f2fad013b98..1712908a826 100644 --- a/packages/playground/windows/playground-win32/Playground-win32.vcxproj +++ b/packages/playground/windows/playground-win32/Playground-win32.vcxproj @@ -86,7 +86,7 @@ _DEBUG;%(PreprocessorDefinitions) - stdcpp17 + stdcpp20 diff --git a/vnext/Microsoft.ReactNative/Utils/ImageUtils.cpp b/vnext/Microsoft.ReactNative/Utils/ImageUtils.cpp index 5a3eaabb218..55b5e1d9d40 100644 --- a/vnext/Microsoft.ReactNative/Utils/ImageUtils.cpp +++ b/vnext/Microsoft.ReactNative/Utils/ImageUtils.cpp @@ -60,7 +60,7 @@ winrt::IAsyncOperation GetImageStreamAsync(ReactImag } winrt::Windows::Storage::Streams::IRandomAccessStreamWithContentType stream{openReadAsync.GetResults()}; - return stream; + co_return stream; } auto httpMethod{ diff --git a/vnext/Microsoft.ReactNative/Utils/LocalBundleReader.cpp b/vnext/Microsoft.ReactNative/Utils/LocalBundleReader.cpp index 08e5fe4d20b..fae8651eadc 100644 --- a/vnext/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +++ b/vnext/Microsoft.ReactNative/Utils/LocalBundleReader.cpp @@ -53,7 +53,7 @@ std::string GetBundleFromEmbeddedResource(const winrt::Windows::Foundation::Uri return std::string(start, start + size); } -std::future LocalBundleReader::LoadBundleAsync(const std::wstring bundleUri) { +winrt::Windows::Foundation::IAsyncOperation LocalBundleReader::LoadBundleAsync(const std::wstring bundleUri) { co_await winrt::resume_background(); winrt::Windows::Storage::StorageFile file{nullptr}; @@ -65,7 +65,7 @@ std::future LocalBundleReader::LoadBundleAsync(const std::wstring b file = co_await winrt::Windows::Storage::StorageFile::GetFileFromApplicationUriAsync(uri); } else if (bundleUri._Starts_with(L"resource://")) { winrt::Windows::Foundation::Uri uri(bundleUri); - co_return GetBundleFromEmbeddedResource(uri); + co_return winrt::to_hstring(GetBundleFromEmbeddedResource(uri)); } else { file = co_await winrt::Windows::Storage::StorageFile::GetFileFromPathAsync(bundleUri); } @@ -86,10 +86,10 @@ std::future LocalBundleReader::LoadBundleAsync(const std::wstring b reinterpret_cast(&script[0]), reinterpret_cast(&script[script.length()])}); dataReader.Close(); - co_return script; + co_return winrt::to_hstring(script); } -std::string LocalBundleReader::LoadBundle(const std::wstring &bundlePath) { +winrt::hstring LocalBundleReader::LoadBundle(const std::wstring &bundlePath) { return LoadBundleAsync(bundlePath).get(); } @@ -113,7 +113,7 @@ size_t StorageFileBigString::size() const { void StorageFileBigString::ensure() const { if (m_string.empty()) { - m_string = m_futureBuffer.get(); + m_string = winrt::to_string(m_futureBuffer.get()); } } diff --git a/vnext/Microsoft.ReactNative/Utils/LocalBundleReader.h b/vnext/Microsoft.ReactNative/Utils/LocalBundleReader.h index 8671ebf59ee..12c8bda970a 100644 --- a/vnext/Microsoft.ReactNative/Utils/LocalBundleReader.h +++ b/vnext/Microsoft.ReactNative/Utils/LocalBundleReader.h @@ -3,15 +3,15 @@ #pragma once #include -#include +#include #include namespace Microsoft::ReactNative { class LocalBundleReader { public: - static std::future LoadBundleAsync(const std::wstring bundlePath); - static std::string LoadBundle(const std::wstring &bundlePath); + static winrt::Windows::Foundation::IAsyncOperation LoadBundleAsync(const std::wstring bundleUri); + static winrt::hstring LoadBundle(const std::wstring &bundlePath); }; class StorageFileBigString : public facebook::react::JSBigString { @@ -24,7 +24,7 @@ class StorageFileBigString : public facebook::react::JSBigString { void ensure() const; private: - mutable std::future m_futureBuffer; + mutable winrt::Windows::Foundation::IAsyncOperation m_futureBuffer; mutable std::string m_string; }; diff --git a/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.cpp b/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.cpp index 59bb0c805db..eb41e63bac8 100644 --- a/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.cpp +++ b/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.cpp @@ -43,7 +43,7 @@ facebook::jsi::ScriptVersion_t UwpScriptStore::getScriptVersion(const std::strin return version; } -std::future UwpScriptStore::getScriptVersionAsync(const std::string &bundleUri) { +winrt::Windows::Foundation::IAsyncOperation UwpScriptStore::getScriptVersionAsync(const std::string &bundleUri) { co_await winrt::resume_background(); const winrt::hstring fileUrl(Microsoft::Common::Unicode::Utf8ToUtf16("ms-appx:///Bundle/" + bundleUri + ".bundle")); diff --git a/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.h b/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.h index 6b77db3f9e7..6e002a78744 100644 --- a/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.h +++ b/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include namespace Microsoft::ReactNative { @@ -16,7 +16,7 @@ class UwpScriptStore : public facebook::jsi::ScriptStore { static facebook::jsi::ScriptVersion_t GetFileVersion(const std::wstring &filePath); private: - std::future getScriptVersionAsync(const std::string &bundleUri); + winrt::Windows::Foundation::IAsyncOperation getScriptVersionAsync(const std::string &bundleUri); }; } // namespace Microsoft::ReactNative diff --git a/vnext/Shared/DevSupportManager.cpp b/vnext/Shared/DevSupportManager.cpp index a6935bb8aa9..dae89dfc915 100644 --- a/vnext/Shared/DevSupportManager.cpp +++ b/vnext/Shared/DevSupportManager.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include @@ -30,7 +32,6 @@ #include #pragma warning(pop) -#include #include #include @@ -44,7 +45,8 @@ using namespace facebook::react; namespace Microsoft::ReactNative { -std::future> GetJavaScriptFromServerAsync(const std::string &url) { +winrt::Windows::Foundation::IAsyncOperation> GetJavaScriptFromServerAsync( + const std::string &url) { winrt::Windows::Web::Http::Filters::HttpBaseProtocolFilter filter; filter.CacheControl().ReadBehavior(winrt::Windows::Web::Http::Filters::HttpCacheReadBehavior::NoCache); winrt::Windows::Web::Http::HttpClient httpClient(filter); @@ -58,8 +60,8 @@ std::future> GetJavaScriptFromServerAsync(const std try { winrt::Windows::Web::Http::HttpResponseMessage response = co_await asyncRequest; } catch (winrt::hresult_error const &e) { - co_return std::make_pair( - Microsoft::Common::Unicode::Utf16ToUtf8(e.message().c_str(), e.message().size()).c_str(), false); + co_return winrt::pair( + winrt::to_hstring(Microsoft::Common::Unicode::Utf16ToUtf8(e.message().c_str(), e.message().size()).c_str()), false); } #else co_await lessthrow_await_adapter> GetJavaScriptFromServerAsync(const std } else { error = fmt::format("Error 0x{:x} downloading {}.", static_cast(asyncRequest.ErrorCode()), url); } - co_return std::make_pair(error, false); + co_return winrt::pair(winrt::to_hstring(error), false); } winrt::Windows::Web::Http::HttpResponseMessage response = asyncRequest.GetResults(); @@ -98,7 +100,7 @@ std::future> GetJavaScriptFromServerAsync(const std result = fmt::format("HTTP Error {} downloading {}.", static_cast(response.StatusCode()), url); } - co_return std::make_pair(std::move(result), response.IsSuccessStatusCode()); + co_return winrt::pair(winrt::to_hstring(std::move(result)), response.IsSuccessStatusCode()); } void LaunchDevTools(const facebook::react::DevSettings &settings) { @@ -171,7 +173,7 @@ bool IsIgnorablePollHResult(HRESULT hr) { return hr == WININET_E_INVALID_SERVER_RESPONSE; } -std::future PollForLiveReload(const std::string &url) { +winrt::Windows::Foundation::IAsyncOperation PollForLiveReload(const std::string url) { winrt::Windows::Web::Http::HttpClient httpClient; winrt::Windows::Foundation::Uri uri(Microsoft::Common::Unicode::Utf8ToUtf16(url)); httpClient.DefaultRequestHeaders().Connection().TryParseAdd(L"keep-alive"); @@ -290,7 +292,9 @@ std::pair GetJavaScriptFromServer( inlineSourceMap, hermesBytecodeVersion); try { - return GetJavaScriptFromServerAsync(bundleUrl).get(); + auto result = GetJavaScriptFromServerAsync(bundleUrl).get(); + return std::make_pair(winrt::to_string(result.Key()), + result.Value()); } catch (winrt::hresult_error const &e) { return std::make_pair( "Error: " + Microsoft::Common::Unicode::Utf16ToUtf8(e.message().c_str(), e.message().size()), false); diff --git a/vnext/Shared/DevSupportManager.h b/vnext/Shared/DevSupportManager.h index 5c33ed1de02..5d3060e578b 100644 --- a/vnext/Shared/DevSupportManager.h +++ b/vnext/Shared/DevSupportManager.h @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -22,6 +23,26 @@ struct DevSettings; } } // namespace facebook +namespace winrt { + +template +struct pair_impl : implements, Windows::Foundation::Collections::IKeyValuePair> +{ + pair_impl(K k, V v) : m_k(k), m_v(v) {} + K Key() { return m_k; } + V Value() { return m_v; } +private: + K m_k; + V m_v; +}; + +template +Windows::Foundation::Collections::IKeyValuePair pair(K key, V value) +{ + return make>(key, value); +} +} + namespace Microsoft::ReactNative { std::pair GetJavaScriptFromServer( diff --git a/vnext/Shared/HermesSamplingProfiler.cpp b/vnext/Shared/HermesSamplingProfiler.cpp index be46cf77c41..2c25e568ee2 100644 --- a/vnext/Shared/HermesSamplingProfiler.cpp +++ b/vnext/Shared/HermesSamplingProfiler.cpp @@ -52,8 +52,7 @@ IAsyncOperation getTraceFilePath() noexcept { .count(); os << hermesDataPath.c_str() << L"\\cpu_" << now << L".cpuprofile"; - // TODO: Use C++ 20 `os.view()` to avoid a copy - co_return winrt::hstring(os.str()); + co_return winrt::hstring(os.view()); } } // namespace From 39df2ae8877e2fd8863ffb184216f071f33e4258 Mon Sep 17 00:00:00 2001 From: Chiara Mooney <34109996+chiaramooney@users.noreply.github.com> Date: Mon, 4 Dec 2023 14:51:16 -0800 Subject: [PATCH 4/8] Format --- .../Utils/LocalBundleReader.cpp | 3 +- .../Utils/UwpScriptStore.cpp | 3 +- .../Utils/UwpScriptStore.h | 3 +- vnext/Shared/DevSupportManager.cpp | 19 ++++++------ vnext/Shared/DevSupportManager.h | 31 ++++++++++--------- 5 files changed, 33 insertions(+), 26 deletions(-) diff --git a/vnext/Microsoft.ReactNative/Utils/LocalBundleReader.cpp b/vnext/Microsoft.ReactNative/Utils/LocalBundleReader.cpp index fae8651eadc..9f8d8fdcf1f 100644 --- a/vnext/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +++ b/vnext/Microsoft.ReactNative/Utils/LocalBundleReader.cpp @@ -53,7 +53,8 @@ std::string GetBundleFromEmbeddedResource(const winrt::Windows::Foundation::Uri return std::string(start, start + size); } -winrt::Windows::Foundation::IAsyncOperation LocalBundleReader::LoadBundleAsync(const std::wstring bundleUri) { +winrt::Windows::Foundation::IAsyncOperation LocalBundleReader::LoadBundleAsync( + const std::wstring bundleUri) { co_await winrt::resume_background(); winrt::Windows::Storage::StorageFile file{nullptr}; diff --git a/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.cpp b/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.cpp index eb41e63bac8..0130afcdfda 100644 --- a/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.cpp +++ b/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.cpp @@ -43,7 +43,8 @@ facebook::jsi::ScriptVersion_t UwpScriptStore::getScriptVersion(const std::strin return version; } -winrt::Windows::Foundation::IAsyncOperation UwpScriptStore::getScriptVersionAsync(const std::string &bundleUri) { +winrt::Windows::Foundation::IAsyncOperation UwpScriptStore::getScriptVersionAsync( + const std::string &bundleUri) { co_await winrt::resume_background(); const winrt::hstring fileUrl(Microsoft::Common::Unicode::Utf8ToUtf16("ms-appx:///Bundle/" + bundleUri + ".bundle")); diff --git a/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.h b/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.h index 6e002a78744..78b1ff112ae 100644 --- a/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.h +++ b/vnext/Microsoft.ReactNative/Utils/UwpScriptStore.h @@ -16,7 +16,8 @@ class UwpScriptStore : public facebook::jsi::ScriptStore { static facebook::jsi::ScriptVersion_t GetFileVersion(const std::wstring &filePath); private: - winrt::Windows::Foundation::IAsyncOperation getScriptVersionAsync(const std::string &bundleUri); + winrt::Windows::Foundation::IAsyncOperation getScriptVersionAsync( + const std::string &bundleUri); }; } // namespace Microsoft::ReactNative diff --git a/vnext/Shared/DevSupportManager.cpp b/vnext/Shared/DevSupportManager.cpp index dae89dfc915..53e54ed07d8 100644 --- a/vnext/Shared/DevSupportManager.cpp +++ b/vnext/Shared/DevSupportManager.cpp @@ -15,13 +15,12 @@ #include "Utilities.h" #include +#include #include #include #include #include #include -#include -#include #include #include @@ -45,8 +44,9 @@ using namespace facebook::react; namespace Microsoft::ReactNative { -winrt::Windows::Foundation::IAsyncOperation> GetJavaScriptFromServerAsync( - const std::string &url) { +winrt::Windows::Foundation::IAsyncOperation< + winrt::Windows::Foundation::Collections::IKeyValuePair> +GetJavaScriptFromServerAsync(const std::string &url) { winrt::Windows::Web::Http::Filters::HttpBaseProtocolFilter filter; filter.CacheControl().ReadBehavior(winrt::Windows::Web::Http::Filters::HttpCacheReadBehavior::NoCache); winrt::Windows::Web::Http::HttpClient httpClient(filter); @@ -61,7 +61,8 @@ winrt::Windows::Foundation::IAsyncOperation( - winrt::to_hstring(Microsoft::Common::Unicode::Utf16ToUtf8(e.message().c_str(), e.message().size()).c_str()), false); + winrt::to_hstring(Microsoft::Common::Unicode::Utf16ToUtf8(e.message().c_str(), e.message().size()).c_str()), + false); } #else co_await lessthrow_await_adapter(asyncRequest.ErrorCode()), url); } - co_return winrt::pair(winrt::to_hstring(error), false); + co_return winrt::pair(winrt::to_hstring(error), false); } winrt::Windows::Web::Http::HttpResponseMessage response = asyncRequest.GetResults(); @@ -173,7 +174,8 @@ bool IsIgnorablePollHResult(HRESULT hr) { return hr == WININET_E_INVALID_SERVER_RESPONSE; } -winrt::Windows::Foundation::IAsyncOperation PollForLiveReload(const std::string url) { +winrt::Windows::Foundation::IAsyncOperation PollForLiveReload( + const std::string url) { winrt::Windows::Web::Http::HttpClient httpClient; winrt::Windows::Foundation::Uri uri(Microsoft::Common::Unicode::Utf8ToUtf16(url)); httpClient.DefaultRequestHeaders().Connection().TryParseAdd(L"keep-alive"); @@ -293,8 +295,7 @@ std::pair GetJavaScriptFromServer( hermesBytecodeVersion); try { auto result = GetJavaScriptFromServerAsync(bundleUrl).get(); - return std::make_pair(winrt::to_string(result.Key()), - result.Value()); + return std::make_pair(winrt::to_string(result.Key()), result.Value()); } catch (winrt::hresult_error const &e) { return std::make_pair( "Error: " + Microsoft::Common::Unicode::Utf16ToUtf8(e.message().c_str(), e.message().size()), false); diff --git a/vnext/Shared/DevSupportManager.h b/vnext/Shared/DevSupportManager.h index 5d3060e578b..ad95a39d9f3 100644 --- a/vnext/Shared/DevSupportManager.h +++ b/vnext/Shared/DevSupportManager.h @@ -7,8 +7,8 @@ #include -#include #include +#include #include #include #include @@ -24,24 +24,27 @@ struct DevSettings; } // namespace facebook namespace winrt { - + template -struct pair_impl : implements, Windows::Foundation::Collections::IKeyValuePair> -{ - pair_impl(K k, V v) : m_k(k), m_v(v) {} - K Key() { return m_k; } - V Value() { return m_v; } -private: - K m_k; - V m_v; +struct pair_impl : implements, Windows::Foundation::Collections::IKeyValuePair> { + pair_impl(K k, V v) : m_k(k), m_v(v) {} + K Key() { + return m_k; + } + V Value() { + return m_v; + } + + private: + K m_k; + V m_v; }; template -Windows::Foundation::Collections::IKeyValuePair pair(K key, V value) -{ - return make>(key, value); -} +Windows::Foundation::Collections::IKeyValuePair pair(K key, V value) { + return make>(key, value); } +} // namespace winrt namespace Microsoft::ReactNative { From 25c722f9f201f86c6b4e2da251cc1e318f60977d Mon Sep 17 00:00:00 2001 From: Chiara Mooney <34109996+chiaramooney@users.noreply.github.com> Date: Tue, 5 Dec 2023 10:51:47 -0800 Subject: [PATCH 5/8] Try Fix: Debug Tests --- vnext/Shared/Networking/WinRTWebSocketResource.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vnext/Shared/Networking/WinRTWebSocketResource.cpp b/vnext/Shared/Networking/WinRTWebSocketResource.cpp index 7e7a9d93b55..62b85925000 100644 --- a/vnext/Shared/Networking/WinRTWebSocketResource.cpp +++ b/vnext/Shared/Networking/WinRTWebSocketResource.cpp @@ -65,8 +65,8 @@ auto resume_in_queue(const Mso::DispatchQueue &queue) noexcept { void await_resume() const noexcept {} - void await_suspend(std::coroutine_handle<> resume) noexcept { - m_callback = [context = resume.address()]() noexcept { std::coroutine_handle<>::from_address(context)(); }; + void await_suspend(std::experimental::coroutine_handle<> resume) noexcept { + m_callback = [context = resume.address()]() noexcept { std::experimental::coroutine_handle<>::from_address(context)(); }; m_queue.Post(std::move(m_callback)); } From 00c813359e998b27936a4c1cfd08b8a4921d78e3 Mon Sep 17 00:00:00 2001 From: Chiara Mooney <34109996+chiaramooney@users.noreply.github.com> Date: Tue, 5 Dec 2023 13:28:56 -0800 Subject: [PATCH 6/8] Remove Fix --- vnext/Shared/Networking/WinRTWebSocketResource.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vnext/Shared/Networking/WinRTWebSocketResource.cpp b/vnext/Shared/Networking/WinRTWebSocketResource.cpp index 62b85925000..8d6eabf31c5 100644 --- a/vnext/Shared/Networking/WinRTWebSocketResource.cpp +++ b/vnext/Shared/Networking/WinRTWebSocketResource.cpp @@ -65,9 +65,10 @@ auto resume_in_queue(const Mso::DispatchQueue &queue) noexcept { void await_resume() const noexcept {} - void await_suspend(std::experimental::coroutine_handle<> resume) noexcept { - m_callback = [context = resume.address()]() noexcept { std::experimental::coroutine_handle<>::from_address(context)(); }; + void await_suspend(std::coroutine_handle<> resume) noexcept { + m_callback = [context = resume.address()]() noexcept { std::coroutine_handle<>::from_address(context)(); }; m_queue.Post(std::move(m_callback)); + } private: From 1990ed6af3b1bc850a2a17c85cd366a778720998 Mon Sep 17 00:00:00 2001 From: Chiara Mooney <34109996+chiaramooney@users.noreply.github.com> Date: Mon, 8 Jan 2024 11:33:57 -0800 Subject: [PATCH 7/8] Fix Format --- vnext/Shared/Networking/WinRTWebSocketResource.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/vnext/Shared/Networking/WinRTWebSocketResource.cpp b/vnext/Shared/Networking/WinRTWebSocketResource.cpp index 8d6eabf31c5..7e7a9d93b55 100644 --- a/vnext/Shared/Networking/WinRTWebSocketResource.cpp +++ b/vnext/Shared/Networking/WinRTWebSocketResource.cpp @@ -68,7 +68,6 @@ auto resume_in_queue(const Mso::DispatchQueue &queue) noexcept { void await_suspend(std::coroutine_handle<> resume) noexcept { m_callback = [context = resume.address()]() noexcept { std::coroutine_handle<>::from_address(context)(); }; m_queue.Post(std::move(m_callback)); - } private: From 64addbd227ebf9ca9b411a0fedd7cc7397b1e12c Mon Sep 17 00:00:00 2001 From: Chiara Mooney <34109996+chiaramooney@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:02:37 -0800 Subject: [PATCH 8/8] Fix Build Break --- vnext/Directory.Build.props | 4 ++-- vnext/Folly/cgmanifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vnext/Directory.Build.props b/vnext/Directory.Build.props index 7751b7e2b0e..8552ac12a6b 100644 --- a/vnext/Directory.Build.props +++ b/vnext/Directory.Build.props @@ -16,8 +16,8 @@ --> false - 2023.10.16.00 - 3da4d3ccc4ea69bc10800754816e339d912736bd + 2023.11.06.00 + d62707bf4dc8c58bcc317260611b8cbe25c7f444 10.1.0 ca2e3685b160617d3d95fcd9e789c4e06ca88 diff --git a/vnext/Folly/cgmanifest.json b/vnext/Folly/cgmanifest.json index 097695e9e9d..97b28b975c2 100644 --- a/vnext/Folly/cgmanifest.json +++ b/vnext/Folly/cgmanifest.json @@ -6,7 +6,7 @@ "Type": "git", "Git": { "RepositoryUrl": "https://github.com/facebook/folly", - "CommitHash": "3da4d3ccc4ea69bc10800754816e339d912736bd" + "CommitHash": "d62707bf4dc8c58bcc317260611b8cbe25c7f444" } }, "DevelopmentDependency": false