Skip to content

Conversation

@brougkr
Copy link

@brougkr brougkr commented Jan 9, 2026

Summary

UE5 strict mode requires all UPROPERTY fields to be explicitly initialized, otherwise the engine logs "property not initialized properly" errors at startup. This PR ensures generated Unreal C++ code properly initializes all UPROPERTY fields.

Changes

  • Modified cpp_ty_init_fmt_impl to accept module parameter for enum type resolution
  • Added initialization for enum types (PlainEnum) using the first variant as default value
  • Updated all call sites in reducer/procedure/struct generation to pass the module

Before

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
EMyEnumType SomeEnumField;  // ERROR: property not initialized properly

After

UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB")
EMyEnumType SomeEnumField = EMyEnumType::FirstVariant;  // OK

Affected generated code

  • Reducer args structs (FXxxReducerArgs)
  • Reducer classes (UXxxReducer)
  • Procedure args structs (FXxxProcedureArgs)
  • Product type structs (FXxxType)

Test plan

  • Build codegen crate successfully
  • Generate bindings for a project with enum types
  • Verify generated code has proper initializers
  • Build Unreal project without "property not initialized properly" errors

Generated with Claude Code

UE5 strict mode requires all UPROPERTY fields to be explicitly
initialized, otherwise the engine logs "property not initialized
properly" errors at startup.

This change ensures generated reducer/procedure args structs and
reducer classes have proper initializers for:

- Primitive types (bool, int, float, etc.)
- Enum types (PlainEnum) - initialized to first variant

The `cpp_ty_init_fmt_impl` function now takes `module` as a parameter
to resolve enum type references and generate appropriate default
values like `= EMyEnumType::FirstVariant`.

Affected generated code:
- Reducer args structs (FXxxReducerArgs)
- Reducer classes (UXxxReducer)
- Procedure args structs (FXxxProcedureArgs)
- Product type structs (FXxxType)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@JasonAtClockwork JasonAtClockwork self-requested a review January 9, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant