-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Detailed migration guide for automatic reflection registration #21109
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
Merged
alice-i-cecile
merged 7 commits into
bevyengine:main
from
alice-i-cecile:auto-registration-notes
Sep 21, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
24095f6
Detailed migration guide for automatic reflection registration
alice-i-cecile 09ea72a
Address feedback from Jan
alice-i-cecile df16f3b
Clarify advice on not enabling feature flags
alice-i-cecile 00dcf7f
Feedback from reviewers
alice-i-cecile 783b08b
Cut digression on utility of reflection
alice-i-cecile e2ff3cc
Clarify what's gated by feature flags
alice-i-cecile 3f83908
Clarify that manual type registration still works
alice-i-cecile File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
release-content/migration-guides/reflect_registration_changes.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
| title: Changes to type registration for reflection | ||
| pull_requests: [15030, 20435, 20893] | ||
| --- | ||
|
|
||
| Calling `.register_type` has long been a nuisance for Bevy users: both library authors and end users. | ||
| This step was previously required in order to register reflected type information in the `TypeRegistry`. | ||
|
|
||
| In Bevy 0.17 however, types which implement `Reflect` are now automatically registered, with the help of some compiler magic. | ||
| You should be able to remove almost all of your `register_type` calls. | ||
| This comes with a few caveats however: | ||
alice-i-cecile marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 1. Automatic type registration is gated by feature flags. | ||
| 2. There are two approaches to do this: one has incomplete platform support, while the other relies on a specific project structure. | ||
| 3. Generic types are not automatically registered, and must still be manually registered. | ||
|
|
||
| In order for Bevy to automatically register your types, you need to turn on the `reflect_auto_register` feature, or the fallback `reflect_auto_register_static`. | ||
| The `reflect_auto_register` feature is part of Bevy's default features, and can be overridden by the `reflect_auto_register_static` feature flag. | ||
| Be aware that the `reflect_auto_register_static` feature comes with some caveats for project structure: check the docs for [load_type_registrations!](https://docs.rs/bevy/0.17.0-rc.1/bevy/reflect/macro.load_type_registrations.html) and follow the [`auto_register_static` example](https://github.com/bevyengine/bevy/tree/main/examples/reflection/auto_register_static). | ||
|
|
||
| We recommend that you: | ||
|
|
||
| 1. Enable `reflect_auto_register` in your application code, CI and in examples/tests. You can enable `bevy` features for tests only by adding a matching copy of `bevy` to `dev-dependencies` with the needed features enabled. | ||
| 2. Do not enable the `reflect_auto_register` feature or the fallback `reflect_auto_register_static` in your library code. | ||
| 3. As a library author, you can safely remove all non-generic `.register_type` calls. | ||
| 4. As a user, if you run into an unregistered generic type with the correct feature enabled, file a bug with the project that defined the offending type, and workaround it by calling `.register_type` manually. | ||
| 5. If you are on an unsupported platform but need reflection support, try the `reflect_autoregister_static` feature, and consider working upstream to add support for your platform in `inventory`. As a last resort, you can still manually register all of the needed types in your application code. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.