Skip to content

UE5.4 support, struct names, binrw - #147

Open
scottanderson wants to merge 168 commits into
localcc:mainfrom
scottanderson:binrw
Open

UE5.4 support, struct names, binrw#147
scottanderson wants to merge 168 commits into
localcc:mainfrom
scottanderson:binrw

Conversation

@scottanderson

@scottanderson scottanderson commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Incomplete

  • Type hints are not implemented. When type information is unavailable, FStructProperty::Custom will attempt to parse the property, and in the event that parsing fails, FStructProperty::Unknown will be used as a generic fallback. This type is distinct from FProperty::Unknown, because a UE4.5 FStructProperty::Unknown has its own type metadata and struct-guid.

@scottanderson
scottanderson marked this pull request as ready for review July 29, 2026 05:34

@localcc localcc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the hints, I will look if the binrw crate can be trivially modified (potentially upstreamed) for access of the property stack

Comment thread src/types/f_date_time.rs
@@ -0,0 +1,116 @@
use std::{fmt::Display, str::FromStr};

use chrono::{DateTime, Utc};

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should chrono be an optional feature enabled by default?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I will try it. I think chrono is only used for serde -> Display/FromStr -> chrono, so it might make sense to tie it to the serde feature.

Comment thread src/types/f_guid.rs
Comment thread src/types/f_text.rs
#[brw(args(format))] TOptional<NumberFormattingOptions>,
FString,
),
// #[brw(magic = 5i8)] AsPercent(FormatArgumentValue, TOptional<NumberFormattingOptions>, FString),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason for those being commented out?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comments are correct from my read of the code, but I have not verified them because the existing test fixtures don't have examples of these.

Comment thread src/types/f_text.rs
Comment on lines +29 to +33
// #[brw(magic = -1i8)]
// #[br(pre_assert(!format.culture_invariant_stability))]
// Empty(),
#[brw(magic = -1i8)]
// #[br(pre_assert(format.culture_invariant_stability))]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these comments can be removed, FTextHistoryNone handles that now.

Suggested change
// #[brw(magic = -1i8)]
// #[br(pre_assert(!format.culture_invariant_stability))]
// Empty(),
#[brw(magic = -1i8)]
// #[br(pre_assert(format.culture_invariant_stability))]
#[brw(magic = -1i8)]

Comment on lines +19 to +21
// #[binrw]
// #[br(import(format: &SerializationFormat, size: Option<u32>, struct_type: &FString, class_name: Option<&str>, guid: FGuid, hint_map: &HintMap, path: Path))]
// #[bw(import(format: &SerializationFormat))]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to leave FStructProperty derived, because it makes the code substantially easier to read.

I think it should be possible to move the variants that need custom handling into their own struct, and leave the enum itself as derived.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that seems like it would make matching on the fstructproperty values harder for users, is there a way to inline it with binrw?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would not change the shape of FStructProperty.

With binrw, if a variant contains something that can't be derived, you can move just that part into a named type that manually implements the binrw traits, while keeping the parent enum derived.

Instead of:

enum FStructProperty {
    Variant(
        /* inner value that requires custom BinRead/BinWrite logic */
    ),
}

// FStructProperty manually implements BinRead/BinWrite

you can do:

#[binrw]
enum FStructProperty {
    Variant(InnerType),
}

struct InnerType {
    /* fields that require custom BinRead/BinWrite logic */
}

// InnerType manually implements BinRead/BinWrite

The public shape of FStructProperty is still the same kind of enum, so matching on it is unchanged in practice. The difference is just that the custom serialization logic is isolated to the part that actually needs it, rather than manually reimplementing the entire enum's serialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants