Skip to content

TypeRegistrationDeserializer: allow fallback to short type paths #18885

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zwazel
Copy link

@zwazel zwazel commented Apr 20, 2025

After a brief Discord conversation with @MrGVSV , I was encouraged to open this pull request to initiate a broader discussion.
This is my first contribution to Bevy.

Objective

  • Permit TypeRegistrationDeserializer to resolve a TypeRegistration using
    the short type path (TypePath::short_type_path) when the full type path is
    not found.
  • Backwards‑compatible: existing data that supplies the full path continues to
    work unchanged.

Solution

  • Inside visit_str we now attempt registry.get_with_short_type_path
    if get_with_type_path fails.
  • No other behavior changed; the full type path remains the primary lookup, so
    there is no performance impact for existing data.

Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Reflection Runtime information about types S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 23, 2025
Copy link
Member

@MrGVSV MrGVSV left a comment

Choose a reason for hiding this comment

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

Looks good! I think it should be okay to do this since it shouldn't affect performance on the happy path and simplifies things for custom formats where Bevy itself isn't taking on the risk of naming conflicts.

Just one comment regarding documentation.

Comment on lines +12 to +14
/// For backward‑compatibility the deserializer first attempts a lookup with the
/// full type path; if no registration is found it falls back to the short type
/// path.
Copy link
Member

Choose a reason for hiding this comment

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

This isn't just a backward compatible thing. We always want to prioritize full type paths since short paths are more likely to conflict. So I would maybe change the wording a bit here to indicate the intended priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types C-Feature A new feature, making something new possible S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants