Skip to content

Commit 830cf8a

Browse files
authored
[Fabric] Remove DeviceInfo stub from template and test app (#12505)
* [Fabric] Remove DeviceInfo stub from template and test app * Change files
1 parent f0bb18d commit 830cf8a

File tree

4 files changed

+8
-62
lines changed

4 files changed

+8
-62
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "[Fabric] Remove DeviceInfo stub from template and test app",
4+
"packageName": "react-native-windows",
5+
"email": "email not defined",
6+
"dependentChangeType": "patch"
7+
}

packages/e2e-test-app-fabric/windows/RNTesterApp-Fabric/RNTesterApp-Fabric.cpp

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,7 @@
1616
#include <winrt/Windows.Foundation.h>
1717
#include "winrt/AutomationChannel.h"
1818

19-
// Work around crash in DeviceInfo when running outside of XAML environment
20-
// TODO rework built-in DeviceInfo to allow it to be driven without use of HWNDs or XamlApps
21-
// Issue Tracking #11414
22-
#include "../../../../vnext/codegen/NativeDeviceInfoSpec.g.h"
23-
REACT_MODULE(DeviceInfo)
24-
struct DeviceInfo {
25-
using ModuleSpec = Microsoft::ReactNativeSpecs::DeviceInfoSpec;
26-
27-
REACT_INIT(Initialize)
28-
void Initialize(React::ReactContext const &reactContext) noexcept {
29-
m_context = reactContext;
30-
}
31-
32-
REACT_GET_CONSTANTS(GetConstants)
33-
Microsoft::ReactNativeSpecs::DeviceInfoSpec_DeviceInfoConstants GetConstants() noexcept {
34-
Microsoft::ReactNativeSpecs::DeviceInfoSpec_DeviceInfoConstants constants;
35-
Microsoft::ReactNativeSpecs::DeviceInfoSpec_DisplayMetrics screenDisplayMetrics;
36-
screenDisplayMetrics.fontScale = 1;
37-
screenDisplayMetrics.height = 1024;
38-
screenDisplayMetrics.width = 1024;
39-
screenDisplayMetrics.scale = 1;
40-
constants.Dimensions.screen = screenDisplayMetrics;
41-
constants.Dimensions.window = screenDisplayMetrics;
42-
return constants;
43-
}
44-
45-
private:
46-
winrt::Microsoft::ReactNative::ReactContext m_context;
47-
};
19+
#include <NativeModules.h>
4820

4921
struct RNTesterAppReactPackageProvider
5022
: winrt::implements<RNTesterAppReactPackageProvider, winrt::Microsoft::ReactNative::IReactPackageProvider> {

packages/playground/windows/playground-composition/Playground-Composition.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
#include <winrt/Windows.Foundation.Collections.h>
1414

15-
#include "../../../../vnext/codegen/NativeDeviceInfoSpec.g.h"
16-
1715
#include <DispatcherQueue.h>
1816
#include <UIAutomation.h>
1917
#include <windows.ui.composition.interop.h>

vnext/templates/cpp-app/windows/MyApp/MyApp.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#include "pch.h"
55
#include "{{ name }}.h"
66

7-
#include "../../node_modules/react-native-windows/codegen/NativeDeviceInfoSpec.g.h"
8-
97
#include <DispatcherQueue.h>
108
#include <UIAutomation.h>
119

@@ -17,35 +15,6 @@
1715

1816
constexpr size_t MAX_LOADSTRING = 100;
1917

20-
// Work around crash in DeviceInfo when running outside of XAML environment
21-
// TODO rework built-in DeviceInfo to allow it to be driven without use of HWNDs or XamlApps
22-
// Issue Tracking #11414
23-
REACT_MODULE(DeviceInfo)
24-
struct DeviceInfo {
25-
using ModuleSpec = Microsoft::ReactNativeSpecs::DeviceInfoSpec;
26-
27-
REACT_INIT(Initialize)
28-
void Initialize(React::ReactContext const &reactContext) noexcept {
29-
m_context = reactContext;
30-
}
31-
32-
REACT_GET_CONSTANTS(GetConstants)
33-
Microsoft::ReactNativeSpecs::DeviceInfoSpec_DeviceInfoConstants GetConstants() noexcept {
34-
Microsoft::ReactNativeSpecs::DeviceInfoSpec_DeviceInfoConstants constants;
35-
Microsoft::ReactNativeSpecs::DeviceInfoSpec_DisplayMetrics screenDisplayMetrics;
36-
screenDisplayMetrics.fontScale = 1;
37-
screenDisplayMetrics.height = 1024;
38-
screenDisplayMetrics.width = 1024;
39-
screenDisplayMetrics.scale = 1;
40-
constants.Dimensions.screen = screenDisplayMetrics;
41-
constants.Dimensions.window = screenDisplayMetrics;
42-
return constants;
43-
}
44-
45-
private:
46-
winrt::Microsoft::ReactNative::ReactContext m_context;
47-
};
48-
4918
// Have to use TurboModules to override built in modules.. so the standard attributed package provider doesn't work.
5019
struct CompReactPackageProvider
5120
: winrt::implements<CompReactPackageProvider, winrt::Microsoft::ReactNative::IReactPackageProvider> {

0 commit comments

Comments
 (0)