Skip to content

[SavedProperty] in base classes is ignored during PostModInitPatch #63

@Creeper-of-Fire

Description

@Creeper-of-Fire

In BaseLib.Patches.PostModInitPatch.ProcessModdedTypes, the code uses modType.GetDeclaredProperties() to check for the [SavedProperty] attribute.

However, GetDeclaredProperties() only returns properties defined in the immediate class, ignoring inherited properties. If a modder defines a base class (e.g., AbstractCustomRelic) with [SavedProperty] and multiple relics inherit from it, those derived relic types will fail the check and won't be injected into SavedPropertiesTypeCache.

This causes all inherited saved properties to be lost upon saving/loading.

Suggested Fix:

Change GetDeclaredProperties() to GetProperties() or ensure inherited properties are scanned:

// Current
foreach (PropertyInfo declaredProperty in modType.GetDeclaredProperties())

// Suggested?
foreach (PropertyInfo prop in modType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))

Or, specifically check if the type or its parents contain the attribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions