Validate class registrations against ClassDB#1664
Open
Bromeon wants to merge 2 commits into
Open
Conversation
|
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1664 |
Bromeon
force-pushed
the
qol/validate-registrations
branch
4 times, most recently
from
July 24, 2026 17:48
0da5dd2 to
54d3896
Compare
Extends the deferred startup-message facility with a `Fatal` level: like `Error`, but additionally marks the process for termination. Errors from all init levels are collected first, so one run surfaces every problem. At the terminal init point (`MainLoop` startup callback, Godot 4.5+), the process is terminated with exit code 111 -- gracefully via `SceneTree::quit()` if a scene tree exists, else `process::exit()`. In the editor, the error is only reported, so the developer can read it and hot-reload a fix.
Godot's `classdb_register_extension_class*` functions return void and only print to stderr on failure, so a rejected class, method, property, signal or constant is silently missing at runtime. The printed Godot error may vary in detail, and some of Godot's checks are compiled out of release builds. New `registry::reg_validation` module queries `ClassDB` before each registration and reports a precise error via `defer_startup_fatal!`. Errors are deferred rather than raised inline, since panicking mid-registration would poison the registration locks. A future builder API could reuse this for programmatic success/error feedback. Active only under strict safeguards (default in Debug) and Godot 4.5+, since deferred messages are flushed at the `MainLoop` startup callback, which does not exist before. Up to 4.6, the `ClassDB` singleton appears only after `Core`-level extension init, so its availability is probed per symbol; 4.7 adds it earlier and compiles the probe out. `#[var]` and `#[func]` are allowed to shadow base-class symbols in Godot, but there aren't many use cases, and an explicit `#[var(override)]` or so might be better. For now warn (no breaking change), will become hard error in v0.6.
Bromeon
force-pushed
the
qol/validate-registrations
branch
from
July 24, 2026 21:55
54d3896 to
46dc050
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Godot's
classdb_register_extension_class*functions return void and only print to stderr on failure, so a rejected class, method, property, signal or constant is silently missing at runtime. The printed Godot error may vary in detail.New
registry::reg_validationmodule queriesClassDBbefore each registration and reports a precise error viagodot_error!(and in a potential future builder API would allow programmatic check).In addition, it exits Godot after collecting all errors. Validation runs only under strict safeguards (default in Debug).
#[var]and#[func]are allowed to collide in Godot, but there aren't many use cases, and an explicit#[var(override)]or so might be better. For now warn (no breaking change), will become hard error in v0.6.Here's a small manual test.
Closes #1024.