From daeed94d7487f346cc78ee8a282ea8605f67a04d Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Fri, 17 Apr 2020 12:57:37 -0700 Subject: [PATCH 01/13] create MS.ReactNative.IntegrationTests project --- .../FootInTheDoor.cpp | 11 ++ ...osoft.ReactNative.IntegrationTests.vcxproj | 141 ++++++++++++++++++ .../main.cpp | 8 + .../packages.config | 5 + .../pch.cpp | 1 + .../pch.h | 8 + vnext/ReactWindows-Universal.sln | 15 ++ 7 files changed, 189 insertions(+) create mode 100644 vnext/Microsoft.ReactNative.IntegrationTests/FootInTheDoor.cpp create mode 100644 vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj create mode 100644 vnext/Microsoft.ReactNative.IntegrationTests/main.cpp create mode 100644 vnext/Microsoft.ReactNative.IntegrationTests/packages.config create mode 100644 vnext/Microsoft.ReactNative.IntegrationTests/pch.cpp create mode 100644 vnext/Microsoft.ReactNative.IntegrationTests/pch.h diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/FootInTheDoor.cpp b/vnext/Microsoft.ReactNative.IntegrationTests/FootInTheDoor.cpp new file mode 100644 index 00000000000..03ba723ac2b --- /dev/null +++ b/vnext/Microsoft.ReactNative.IntegrationTests/FootInTheDoor.cpp @@ -0,0 +1,11 @@ +#include "pch.h" + +namespace Microsoft::ReactNative::IntegrationTests { + +TEST_CLASS (FootInTheDoorClass) { + TEST_METHOD(TestReadCustomType) { + TestCheck(1 == 1); + } +}; + +} // namespace Microsoft::ReactNative::IntegrationTests diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj b/vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj new file mode 100644 index 00000000000..d46d96ced7a --- /dev/null +++ b/vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj @@ -0,0 +1,141 @@ + + + + + + true + 16.0 + {14FA0516-E6D7-4E4D-B097-1470198C5072} + Win32Proj + Microsoft.ReactNative.IntegrationTests + 10.0 + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + Application + Unicode + + + true + true + + + false + true + false + + + + + + + + + + + + + + + + + Use + pch.h + $(IntDir)pch.pch + pch.h + _CONSOLE;%(PreprocessorDefinitions) + Level4 + $(MSBuildThisFileDirectory);%(AdditionalIncludeDirectories) + /await %(AdditionalOptions) /bigobj + true + Cdecl + + + Console + false + + + $(ReactNativeWindowsDir)Microsoft.ReactNative;%(AdditionalIncludeDirectories) + + + + + Disabled + _DEBUG;%(PreprocessorDefinitions) + + + true + + + + + WIN32;%(PreprocessorDefinitions) + + + + + MaxSpeed + true + true + NDEBUG;%(PreprocessorDefinitions) + + + Console + true + true + + + + + + + Create + + + + + + + + + + + + + + + + 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}. + + + + + + \ No newline at end of file diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/main.cpp b/vnext/Microsoft.ReactNative.IntegrationTests/main.cpp new file mode 100644 index 00000000000..175c1f79280 --- /dev/null +++ b/vnext/Microsoft.ReactNative.IntegrationTests/main.cpp @@ -0,0 +1,8 @@ +#include "pch.h" +#include "motifCpp/gTestAdapter.h" + +int main(int argc, char **argv) { + Mso::UnitTests::GTest::RegisterUnitTests(); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/packages.config b/vnext/Microsoft.ReactNative.IntegrationTests/packages.config new file mode 100644 index 00000000000..b331b8ea9a0 --- /dev/null +++ b/vnext/Microsoft.ReactNative.IntegrationTests/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/pch.cpp b/vnext/Microsoft.ReactNative.IntegrationTests/pch.cpp new file mode 100644 index 00000000000..1d9f38c57d6 --- /dev/null +++ b/vnext/Microsoft.ReactNative.IntegrationTests/pch.cpp @@ -0,0 +1 @@ +#include "pch.h" diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/pch.h b/vnext/Microsoft.ReactNative.IntegrationTests/pch.h new file mode 100644 index 00000000000..ee0f0195afe --- /dev/null +++ b/vnext/Microsoft.ReactNative.IntegrationTests/pch.h @@ -0,0 +1,8 @@ +#pragma once + + +#define NOMINMAX + +#include "gtest/gtest.h" +#include "motifCpp/gTestAdapter.h" +#include "motifCpp/testCheck.h" diff --git a/vnext/ReactWindows-Universal.sln b/vnext/ReactWindows-Universal.sln index f9ae2a965b2..b32e8f76577 100644 --- a/vnext/ReactWindows-Universal.sln +++ b/vnext/ReactWindows-Universal.sln @@ -103,9 +103,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mso.UnitTests", "Mso.UnitTe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.ReactNative.Managed.UnitTests", "Microsoft.ReactNative.Managed.UnitTests\Microsoft.ReactNative.Managed.UnitTests.csproj", "{46D76F7A-8FD9-4A7D-8102-2857E5DA6B84}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.ReactNative.IntegrationTests", "Microsoft.ReactNative.IntegrationTests\Microsoft.ReactNative.IntegrationTests.vcxproj", "{14FA0516-E6D7-4E4D-B097-1470198C5072}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution JSI\Shared\JSI.Shared.vcxitems*{0cc28589-39e4-4288-b162-97b959f8b843}*SharedItemsImports = 9 + Mso\Mso.vcxitems*{14fa0516-e6d7-4e4d-b097-1470198c5072}*SharedItemsImports = 4 Mso\Mso.vcxitems*{1958ceaa-fbe0-44e3-8a99-90ad85531ffe}*SharedItemsImports = 4 Shared\Shared.vcxitems*{2049dbe9-8d13-42c9-ae4b-413ae38fffd0}*SharedItemsImports = 9 Chakra\Chakra.vcxitems*{2d5d43d9-cffc-4c40-b4cd-02efb4e2742b}*SharedItemsImports = 4 @@ -330,6 +333,18 @@ Global {46D76F7A-8FD9-4A7D-8102-2857E5DA6B84}.Release|x86.ActiveCfg = Release|x86 {46D76F7A-8FD9-4A7D-8102-2857E5DA6B84}.Release|x86.Build.0 = Release|x86 {46D76F7A-8FD9-4A7D-8102-2857E5DA6B84}.Release|x86.Deploy.0 = Release|x86 + {14FA0516-E6D7-4E4D-B097-1470198C5072}.Debug|ARM.ActiveCfg = Debug|Win32 + {14FA0516-E6D7-4E4D-B097-1470198C5072}.Debug|ARM64.ActiveCfg = Debug|Win32 + {14FA0516-E6D7-4E4D-B097-1470198C5072}.Debug|x64.ActiveCfg = Debug|x64 + {14FA0516-E6D7-4E4D-B097-1470198C5072}.Debug|x64.Build.0 = Debug|x64 + {14FA0516-E6D7-4E4D-B097-1470198C5072}.Debug|x86.ActiveCfg = Debug|Win32 + {14FA0516-E6D7-4E4D-B097-1470198C5072}.Debug|x86.Build.0 = Debug|Win32 + {14FA0516-E6D7-4E4D-B097-1470198C5072}.Release|ARM.ActiveCfg = Release|Win32 + {14FA0516-E6D7-4E4D-B097-1470198C5072}.Release|ARM64.ActiveCfg = Release|Win32 + {14FA0516-E6D7-4E4D-B097-1470198C5072}.Release|x64.ActiveCfg = Release|x64 + {14FA0516-E6D7-4E4D-B097-1470198C5072}.Release|x64.Build.0 = Release|x64 + {14FA0516-E6D7-4E4D-B097-1470198C5072}.Release|x86.ActiveCfg = Release|Win32 + {14FA0516-E6D7-4E4D-B097-1470198C5072}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 84f2f444faaec977ee9bb72da3bb079ebeb5889b Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Wed, 22 Apr 2020 23:20:14 -0700 Subject: [PATCH 02/13] RNHost activation succeeds --- .../Application.manifest | 13 ++++++++++ .../FootInTheDoor.cpp | 11 -------- ...osoft.ReactNative.IntegrationTests.vcxproj | 26 ++++++++++--------- .../ReactNativeHostTests.cpp | 18 +++++++++++++ .../packages.config | 1 + 5 files changed, 46 insertions(+), 23 deletions(-) create mode 100644 vnext/Microsoft.ReactNative.IntegrationTests/Application.manifest delete mode 100644 vnext/Microsoft.ReactNative.IntegrationTests/FootInTheDoor.cpp create mode 100644 vnext/Microsoft.ReactNative.IntegrationTests/ReactNativeHostTests.cpp diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/Application.manifest b/vnext/Microsoft.ReactNative.IntegrationTests/Application.manifest new file mode 100644 index 00000000000..f6b18494725 --- /dev/null +++ b/vnext/Microsoft.ReactNative.IntegrationTests/Application.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/FootInTheDoor.cpp b/vnext/Microsoft.ReactNative.IntegrationTests/FootInTheDoor.cpp deleted file mode 100644 index 03ba723ac2b..00000000000 --- a/vnext/Microsoft.ReactNative.IntegrationTests/FootInTheDoor.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "pch.h" - -namespace Microsoft::ReactNative::IntegrationTests { - -TEST_CLASS (FootInTheDoorClass) { - TEST_METHOD(TestReadCustomType) { - TestCheck(1 == 1); - } -}; - -} // namespace Microsoft::ReactNative::IntegrationTests diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj b/vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj index d46d96ced7a..24559702450 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj +++ b/vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj @@ -2,19 +2,13 @@ - + high true 16.0 {14FA0516-E6D7-4E4D-B097-1470198C5072} Win32Proj Microsoft.ReactNative.IntegrationTests 10.0 - @@ -53,7 +47,7 @@ - + @@ -113,22 +107,29 @@ - + - - Create - + + Create + + + + + {f7d32bd0-2749-483e-9a0d-1635ef7e3136} + + + @@ -137,5 +138,6 @@ + \ No newline at end of file diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/ReactNativeHostTests.cpp b/vnext/Microsoft.ReactNative.IntegrationTests/ReactNativeHostTests.cpp new file mode 100644 index 00000000000..4117db9e01d --- /dev/null +++ b/vnext/Microsoft.ReactNative.IntegrationTests/ReactNativeHostTests.cpp @@ -0,0 +1,18 @@ +#include "pch.h" + +#include + +namespace ReactNativeIntegrationTests { + +TEST_CLASS (ReactNativeHostTests) { + TEST_METHOD(Activation_Succeeds) { + try { + winrt::Microsoft::ReactNative::ReactNativeHost host{}; + TestCheck(true); + } catch (...) { + TestCheckFail(); + } + } +}; + +} // namespace ReactNativeIntegrationTests diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/packages.config b/vnext/Microsoft.ReactNative.IntegrationTests/packages.config index b331b8ea9a0..f78d593dc8b 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/packages.config +++ b/vnext/Microsoft.ReactNative.IntegrationTests/packages.config @@ -1,5 +1,6 @@  + \ No newline at end of file From bdc22d99d63998802228ef08ffe2327f317dedd3 Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Wed, 22 Apr 2020 23:28:55 -0700 Subject: [PATCH 03/13] update --- vnext/Microsoft.ReactNative.IntegrationTests/main.cpp | 6 +++--- vnext/Microsoft.ReactNative.IntegrationTests/pch.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/main.cpp b/vnext/Microsoft.ReactNative.IntegrationTests/main.cpp index 175c1f79280..3e0e14c0536 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/main.cpp +++ b/vnext/Microsoft.ReactNative.IntegrationTests/main.cpp @@ -2,7 +2,7 @@ #include "motifCpp/gTestAdapter.h" int main(int argc, char **argv) { - Mso::UnitTests::GTest::RegisterUnitTests(); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + Mso::UnitTests::GTest::RegisterUnitTests(); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/pch.h b/vnext/Microsoft.ReactNative.IntegrationTests/pch.h index ee0f0195afe..cdbaa25a673 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/pch.h +++ b/vnext/Microsoft.ReactNative.IntegrationTests/pch.h @@ -1,6 +1,5 @@ #pragma once - #define NOMINMAX #include "gtest/gtest.h" From 19951b9ff67d8a8d8da094268082c1138e9a2cb6 Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Wed, 22 Apr 2020 23:49:55 -0700 Subject: [PATCH 04/13] update --- vnext/ReactWindows-Universal.sln | 1 + 1 file changed, 1 insertion(+) diff --git a/vnext/ReactWindows-Universal.sln b/vnext/ReactWindows-Universal.sln index b32e8f76577..124df59f409 100644 --- a/vnext/ReactWindows-Universal.sln +++ b/vnext/ReactWindows-Universal.sln @@ -112,6 +112,7 @@ Global Mso\Mso.vcxitems*{1958ceaa-fbe0-44e3-8a99-90ad85531ffe}*SharedItemsImports = 4 Shared\Shared.vcxitems*{2049dbe9-8d13-42c9-ae4b-413ae38fffd0}*SharedItemsImports = 9 Chakra\Chakra.vcxitems*{2d5d43d9-cffc-4c40-b4cd-02efb4e2742b}*SharedItemsImports = 4 + Mso\Mso.vcxitems*{2d5d43d9-cffc-4c40-b4cd-02efb4e2742b}*SharedItemsImports = 4 Shared\Shared.vcxitems*{2d5d43d9-cffc-4c40-b4cd-02efb4e2742b}*SharedItemsImports = 4 Microsoft.ReactNative.SharedManaged\Microsoft.ReactNative.SharedManaged.projitems*{46d76f7a-8fd9-4a7d-8102-2857e5da6b84}*SharedItemsImports = 4 Microsoft.ReactNative.SharedManaged\Microsoft.ReactNative.SharedManaged.projitems*{67a1076f-7790-4203-86ea-4402ccb5e782}*SharedItemsImports = 13 From 027a6e954b8dfa55ddb3856de5994869ab43f171 Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Thu, 23 Apr 2020 15:24:51 -0700 Subject: [PATCH 05/13] Change files --- ...act-native-windows-2020-04-23-15-24-50-abi-safety.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 change/react-native-windows-2020-04-23-15-24-50-abi-safety.json diff --git a/change/react-native-windows-2020-04-23-15-24-50-abi-safety.json b/change/react-native-windows-2020-04-23-15-24-50-abi-safety.json new file mode 100644 index 00000000000..39ab158f7ed --- /dev/null +++ b/change/react-native-windows-2020-04-23-15-24-50-abi-safety.json @@ -0,0 +1,8 @@ +{ + "type": "none", + "comment": "Add Microsoft.ReactNative.IntegrationTests project", + "packageName": "react-native-windows", + "email": "aeulitz@microsoft.com", + "dependentChangeType": "none", + "date": "2020-04-23T22:24:50.780Z" +} From 974f81e3d17ab38d4fe686d439179483c006ef90 Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Thu, 30 Apr 2020 18:05:26 -0700 Subject: [PATCH 06/13] add JS function call test --- .../AddValues.js | 9 +++ ...osoft.ReactNative.IntegrationTests.vcxproj | 3 + .../ReactNativeHostTests.cpp | 78 +++++++++++++++++-- .../TestBundle.targets | 10 +++ .../main.cpp | 2 + .../pch.h | 6 +- 6 files changed, 98 insertions(+), 10 deletions(-) create mode 100644 vnext/Microsoft.ReactNative.IntegrationTests/AddValues.js create mode 100644 vnext/Microsoft.ReactNative.IntegrationTests/TestBundle.targets diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/AddValues.js b/vnext/Microsoft.ReactNative.IntegrationTests/AddValues.js new file mode 100644 index 00000000000..5079081362b --- /dev/null +++ b/vnext/Microsoft.ReactNative.IntegrationTests/AddValues.js @@ -0,0 +1,9 @@ +import { NativeModules } from 'react-native'; + +class SampleModuleCpp { + addValues(a, b) { + NativeModules.TestHostModule.returnInt(a + b); + } +} + +global.__fbBatchedBridge.registerLazyCallableModule('SampleModuleCpp', () => new SampleModuleCpp()); diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj b/vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj index 24559702450..5b1aacd65ec 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj +++ b/vnext/Microsoft.ReactNative.IntegrationTests/Microsoft.ReactNative.IntegrationTests.vcxproj @@ -47,6 +47,7 @@ + @@ -119,6 +120,7 @@ + @@ -130,6 +132,7 @@ + diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/ReactNativeHostTests.cpp b/vnext/Microsoft.ReactNative.IntegrationTests/ReactNativeHostTests.cpp index 4117db9e01d..67a176e362e 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/ReactNativeHostTests.cpp +++ b/vnext/Microsoft.ReactNative.IntegrationTests/ReactNativeHostTests.cpp @@ -1,18 +1,80 @@ #include "pch.h" -#include +using namespace React; namespace ReactNativeIntegrationTests { +REACT_MODULE(TestHostModule) +struct TestHostModule { + REACT_INIT(Initialize) + void Initialize(IReactContext const & /*reactContext*/) noexcept { + TestHostModule::Instance.set_value(*this); + } + + REACT_FUNCTION(addValues) + std::function addValues; + + REACT_METHOD(returnInt) + void returnInt(int value) noexcept { + TestHostModule::IntReturnValue.set_value(value); + } + + static std::promise Instance; + static std::promise IntReturnValue; +}; + +std::promise TestHostModule::Instance; +std::promise TestHostModule::IntReturnValue; + +struct TestPackageProvider : winrt::implements { + void CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept { + TryAddAttributedModule(packageBuilder, L"TestHostModule"); + } +}; + TEST_CLASS (ReactNativeHostTests) { TEST_METHOD(Activation_Succeeds) { - try { - winrt::Microsoft::ReactNative::ReactNativeHost host{}; - TestCheck(true); - } catch (...) { - TestCheckFail(); - } + TestCheckNoThrow(winrt::Microsoft::ReactNative::ReactNativeHost{}); } -}; + + // The test method below is being skipped as the instance creation currently crashes with the following dependency on + // the Xaml application framework: + // 0b VCRUNTIME140D!_CxxThrowException + // 0c Microsoft_ReactNative!winrt::throw_hresult + // 0d Microsoft_ReactNative!winrt::check_hresult + // 0e Microsoft_ReactNative!winrt::impl::consume_Windows_ApplicationModel_Core_ICoreImmersiveApplication::MainView + // 0f Microsoft_ReactNative!::operator() + // 10 Microsoft_ReactNative!:: + // 11 Microsoft_ReactNative!winrt::impl::factory_cache_entry::call + // 12 Microsoft_ReactNative!winrt::impl::call_factory_cast > + // 13 Microsoft_ReactNative!winrt::Windows::ApplicationModel::Core::CoreApplication::MainView + // 14 Microsoft_ReactNative!Mso::DispatchQueueStatic::MakeMainUIScheduler + // 15 Microsoft_ReactNative!Mso::DispatchQueueStatic::MainUIQueue + // 16 Microsoft_ReactNative!Mso::DispatchQueue::MainUIQueue + // 17 Microsoft_ReactNative!Mso::React::ReactInstanceWin::InitUIMessageThread + // 18 Microsoft_ReactNative!Mso::React::ReactInstanceWin::Initialize + // In the short term, there are several ways in which this could get mitigated (e.g. transforming the integration test + // app into a UWP app). In the long term, the issue should get addressed by splitting the Microsoft.ReactNative.dll + // into a "core" and a "UI" DLL, and by having the tests in this project target the "core" DLL. + SKIPTESTMETHOD(JsFunctionCall_Succeeds) { + std::future testHostModule = TestHostModule::Instance.get_future(); + std::future returnValue = TestHostModule::IntReturnValue.get_future(); + + winrt::Microsoft::ReactNative::ReactNativeHost host{}; + host.PackageProviders().Append(winrt::make()); + + // bundle is assumed to be co-located with the test binary + wchar_t testBinaryPath[MAX_PATH]; + TestCheck(GetModuleFileNameW(NULL, testBinaryPath, MAX_PATH) < MAX_PATH); + testBinaryPath[std::wstring_view{testBinaryPath}.rfind(L"\\")] = 0; + host.InstanceSettings().BundleRootPath(testBinaryPath); + + host.InstanceSettings().JavaScriptBundleFile(L"AddValues.bundle"); + host.ReloadInstance(); + + testHostModule.get().addValues(12, 23); + TestCheckEqual(35, returnValue.get()); + } + }; } // namespace ReactNativeIntegrationTests diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/TestBundle.targets b/vnext/Microsoft.ReactNative.IntegrationTests/TestBundle.targets new file mode 100644 index 00000000000..284e1cd3af6 --- /dev/null +++ b/vnext/Microsoft.ReactNative.IntegrationTests/TestBundle.targets @@ -0,0 +1,10 @@ + + + + + + diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/main.cpp b/vnext/Microsoft.ReactNative.IntegrationTests/main.cpp index 3e0e14c0536..4d4152fe7f4 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/main.cpp +++ b/vnext/Microsoft.ReactNative.IntegrationTests/main.cpp @@ -1,4 +1,6 @@ #include "pch.h" + +#include "gtest/gtest.h" #include "motifCpp/gTestAdapter.h" int main(int argc, char **argv) { diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/pch.h b/vnext/Microsoft.ReactNative.IntegrationTests/pch.h index cdbaa25a673..ca7c2245f28 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/pch.h +++ b/vnext/Microsoft.ReactNative.IntegrationTests/pch.h @@ -2,6 +2,8 @@ #define NOMINMAX -#include "gtest/gtest.h" -#include "motifCpp/gTestAdapter.h" +#include "functional/functor.h" +#include #include "motifCpp/testCheck.h" +#include "NativeModules.h" +#include From 97ee9d00985354804c95449cea7bc756f6aec077 Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Thu, 30 Apr 2020 18:28:03 -0700 Subject: [PATCH 07/13] Change files --- ...act-native-windows-2020-04-30-18-28-03-abi-safety.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 change/react-native-windows-2020-04-30-18-28-03-abi-safety.json diff --git a/change/react-native-windows-2020-04-30-18-28-03-abi-safety.json b/change/react-native-windows-2020-04-30-18-28-03-abi-safety.json new file mode 100644 index 00000000000..7cf31717cd8 --- /dev/null +++ b/change/react-native-windows-2020-04-30-18-28-03-abi-safety.json @@ -0,0 +1,8 @@ +{ + "type": "none", + "comment": "test bundle build logic, JS function call test", + "packageName": "react-native-windows", + "email": "aeulitz@microsoft.com", + "dependentChangeType": "none", + "date": "2020-05-01T01:28:03.315Z" +} From 3174af552908dd377574639b46f3b4dc83a74d93 Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Fri, 1 May 2020 15:43:47 -0700 Subject: [PATCH 08/13] fix formatting --- .../ReactNativeHostTests.cpp | 33 +++++++++++-------- .../pch.h | 6 ++-- vnext/ReactWindows-Universal.sln | 1 + 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/ReactNativeHostTests.cpp b/vnext/Microsoft.ReactNative.IntegrationTests/ReactNativeHostTests.cpp index 67a176e362e..11d16009c32 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/ReactNativeHostTests.cpp +++ b/vnext/Microsoft.ReactNative.IntegrationTests/ReactNativeHostTests.cpp @@ -7,7 +7,7 @@ namespace ReactNativeIntegrationTests { REACT_MODULE(TestHostModule) struct TestHostModule { REACT_INIT(Initialize) - void Initialize(IReactContext const & /*reactContext*/) noexcept { + void Initialize(ReactContext const & /*reactContext*/) noexcept { TestHostModule::Instance.set_value(*this); } @@ -19,11 +19,11 @@ struct TestHostModule { TestHostModule::IntReturnValue.set_value(value); } - static std::promise Instance; + static std::promise Instance; static std::promise IntReturnValue; }; -std::promise TestHostModule::Instance; +std::promise TestHostModule::Instance; std::promise TestHostModule::IntReturnValue; struct TestPackageProvider : winrt::implements { @@ -42,22 +42,27 @@ TEST_CLASS (ReactNativeHostTests) { // 0b VCRUNTIME140D!_CxxThrowException // 0c Microsoft_ReactNative!winrt::throw_hresult // 0d Microsoft_ReactNative!winrt::check_hresult - // 0e Microsoft_ReactNative!winrt::impl::consume_Windows_ApplicationModel_Core_ICoreImmersiveApplication::MainView + // 0e + // Microsoft_ReactNative!winrt::impl::consume_Windows_ApplicationModel_Core_ICoreImmersiveApplication::MainView // 0f Microsoft_ReactNative!::operator() // 10 Microsoft_ReactNative!:: - // 11 Microsoft_ReactNative!winrt::impl::factory_cache_entry::call - // 12 Microsoft_ReactNative!winrt::impl::call_factory_cast > - // 13 Microsoft_ReactNative!winrt::Windows::ApplicationModel::Core::CoreApplication::MainView - // 14 Microsoft_ReactNative!Mso::DispatchQueueStatic::MakeMainUIScheduler - // 15 Microsoft_ReactNative!Mso::DispatchQueueStatic::MainUIQueue - // 16 Microsoft_ReactNative!Mso::DispatchQueue::MainUIQueue - // 17 Microsoft_ReactNative!Mso::React::ReactInstanceWin::InitUIMessageThread - // 18 Microsoft_ReactNative!Mso::React::ReactInstanceWin::Initialize + // 11 + // Microsoft_ReactNative!winrt::impl::factory_cache_entry::call 12 + // Microsoft_ReactNative!winrt::impl::call_factory_cast + // > 13 Microsoft_ReactNative!winrt::Windows::ApplicationModel::Core::CoreApplication::MainView 14 + // Microsoft_ReactNative!Mso::DispatchQueueStatic::MakeMainUIScheduler 15 + // Microsoft_ReactNative!Mso::DispatchQueueStatic::MainUIQueue 16 + // Microsoft_ReactNative!Mso::DispatchQueue::MainUIQueue 17 + // Microsoft_ReactNative!Mso::React::ReactInstanceWin::InitUIMessageThread 18 + // Microsoft_ReactNative!Mso::React::ReactInstanceWin::Initialize // In the short term, there are several ways in which this could get mitigated (e.g. transforming the integration test // app into a UWP app). In the long term, the issue should get addressed by splitting the Microsoft.ReactNative.dll // into a "core" and a "UI" DLL, and by having the tests in this project target the "core" DLL. SKIPTESTMETHOD(JsFunctionCall_Succeeds) { - std::future testHostModule = TestHostModule::Instance.get_future(); + std::future testHostModule = TestHostModule::Instance.get_future(); std::future returnValue = TestHostModule::IntReturnValue.get_future(); winrt::Microsoft::ReactNative::ReactNativeHost host{}; @@ -75,6 +80,6 @@ TEST_CLASS (ReactNativeHostTests) { testHostModule.get().addValues(12, 23); TestCheckEqual(35, returnValue.get()); } - }; +}; } // namespace ReactNativeIntegrationTests diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/pch.h b/vnext/Microsoft.ReactNative.IntegrationTests/pch.h index ca7c2245f28..df633651c1b 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/pch.h +++ b/vnext/Microsoft.ReactNative.IntegrationTests/pch.h @@ -2,8 +2,8 @@ #define NOMINMAX -#include "functional/functor.h" +#include #include +#include "NativeModules.h" +#include "functional/functor.h" #include "motifCpp/testCheck.h" -#include "NativeModules.h" -#include diff --git a/vnext/ReactWindows-Universal.sln b/vnext/ReactWindows-Universal.sln index 89f5f1eb5c3..5b0b2509e19 100644 --- a/vnext/ReactWindows-Universal.sln +++ b/vnext/ReactWindows-Universal.sln @@ -108,6 +108,7 @@ EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution JSI\Shared\JSI.Shared.vcxitems*{0cc28589-39e4-4288-b162-97b959f8b843}*SharedItemsImports = 9 + Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems*{14fa0516-e6d7-4e4d-b097-1470198c5072}*SharedItemsImports = 4 Mso\Mso.vcxitems*{14fa0516-e6d7-4e4d-b097-1470198c5072}*SharedItemsImports = 4 Mso\Mso.vcxitems*{1958ceaa-fbe0-44e3-8a99-90ad85531ffe}*SharedItemsImports = 4 Shared\Shared.vcxitems*{2049dbe9-8d13-42c9-ae4b-413ae38fffd0}*SharedItemsImports = 9 From e258c653da61795baa4a7ec36ad0c20625c2cf65 Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Wed, 6 May 2020 13:04:40 -0700 Subject: [PATCH 09/13] submit current state --- vnext/Desktop.ABITests/ActivationFactory.h | 10 +++++++ vnext/Desktop.ABITests/MemoryTrackerTests.cpp | 3 +- .../Desktop.ABITests/NativeLogEventTests.cpp | 3 +- .../React.Windows.Desktop.ABITests.vcxproj | 2 ++ ...t.Windows.Desktop.ABITests.vcxproj.filters | 6 ++++ .../Desktop.ABITests/ReactNativeHostTests.cpp | 28 +++++++++++++++++++ vnext/Desktop/ABI/ReactNativeHost.cpp | 2 ++ vnext/Desktop/ABI/ReactNativeHost.h | 1 + vnext/Desktop/React.Windows.Desktop.vcxproj | 9 ++++++ .../React.Windows.Desktop.vcxproj.filters | 3 ++ 10 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 vnext/Desktop.ABITests/ActivationFactory.h create mode 100644 vnext/Desktop.ABITests/ReactNativeHostTests.cpp create mode 100644 vnext/Desktop/ABI/ReactNativeHost.cpp create mode 100644 vnext/Desktop/ABI/ReactNativeHost.h diff --git a/vnext/Desktop.ABITests/ActivationFactory.h b/vnext/Desktop.ABITests/ActivationFactory.h new file mode 100644 index 00000000000..e53f76d24ce --- /dev/null +++ b/vnext/Desktop.ABITests/ActivationFactory.h @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#pragma once + +#include "pch.h" +#include +#include + +extern int32_t __stdcall WINRT_RoGetActivationFactory(void *classId, winrt::guid const &iid, void **factory) noexcept; diff --git a/vnext/Desktop.ABITests/MemoryTrackerTests.cpp b/vnext/Desktop.ABITests/MemoryTrackerTests.cpp index ce3da0f7549..19380868b15 100644 --- a/vnext/Desktop.ABITests/MemoryTrackerTests.cpp +++ b/vnext/Desktop.ABITests/MemoryTrackerTests.cpp @@ -7,13 +7,14 @@ #include #include +#include "ActivationFactory.h" #include "MessageQueueShim.h" using namespace Microsoft::React::Test; using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace winrt::facebook::react; -int32_t __stdcall WINRT_RoGetActivationFactory(void *classId, winrt::guid const &iid, void **factory) noexcept; +// int32_t __stdcall WINRT_RoGetActivationFactory(void *classId, winrt::guid const &iid, void **factory) noexcept; namespace ABITests { diff --git a/vnext/Desktop.ABITests/NativeLogEventTests.cpp b/vnext/Desktop.ABITests/NativeLogEventTests.cpp index d23fd4ae2ad..a223933b374 100644 --- a/vnext/Desktop.ABITests/NativeLogEventTests.cpp +++ b/vnext/Desktop.ABITests/NativeLogEventTests.cpp @@ -5,12 +5,13 @@ #include #include #include +#include "ActivationFactory.h" using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace winrt::facebook::react; using namespace winrt; -int32_t __stdcall WINRT_RoGetActivationFactory(void *classId, winrt::guid const &iid, void **factory) noexcept; +// int32_t __stdcall WINRT_RoGetActivationFactory(void *classId, winrt::guid const &iid, void **factory) noexcept; namespace ABITests { diff --git a/vnext/Desktop.ABITests/React.Windows.Desktop.ABITests.vcxproj b/vnext/Desktop.ABITests/React.Windows.Desktop.ABITests.vcxproj index ec0af2a58ba..35f5829aec3 100644 --- a/vnext/Desktop.ABITests/React.Windows.Desktop.ABITests.vcxproj +++ b/vnext/Desktop.ABITests/React.Windows.Desktop.ABITests.vcxproj @@ -133,9 +133,11 @@ Create + + diff --git a/vnext/Desktop.ABITests/React.Windows.Desktop.ABITests.vcxproj.filters b/vnext/Desktop.ABITests/React.Windows.Desktop.ABITests.vcxproj.filters index 49daa4eb2a2..76bd4b11819 100644 --- a/vnext/Desktop.ABITests/React.Windows.Desktop.ABITests.vcxproj.filters +++ b/vnext/Desktop.ABITests/React.Windows.Desktop.ABITests.vcxproj.filters @@ -36,6 +36,9 @@ Source Files + + Source Files + @@ -44,6 +47,9 @@ Header Files + + Header Files + diff --git a/vnext/Desktop.ABITests/ReactNativeHostTests.cpp b/vnext/Desktop.ABITests/ReactNativeHostTests.cpp new file mode 100644 index 00000000000..711064688a1 --- /dev/null +++ b/vnext/Desktop.ABITests/ReactNativeHostTests.cpp @@ -0,0 +1,28 @@ +#include "pch.h" +#include + +#include "ActivationFactory.h" + +namespace ABITests { + +TEST_CLASS (ReactNativeHostTests) { + public: + ReactNativeHostTests() noexcept { + winrt_activation_handler = WINRT_RoGetActivationFactory; + } + + TEST_METHOD(Activation_Succeeds) { + try { + winrt::Microsoft::ReactNative::ReactNativeHost host{}; + + // TODO: success primitive? + Assert::IsTrue(true); + Asser + } catch (...) { + // TODO: failure primitive? + Assert::IsTrue(false); + } + } +}; + +} // namespace ABITests diff --git a/vnext/Desktop/ABI/ReactNativeHost.cpp b/vnext/Desktop/ABI/ReactNativeHost.cpp new file mode 100644 index 00000000000..f4e3fdeb756 --- /dev/null +++ b/vnext/Desktop/ABI/ReactNativeHost.cpp @@ -0,0 +1,2 @@ +#include +#include "ReactNativeHost.h" diff --git a/vnext/Desktop/ABI/ReactNativeHost.h b/vnext/Desktop/ABI/ReactNativeHost.h new file mode 100644 index 00000000000..6f70f09beec --- /dev/null +++ b/vnext/Desktop/ABI/ReactNativeHost.h @@ -0,0 +1 @@ +#pragma once diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj b/vnext/Desktop/React.Windows.Desktop.vcxproj index a95ef3c358f..87dba15ea45 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj @@ -98,6 +98,7 @@ + @@ -116,6 +117,10 @@ ABI\NativeTracing.idl $(IntDir)\ABI\ + + ..\Microsoft.ReactNative\ReactNativeHost.idl + $(IntDir)\ABI\ + @@ -146,6 +151,10 @@ ABI\NativeTracing.idl + + ..\Microsoft.ReactNative\ReactNativeHost.idl + Code + diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj.filters b/vnext/Desktop/React.Windows.Desktop.vcxproj.filters index e150e18d4fa..47723680882 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj.filters +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj.filters @@ -42,6 +42,9 @@ ABI + + ABI + From e90e44460133bfd036ad3cb5699cc4c4683222ce Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Sat, 9 May 2020 17:39:19 -0700 Subject: [PATCH 10/13] ReactNativeHost activation test succeeds --- vnext/Desktop.ABITests/ActivationFactory.cpp | 2 +- vnext/Desktop.ABITests/MemoryTrackerTests.cpp | 4 +- .../Desktop.ABITests/NativeLogEventTests.cpp | 2 - .../NativeTraceEventTests.cpp | 3 +- .../React.Windows.Desktop.ABITests.vcxproj | 3 + .../Desktop.ABITests/ReactNativeHostTests.cpp | 10 ++- vnext/Desktop/ABI/ReactNativeHost.cpp | 61 +++++++++++++++++++ vnext/Desktop/ABI/ReactNativeHost.h | 38 ++++++++++++ vnext/Desktop/React.Windows.Desktop.vcxproj | 11 ++++ vnext/Desktop/module.g.cpp | 8 +++ 10 files changed, 129 insertions(+), 13 deletions(-) diff --git a/vnext/Desktop.ABITests/ActivationFactory.cpp b/vnext/Desktop.ABITests/ActivationFactory.cpp index 81ff78b6cf7..19915c7e683 100644 --- a/vnext/Desktop.ABITests/ActivationFactory.cpp +++ b/vnext/Desktop.ABITests/ActivationFactory.cpp @@ -26,7 +26,7 @@ int32_t __stdcall WINRT_RoGetActivationFactory(void *classId, guid const &iid, v std::wstring_view const name{*reinterpret_cast(&classId)}; HMODULE library{nullptr}; - if (starts_with(name, L"facebook.react.")) { + if (starts_with(name, L"facebook.react.") || starts_with(name, L"Microsoft.React")) { library = LoadLibraryExW(RNDLLPATH, NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); } else { return OS_RoGetActivationFactory(classId, iid, factory); diff --git a/vnext/Desktop.ABITests/MemoryTrackerTests.cpp b/vnext/Desktop.ABITests/MemoryTrackerTests.cpp index 19380868b15..e673ba7b60e 100644 --- a/vnext/Desktop.ABITests/MemoryTrackerTests.cpp +++ b/vnext/Desktop.ABITests/MemoryTrackerTests.cpp @@ -10,12 +10,12 @@ #include "ActivationFactory.h" #include "MessageQueueShim.h" +#include "ActivationFactory.h" + using namespace Microsoft::React::Test; using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace winrt::facebook::react; -// int32_t __stdcall WINRT_RoGetActivationFactory(void *classId, winrt::guid const &iid, void **factory) noexcept; - namespace ABITests { // We turn clang format off here because it does not work with some of the diff --git a/vnext/Desktop.ABITests/NativeLogEventTests.cpp b/vnext/Desktop.ABITests/NativeLogEventTests.cpp index a223933b374..859b84dca56 100644 --- a/vnext/Desktop.ABITests/NativeLogEventTests.cpp +++ b/vnext/Desktop.ABITests/NativeLogEventTests.cpp @@ -11,8 +11,6 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace winrt::facebook::react; using namespace winrt; -// int32_t __stdcall WINRT_RoGetActivationFactory(void *classId, winrt::guid const &iid, void **factory) noexcept; - namespace ABITests { TEST_CLASS (NativeLogEventTests) { diff --git a/vnext/Desktop.ABITests/NativeTraceEventTests.cpp b/vnext/Desktop.ABITests/NativeTraceEventTests.cpp index 371589c30a1..16348920fa3 100644 --- a/vnext/Desktop.ABITests/NativeTraceEventTests.cpp +++ b/vnext/Desktop.ABITests/NativeTraceEventTests.cpp @@ -6,13 +6,12 @@ #include #include #include +#include "ActivationFactory.h" using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace winrt::facebook::react; using namespace winrt; -int32_t __stdcall WINRT_RoGetActivationFactory(void *classId, winrt::guid const &iid, void **factory) noexcept; - namespace ABITests { TEST_CLASS (NativeTraceEventTests) { diff --git a/vnext/Desktop.ABITests/React.Windows.Desktop.ABITests.vcxproj b/vnext/Desktop.ABITests/React.Windows.Desktop.ABITests.vcxproj index 35f5829aec3..c4972ba5924 100644 --- a/vnext/Desktop.ABITests/React.Windows.Desktop.ABITests.vcxproj +++ b/vnext/Desktop.ABITests/React.Windows.Desktop.ABITests.vcxproj @@ -103,6 +103,9 @@ $(OutputPath)..\React.Windows.Desktop\facebook.react.winmd + + $(OutputPath)..\React.Windows.Desktop\Microsoft.ReactNative.winmd + diff --git a/vnext/Desktop.ABITests/ReactNativeHostTests.cpp b/vnext/Desktop.ABITests/ReactNativeHostTests.cpp index 711064688a1..4bcb8d1f54b 100644 --- a/vnext/Desktop.ABITests/ReactNativeHostTests.cpp +++ b/vnext/Desktop.ABITests/ReactNativeHostTests.cpp @@ -1,8 +1,10 @@ #include "pch.h" #include - +#include #include "ActivationFactory.h" +using namespace Microsoft::VisualStudio::CppUnitTestFramework; + namespace ABITests { TEST_CLASS (ReactNativeHostTests) { @@ -14,13 +16,9 @@ TEST_CLASS (ReactNativeHostTests) { TEST_METHOD(Activation_Succeeds) { try { winrt::Microsoft::ReactNative::ReactNativeHost host{}; - - // TODO: success primitive? Assert::IsTrue(true); - Asser } catch (...) { - // TODO: failure primitive? - Assert::IsTrue(false); + Assert::Fail(); } } }; diff --git a/vnext/Desktop/ABI/ReactNativeHost.cpp b/vnext/Desktop/ABI/ReactNativeHost.cpp index f4e3fdeb756..f4453740700 100644 --- a/vnext/Desktop/ABI/ReactNativeHost.cpp +++ b/vnext/Desktop/ABI/ReactNativeHost.cpp @@ -1,2 +1,63 @@ #include #include "ReactNativeHost.h" + +#include "Microsoft.ReactNative.ReactNativeHost.g.cpp" + +using namespace winrt::Windows::Foundation::Collections; + +namespace winrt::Microsoft::ReactNative::implementation { + +ReactNativeHost::ReactNativeHost() noexcept { + // TODO: implement +} + +IVector ReactNativeHost::PackageProviders() noexcept { + if (!m_packageProviders) { + m_packageProviders = single_threaded_vector(); + } + + return m_packageProviders; +} + +void ReactNativeHost::PackageProviders(IVector const &value) noexcept { + m_packageProviders = value; +} + +ReactNative::ReactInstanceSettings ReactNativeHost::InstanceSettings() noexcept { + if (!m_instanceSettings) { + // TODO: implement + // m_instanceSettings = make(); + } + + return m_instanceSettings; +} + +void ReactNativeHost::InstanceSettings(ReactNative::ReactInstanceSettings const &value) noexcept { + m_instanceSettings = value; +} + +void ReactNativeHost::ReloadInstance() noexcept { + // TODO: implement +} + +void ReactNativeHost::OnSuspend() noexcept { + // TODO: implement +} + +void ReactNativeHost::OnEnteredBackground() noexcept { + // TODO: implement +} + +void ReactNativeHost::OnLeavingBackground() noexcept { + // TODO: implement +} + +void ReactNativeHost::OnResume(OnResumeAction const & /*action*/) noexcept { + // TODO: implement +} + +void ReactNativeHost::OnBackPressed() noexcept { + // TODO: implement +} + +} // namespace winrt::Microsoft::ReactNative::implementation diff --git a/vnext/Desktop/ABI/ReactNativeHost.h b/vnext/Desktop/ABI/ReactNativeHost.h index 6f70f09beec..bc5e1f5b4d5 100644 --- a/vnext/Desktop/ABI/ReactNativeHost.h +++ b/vnext/Desktop/ABI/ReactNativeHost.h @@ -1 +1,39 @@ #pragma once + +#include + +#include "Microsoft.ReactNative.ReactNativeHost.g.h" + +namespace winrt::Microsoft::ReactNative::implementation { + +struct ReactNativeHost : ReactNativeHostT { + ReactNativeHost() noexcept; + + // property PackageProviders + Windows::Foundation::Collections::IVector PackageProviders() noexcept; + void PackageProviders(Windows::Foundation::Collections::IVector const &value) noexcept; + + // property InstanceSettings + ReactNative::ReactInstanceSettings InstanceSettings() noexcept; + void InstanceSettings(ReactNative::ReactInstanceSettings const &value) noexcept; + + void ReloadInstance() noexcept; + + void OnSuspend() noexcept; + void OnEnteredBackground() noexcept; + void OnLeavingBackground() noexcept; + void OnResume(OnResumeAction const &action) noexcept; + void OnBackPressed() noexcept; + + private: + ReactNative::ReactInstanceSettings m_instanceSettings{nullptr}; + Windows::Foundation::Collections::IVector m_packageProviders; +}; + +} // namespace winrt::Microsoft::ReactNative::implementation + +namespace winrt::Microsoft::ReactNative::factory_implementation { + +struct ReactNativeHost : ReactNativeHostT {}; + +} // namespace winrt::Microsoft::ReactNative::factory_implementation diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj b/vnext/Desktop/React.Windows.Desktop.vcxproj index 87dba15ea45..841605aa75d 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj @@ -91,6 +91,9 @@ Shlwapi.lib;%(AdditionalDependencies) -minpdbpathlen:256 + + $(ReactNativeWindowsDir)\Microsoft.ReactNative;$(ReactNativeWindowsDir)\Microsoft.ReactNative.Cxx; + @@ -99,6 +102,14 @@ + + + + + + + + diff --git a/vnext/Desktop/module.g.cpp b/vnext/Desktop/module.g.cpp index 84d71805b03..a1ed4613ebe 100644 --- a/vnext/Desktop/module.g.cpp +++ b/vnext/Desktop/module.g.cpp @@ -1,8 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +// WARNING: Please don't edit this file. It was generated by C++/WinRT v2.0.200316.3 + #include "pch.h" #include "winrt/base.h" +void* winrt_make_Microsoft_ReactNative_ReactNativeHost(); void* winrt_make_facebook_react_MemoryTracker(); void* winrt_make_facebook_react_NativeLogEventSource(); void* winrt_make_facebook_react_NativeTraceEventSource(); @@ -25,6 +28,11 @@ void* __stdcall winrt_get_activation_factory([[maybe_unused]] std::wstring_view return std::equal(left.rbegin(), left.rend(), right.rbegin(), right.rend()); }; + if (requal(name, L"Microsoft.ReactNative.ReactNativeHost")) + { + return winrt_make_Microsoft_ReactNative_ReactNativeHost(); + } + if (requal(name, L"facebook.react.MemoryTracker")) { return winrt_make_facebook_react_MemoryTracker(); From a980a4b5f64809d75f3abae5c93732d1c170cf30 Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Sat, 9 May 2020 17:42:53 -0700 Subject: [PATCH 11/13] Change files --- ...act-native-windows-2020-05-09-17-42-52-abi-safety.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 change/react-native-windows-2020-05-09-17-42-52-abi-safety.json diff --git a/change/react-native-windows-2020-05-09-17-42-52-abi-safety.json b/change/react-native-windows-2020-05-09-17-42-52-abi-safety.json new file mode 100644 index 00000000000..ef25becd822 --- /dev/null +++ b/change/react-native-windows-2020-05-09-17-42-52-abi-safety.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "add ReactNativeHost to Win32 C++/WinRT ABI", + "packageName": "react-native-windows", + "email": "aeulitz@microsoft.com", + "dependentChangeType": "patch", + "date": "2020-05-10T00:42:52.866Z" +} From f31a7132f6ca15be0282d2f9eeb70c9f492a1800 Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Mon, 11 May 2020 13:17:24 -0700 Subject: [PATCH 12/13] account for property bag addition --- vnext/Desktop/React.Windows.Desktop.vcxproj | 1 + .../React.Windows.Desktop.vcxproj.filters | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj b/vnext/Desktop/React.Windows.Desktop.vcxproj index b73ac7b3eb2..115c7d66b5f 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj @@ -109,6 +109,7 @@ + diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj.filters b/vnext/Desktop/React.Windows.Desktop.vcxproj.filters index 47723680882..518adf1c504 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj.filters +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj.filters @@ -45,6 +45,33 @@ ABI + + ABI + + + ABI + + + ABI + + + ABI + + + ABI + + + ABI + + + ABI + + + ABI + + + ABI + From e0911bd4f6f3f777a46c7c269eb581f59c337a05 Mon Sep 17 00:00:00 2001 From: Andreas Eulitz Date: Mon, 11 May 2020 17:21:59 -0700 Subject: [PATCH 13/13] sync, address code review feedback --- vnext/Desktop.ABITests/MemoryTrackerTests.cpp | 2 -- vnext/Desktop.ABITests/ReactNativeHostTests.cpp | 3 +++ vnext/Desktop/ABI/ReactNativeHost.cpp | 3 +++ vnext/Desktop/ABI/ReactNativeHost.h | 3 +++ vnext/Desktop/React.Windows.Desktop.vcxproj | 1 + vnext/Desktop/React.Windows.Desktop.vcxproj.filters | 3 +++ 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/vnext/Desktop.ABITests/MemoryTrackerTests.cpp b/vnext/Desktop.ABITests/MemoryTrackerTests.cpp index e673ba7b60e..79ad888716c 100644 --- a/vnext/Desktop.ABITests/MemoryTrackerTests.cpp +++ b/vnext/Desktop.ABITests/MemoryTrackerTests.cpp @@ -10,8 +10,6 @@ #include "ActivationFactory.h" #include "MessageQueueShim.h" -#include "ActivationFactory.h" - using namespace Microsoft::React::Test; using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace winrt::facebook::react; diff --git a/vnext/Desktop.ABITests/ReactNativeHostTests.cpp b/vnext/Desktop.ABITests/ReactNativeHostTests.cpp index 4bcb8d1f54b..7206f5b8daf 100644 --- a/vnext/Desktop.ABITests/ReactNativeHostTests.cpp +++ b/vnext/Desktop.ABITests/ReactNativeHostTests.cpp @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #include "pch.h" #include #include diff --git a/vnext/Desktop/ABI/ReactNativeHost.cpp b/vnext/Desktop/ABI/ReactNativeHost.cpp index f4453740700..4486d9a209f 100644 --- a/vnext/Desktop/ABI/ReactNativeHost.cpp +++ b/vnext/Desktop/ABI/ReactNativeHost.cpp @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #include #include "ReactNativeHost.h" diff --git a/vnext/Desktop/ABI/ReactNativeHost.h b/vnext/Desktop/ABI/ReactNativeHost.h index bc5e1f5b4d5..f1596c4b49b 100644 --- a/vnext/Desktop/ABI/ReactNativeHost.h +++ b/vnext/Desktop/ABI/ReactNativeHost.h @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + #pragma once #include diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj b/vnext/Desktop/React.Windows.Desktop.vcxproj index 115c7d66b5f..304f44e661b 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj @@ -110,6 +110,7 @@ + diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj.filters b/vnext/Desktop/React.Windows.Desktop.vcxproj.filters index 518adf1c504..6a4be8c5886 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj.filters +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj.filters @@ -72,6 +72,9 @@ ABI + + ABI +