From 589547ab61a9ff415ca16ad83b0f2f9d8aa7fb4b Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Thu, 22 Jan 2026 07:59:01 -0800 Subject: [PATCH] Update ReactNativeVersion.h not to rely on an anonymous struct (#55271) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55271 Changelog: [Internal] During research for the Stable C++ Api project, I've noticed that doxygen isn't able to handle anonymous structs, producing weird results. The only occurence of this pattern in the codebase was in the `ReactNativeVersion.h` file. This diff updates this file not to use that pattern. Reviewed By: cortinico Differential Revision: D91220998 fbshipit-source-id: 9fd2ec5fb811111a0f3c75bf442f95df4b06a04b --- .../ReactCommon/cxxreact/ReactNativeVersion.h | 6 ++++-- .../set-rn-artifacts-version-test.js.snap | 12 ++++++++---- .../templates/ReactNativeVersion.h-template.js | 6 ++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/react-native/ReactCommon/cxxreact/ReactNativeVersion.h b/packages/react-native/ReactCommon/cxxreact/ReactNativeVersion.h index 0c876d971a6..25468f63f05 100644 --- a/packages/react-native/ReactCommon/cxxreact/ReactNativeVersion.h +++ b/packages/react-native/ReactCommon/cxxreact/ReactNativeVersion.h @@ -18,11 +18,13 @@ namespace facebook::react { -constexpr struct { +struct ReactNativeVersionType { int32_t Major = 1000; int32_t Minor = 0; int32_t Patch = 0; std::string_view Prerelease = ""; -} ReactNativeVersion; +}; + +constexpr ReactNativeVersionType ReactNativeVersion; } // namespace facebook::react diff --git a/scripts/releases/__tests__/__snapshots__/set-rn-artifacts-version-test.js.snap b/scripts/releases/__tests__/__snapshots__/set-rn-artifacts-version-test.js.snap index 26da0dbf79a..bd30713aa4a 100644 --- a/scripts/releases/__tests__/__snapshots__/set-rn-artifacts-version-test.js.snap +++ b/scripts/releases/__tests__/__snapshots__/set-rn-artifacts-version-test.js.snap @@ -138,12 +138,14 @@ exports[`updateReactNativeArtifacts should set nightly version: packages/react-n namespace facebook::react { -constexpr struct { +struct ReactNativeVersionType { int32_t Major = 0; int32_t Minor = 81; int32_t Patch = 0; std::string_view Prerelease = \\"nightly-29282302-abcd1234\\"; -} ReactNativeVersion; +}; + +constexpr ReactNativeVersionType ReactNativeVersion; } // namespace facebook::react " @@ -293,12 +295,14 @@ exports[`updateReactNativeArtifacts should set release version: packages/react-n namespace facebook::react { -constexpr struct { +struct ReactNativeVersionType { int32_t Major = 0; int32_t Minor = 81; int32_t Patch = 0; std::string_view Prerelease = \\"\\"; -} ReactNativeVersion; +}; + +constexpr ReactNativeVersionType ReactNativeVersion; } // namespace facebook::react " diff --git a/scripts/releases/templates/ReactNativeVersion.h-template.js b/scripts/releases/templates/ReactNativeVersion.h-template.js index 66cbe986165..f100ddd15f9 100644 --- a/scripts/releases/templates/ReactNativeVersion.h-template.js +++ b/scripts/releases/templates/ReactNativeVersion.h-template.js @@ -32,14 +32,16 @@ module.exports = ({version} /*: {version: Version} */) /*: string */ => `/** namespace facebook::react { -constexpr struct { +struct ReactNativeVersionType { int32_t Major = ${version.major}; int32_t Minor = ${version.minor}; int32_t Patch = ${version.patch}; std::string_view Prerelease = ${ version.prerelease != null ? `"${version.prerelease}"` : '""' }; -} ReactNativeVersion; +}; + +constexpr ReactNativeVersionType ReactNativeVersion; } // namespace facebook::react `;