From a0c7672f23dcc3c3f45ea68d2e947e89a653483f Mon Sep 17 00:00:00 2001 From: Abhijeet Jha <74712637+iamAbhi-916@users.noreply.github.com> Date: Tue, 28 Oct 2025 16:19:36 +0530 Subject: [PATCH 1/6] visual studio 2026 strict check fix --- .../Fabric/Composition/UiaHelpers.cpp | 12 ++++++++---- vnext/Mso/src/dispatchQueue/queueService.cpp | 4 +++- vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp | 3 ++- vnext/Shared/Networking/OriginPolicyHttpFilter.cpp | 3 ++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp index 68551fd5f22..2de775887a3 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp @@ -48,7 +48,8 @@ HRESULT UiaNavigateHelper( uint32_t index = children.Size() - 1; do { auto child = children.GetAt(index).as(); - if (uiaProvider = child->EnsureUiaProvider()) { + uiaProvider = child->EnsureUiaProvider(); + if (uiaProvider) { break; } } while (index-- != 0); @@ -60,7 +61,8 @@ HRESULT UiaNavigateHelper( uint32_t index = 0; do { auto child = children.GetAt(index).as(); - if (uiaProvider = child->EnsureUiaProvider()) { + uiaProvider = child->EnsureUiaProvider(); + if (uiaProvider) { break; } } while (++index != children.Size()); @@ -74,7 +76,8 @@ HRESULT UiaNavigateHelper( while (++it != children.end()) { auto nextchild = (*it).as(); - if (uiaProvider = nextchild->EnsureUiaProvider()) { + uiaProvider = nextchild->EnsureUiaProvider(); + if (uiaProvider) { break; } } @@ -91,7 +94,8 @@ HRESULT UiaNavigateHelper( do { it--; auto prevchild = (*it).as(); - if (uiaProvider = prevchild->EnsureUiaProvider()) { + uiaProvider = prevchild->EnsureUiaProvider(); + if (uiaProvider) { break; } } while (it != children.begin()); diff --git a/vnext/Mso/src/dispatchQueue/queueService.cpp b/vnext/Mso/src/dispatchQueue/queueService.cpp index d8e8c240173..1738951a2b3 100644 --- a/vnext/Mso/src/dispatchQueue/queueService.cpp +++ b/vnext/Mso/src/dispatchQueue/queueService.cpp @@ -205,8 +205,10 @@ void QueueService::InvokeTask( DispatchTask taskToInvoke{std::move(task)}; taskToInvoke.Get()->Invoke(); // Call Get()->Invoke instead of operator() to flatten call stack - while (taskToInvoke = context.TakeNextDeferredTask()) { + taskToInvoke = context.TakeNextDeferredTask(); + while (taskToInvoke) { taskToInvoke.Get()->Invoke(); + taskToInvoke = context.TakeNextDeferredTask(); } } diff --git a/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp b/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp index 5a469852d45..9cc091cdbc0 100644 --- a/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp +++ b/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp @@ -271,7 +271,8 @@ bool UISchedulerWinRT::TryTakeTask( --m_taskCount; } - if (queue = m_queue.GetStrongPtr()) { + queue = m_queue.GetStrongPtr(); + if (queue) { return queue->TryDequeTask(task); } diff --git a/vnext/Shared/Networking/OriginPolicyHttpFilter.cpp b/vnext/Shared/Networking/OriginPolicyHttpFilter.cpp index 1179be69311..4ae3c1a47be 100644 --- a/vnext/Shared/Networking/OriginPolicyHttpFilter.cpp +++ b/vnext/Shared/Networking/OriginPolicyHttpFilter.cpp @@ -758,7 +758,8 @@ ResponseOperation OriginPolicyHttpFilter::SendRequestAsync(HttpRequestMessage co if (originPolicy == OriginPolicy::CrossOriginResourceSharing) { // If inner filter can AllowRedirect, disable for preflight. winrt::impl::com_ref baseFilter; - if (baseFilter = m_innerFilter.try_as()) { + baseFilter = m_innerFilter.try_as(); + if (baseFilter) { baseFilter.AllowAutoRedirect(false); } From 257b0509554167c0fc485c33636ee9dab0df64e1 Mon Sep 17 00:00:00 2001 From: Abhijeet Jha <74712637+iamAbhi-916@users.noreply.github.com> Date: Fri, 14 Nov 2025 19:03:11 +0530 Subject: [PATCH 2/6] Add HostTargetMetadata with app name and device name for inspector page naming --- .../ReactHost/ReactHost.cpp | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp b/vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp index 5e99e6c6396..4aa7b347fcb 100644 --- a/vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp +++ b/vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp @@ -285,10 +285,28 @@ class ReactInspectorHostTargetDelegate : public jsinspector_modern::HostTargetDe ReactInspectorHostTargetDelegate(Mso::WeakPtr &&reactHost) noexcept : m_reactHost(std::move(reactHost)) {} jsinspector_modern::HostTargetMetadata getMetadata() override { - // TODO: (vmoroz) provide more info - return { - .integrationName = "React Native Windows (Host)", - }; + jsinspector_modern::HostTargetMetadata metadata; + metadata.integrationName = "React Native Windows (Host)"; + metadata.platform = "windows"; + + if (Mso::CntPtr reactHost = m_reactHost.GetStrongPtr()) { + auto options = reactHost->Options(); + if (!options.Identity.empty()) { + std::string identity = options.Identity; + size_t lastSlash = identity.find_last_of("\\/"); + metadata.appDisplayName = (lastSlash != std::string::npos && lastSlash + 1 < identity.length()) + ? identity.substr(lastSlash + 1) + : identity; + } + } + + wchar_t computerName[MAX_COMPUTERNAME_LENGTH + 1]; + DWORD size = MAX_COMPUTERNAME_LENGTH + 1; + if (GetComputerNameW(computerName, &size)) { + metadata.deviceName = winrt::to_string(computerName); + } + + return metadata; } void onReload(jsinspector_modern::HostTargetDelegate::PageReloadRequest const &request) override { @@ -589,9 +607,20 @@ void ReactHost::AddInspectorPage() noexcept { jsinspector_modern::InspectorTargetCapabilities capabilities; capabilities.nativePageReloads = true; capabilities.prefersFuseboxFrontend = true; - // TODO: (vmoroz) improve the page name + + auto metadata = m_inspectorHostTargetDelegate->getMetadata(); + std::string pageName; + if (metadata.appDisplayName.has_value() && !metadata.appDisplayName.value().empty()) { + pageName = metadata.appDisplayName.value(); + } else { + pageName = "React Native Windows (Experimental)"; + } + if (metadata.deviceName.has_value() && !metadata.deviceName.value().empty()) { + pageName += " (" + metadata.deviceName.value() + ")"; + } + inspectorPageId = jsinspector_modern::getInspectorInstance().addPage( - "React Native Windows (Experimental)", + pageName, "Hermes", [weakInspectorHostTarget = std::weak_ptr(m_inspectorHostTarget)](std::unique_ptr remote) From 5c87b76447823416e82457bae14909cff0f0a669 Mon Sep 17 00:00:00 2001 From: Abhijeet Jha <74712637+iamAbhi-916@users.noreply.github.com> Date: Fri, 14 Nov 2025 19:08:40 +0530 Subject: [PATCH 3/6] lint:fix --- vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp | 10 +++++----- .../components/Xaml/XamlHostNativeComponent.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp b/vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp index 4aa7b347fcb..b26d57fcfca 100644 --- a/vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp +++ b/vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp @@ -288,7 +288,7 @@ class ReactInspectorHostTargetDelegate : public jsinspector_modern::HostTargetDe jsinspector_modern::HostTargetMetadata metadata; metadata.integrationName = "React Native Windows (Host)"; metadata.platform = "windows"; - + if (Mso::CntPtr reactHost = m_reactHost.GetStrongPtr()) { auto options = reactHost->Options(); if (!options.Identity.empty()) { @@ -299,13 +299,13 @@ class ReactInspectorHostTargetDelegate : public jsinspector_modern::HostTargetDe : identity; } } - + wchar_t computerName[MAX_COMPUTERNAME_LENGTH + 1]; DWORD size = MAX_COMPUTERNAME_LENGTH + 1; if (GetComputerNameW(computerName, &size)) { metadata.deviceName = winrt::to_string(computerName); } - + return metadata; } @@ -607,7 +607,7 @@ void ReactHost::AddInspectorPage() noexcept { jsinspector_modern::InspectorTargetCapabilities capabilities; capabilities.nativePageReloads = true; capabilities.prefersFuseboxFrontend = true; - + auto metadata = m_inspectorHostTargetDelegate->getMetadata(); std::string pageName; if (metadata.appDisplayName.has_value() && !metadata.appDisplayName.value().empty()) { @@ -618,7 +618,7 @@ void ReactHost::AddInspectorPage() noexcept { if (metadata.deviceName.has_value() && !metadata.deviceName.value().empty()) { pageName += " (" + metadata.deviceName.value() + ")"; } - + inspectorPageId = jsinspector_modern::getInspectorInstance().addPage( pageName, "Hermes", diff --git a/vnext/src-win/src/private/specs_DEPRECATED/components/Xaml/XamlHostNativeComponent.js b/vnext/src-win/src/private/specs_DEPRECATED/components/Xaml/XamlHostNativeComponent.js index 4b0fc158fd8..f1a9ed9c96a 100644 --- a/vnext/src-win/src/private/specs_DEPRECATED/components/Xaml/XamlHostNativeComponent.js +++ b/vnext/src-win/src/private/specs_DEPRECATED/components/Xaml/XamlHostNativeComponent.js @@ -7,8 +7,8 @@ 'use strict'; -import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; -import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; +import type {ViewProps} from 'react-native'; +import {codegenNativeComponent} from 'react-native'; import type {HostComponent} from '../../../../../src/private/types/HostComponent'; type XamlHostProps = $ReadOnly<{| From c218a541663894b6c08eaba5ff294c8b032741eb Mon Sep 17 00:00:00 2001 From: Abhijeet Jha <74712637+iamAbhi-916@users.noreply.github.com> Date: Fri, 14 Nov 2025 19:09:11 +0530 Subject: [PATCH 4/6] Change files --- ...ative-windows-8863778a-7158-453c-abaf-e5c40ed489bc.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/react-native-windows-8863778a-7158-453c-abaf-e5c40ed489bc.json diff --git a/change/react-native-windows-8863778a-7158-453c-abaf-e5c40ed489bc.json b/change/react-native-windows-8863778a-7158-453c-abaf-e5c40ed489bc.json new file mode 100644 index 00000000000..7d94a647b6e --- /dev/null +++ b/change/react-native-windows-8863778a-7158-453c-abaf-e5c40ed489bc.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Add HostTargetMetadata with app name and device name for inspector page naming", + "packageName": "react-native-windows", + "email": "74712637+iamAbhi-916@users.noreply.github.com", + "dependentChangeType": "patch" +} From 65b6b564ceff7929bdb1fd183d2f0ecb424fc989 Mon Sep 17 00:00:00 2001 From: Abhijeet Jha <74712637+iamAbhi-916@users.noreply.github.com> Date: Mon, 17 Nov 2025 11:18:12 +0530 Subject: [PATCH 5/6] revert VS 2026 strict checks fix --- .../Fabric/Composition/UiaHelpers.cpp | 12 ++++-------- vnext/Mso/src/dispatchQueue/queueService.cpp | 4 +--- vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp | 3 +-- vnext/Shared/Networking/OriginPolicyHttpFilter.cpp | 3 +-- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp index 2de775887a3..68551fd5f22 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp @@ -48,8 +48,7 @@ HRESULT UiaNavigateHelper( uint32_t index = children.Size() - 1; do { auto child = children.GetAt(index).as(); - uiaProvider = child->EnsureUiaProvider(); - if (uiaProvider) { + if (uiaProvider = child->EnsureUiaProvider()) { break; } } while (index-- != 0); @@ -61,8 +60,7 @@ HRESULT UiaNavigateHelper( uint32_t index = 0; do { auto child = children.GetAt(index).as(); - uiaProvider = child->EnsureUiaProvider(); - if (uiaProvider) { + if (uiaProvider = child->EnsureUiaProvider()) { break; } } while (++index != children.Size()); @@ -76,8 +74,7 @@ HRESULT UiaNavigateHelper( while (++it != children.end()) { auto nextchild = (*it).as(); - uiaProvider = nextchild->EnsureUiaProvider(); - if (uiaProvider) { + if (uiaProvider = nextchild->EnsureUiaProvider()) { break; } } @@ -94,8 +91,7 @@ HRESULT UiaNavigateHelper( do { it--; auto prevchild = (*it).as(); - uiaProvider = prevchild->EnsureUiaProvider(); - if (uiaProvider) { + if (uiaProvider = prevchild->EnsureUiaProvider()) { break; } } while (it != children.begin()); diff --git a/vnext/Mso/src/dispatchQueue/queueService.cpp b/vnext/Mso/src/dispatchQueue/queueService.cpp index 1738951a2b3..d8e8c240173 100644 --- a/vnext/Mso/src/dispatchQueue/queueService.cpp +++ b/vnext/Mso/src/dispatchQueue/queueService.cpp @@ -205,10 +205,8 @@ void QueueService::InvokeTask( DispatchTask taskToInvoke{std::move(task)}; taskToInvoke.Get()->Invoke(); // Call Get()->Invoke instead of operator() to flatten call stack - taskToInvoke = context.TakeNextDeferredTask(); - while (taskToInvoke) { + while (taskToInvoke = context.TakeNextDeferredTask()) { taskToInvoke.Get()->Invoke(); - taskToInvoke = context.TakeNextDeferredTask(); } } diff --git a/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp b/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp index 9cc091cdbc0..5a469852d45 100644 --- a/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp +++ b/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp @@ -271,8 +271,7 @@ bool UISchedulerWinRT::TryTakeTask( --m_taskCount; } - queue = m_queue.GetStrongPtr(); - if (queue) { + if (queue = m_queue.GetStrongPtr()) { return queue->TryDequeTask(task); } diff --git a/vnext/Shared/Networking/OriginPolicyHttpFilter.cpp b/vnext/Shared/Networking/OriginPolicyHttpFilter.cpp index 4ae3c1a47be..1179be69311 100644 --- a/vnext/Shared/Networking/OriginPolicyHttpFilter.cpp +++ b/vnext/Shared/Networking/OriginPolicyHttpFilter.cpp @@ -758,8 +758,7 @@ ResponseOperation OriginPolicyHttpFilter::SendRequestAsync(HttpRequestMessage co if (originPolicy == OriginPolicy::CrossOriginResourceSharing) { // If inner filter can AllowRedirect, disable for preflight. winrt::impl::com_ref baseFilter; - baseFilter = m_innerFilter.try_as(); - if (baseFilter) { + if (baseFilter = m_innerFilter.try_as()) { baseFilter.AllowAutoRedirect(false); } From 514605804eee732ab27e19a9c650321b845a03b2 Mon Sep 17 00:00:00 2001 From: Abhijeet Jha <74712637+iamAbhi-916@users.noreply.github.com> Date: Mon, 17 Nov 2025 11:26:45 +0530 Subject: [PATCH 6/6] review comments --- .../ReactHost/ReactHost.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp b/vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp index b26d57fcfca..7e205570800 100644 --- a/vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp +++ b/vnext/Microsoft.ReactNative/ReactHost/ReactHost.cpp @@ -285,18 +285,22 @@ class ReactInspectorHostTargetDelegate : public jsinspector_modern::HostTargetDe ReactInspectorHostTargetDelegate(Mso::WeakPtr &&reactHost) noexcept : m_reactHost(std::move(reactHost)) {} jsinspector_modern::HostTargetMetadata getMetadata() override { - jsinspector_modern::HostTargetMetadata metadata; + jsinspector_modern::HostTargetMetadata metadata{}; metadata.integrationName = "React Native Windows (Host)"; metadata.platform = "windows"; if (Mso::CntPtr reactHost = m_reactHost.GetStrongPtr()) { - auto options = reactHost->Options(); + const ReactOptions &options = reactHost->Options(); if (!options.Identity.empty()) { std::string identity = options.Identity; - size_t lastSlash = identity.find_last_of("\\/"); - metadata.appDisplayName = (lastSlash != std::string::npos && lastSlash + 1 < identity.length()) - ? identity.substr(lastSlash + 1) - : identity; + // Replace illegal characters with underscore + for (char &c : identity) { + if (c == '\\' || c == '/' || c == ':' || c == '*' || c == '?' || c == '"' || c == '<' || c == '>' || + c == '|') { + c = '_'; + } + } + metadata.appDisplayName = identity; } }