Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RN][Codegen] add missing struct member initialization in Props.h #44294

Closed
wants to merge 1 commit into from

Commits on Apr 29, 2024

  1. add missing struct member initialization in Props.h

    Summary:
    **Problem:**
    
    It was discovered while testing 3 party library, generated member variables in a C++ `struct` in `Props.h` is not initialized.
    Also `WithDefault` would not work as well.
    (For the problematic case it was a `boolean` but would also apply to other primitive types.)
    
    If there is no default initialization and the component prop is optional and the user of the native component does not set the prop then the variable is never initialized and this is problematic for primitive types in C++ where no initialization results in an undefined behavior.
    
    **Proposed solution:**
    
    (Following C++Core Guideline of [always initialize](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always).)
    Reusing `generatePropsString()` used by `ClassTemplate` to generate props for `StructTemplate` as well.
    updated relevant test snapshots.
    This change is only concerning the `Props.h` file.
    
    **Changelog:**
    [General][Fixed] - fixed `Props.h` created from codegen missing default initializers in C++ `struct`
    
    Differential Revision: D56659457
    alanleedev authored and facebook-github-bot committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    8b9a70e View commit details
    Browse the repository at this point in the history