Skip to content
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

Fix debug printing for dynamic types #10740

Merged
merged 7 commits into from Dec 12, 2023

Conversation

Davier
Copy link
Contributor

@Davier Davier commented Nov 25, 2023

Objective

Printing DynamicStruct with a debug format does not show the contained type anymore. For instance, in examples/reflection/reflection.rs, adding dbg!(&reflect_value); to line 96 will print:

[examples/reflection/reflection.rs:96] &reflect_value = DynamicStruct(bevy_reflect::DynamicStruct {
    a: 4,
    nested: DynamicStruct(bevy_reflect::DynamicStruct {
        b: 8,
    }),
})

Solution

Show the represented type instead (reflection::Foo and reflection::Bar in this case):

[examples/reflection/reflection.rs:96] &reflect_value = DynamicStruct(reflection::Foo {
    a: 4,
    nested: DynamicStruct(reflection::Bar {
        b: 8,
    }),
})

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.

I’m going to guess all of the dynamic types are broken in this way. Could we fix all of them in this PR as well? If not, we can tackle it in another PR.

crates/bevy_reflect/src/struct_trait.rs Outdated Show resolved Hide resolved
@MrGVSV
Copy link
Member

MrGVSV commented Nov 25, 2023

Might also be worth adding tests to ensure our Debug output doesn't break in the future.

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Reflection Runtime information about types labels Nov 26, 2023
@alice-i-cecile alice-i-cecile added this to the 0.13 milestone Nov 26, 2023
@Davier Davier changed the title Fix DynamicStruct debug printing Fix debug printing for dynamic types Nov 27, 2023
@Davier
Copy link
Contributor Author

Davier commented Nov 29, 2023

I rebased to resolve merge conflicts.

@Davier Davier requested a review from MrGVSV November 29, 2023 09:50
crates/bevy_reflect/src/tuple_struct.rs Outdated Show resolved Hide resolved
crates/bevy_reflect/src/lib.rs Outdated Show resolved Hide resolved
@MrGVSV MrGVSV added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Dec 8, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 12, 2023
Merged via the queue into bevyengine:main with commit 55402bd Dec 12, 2023
23 checks passed
@Davier Davier deleted the dyn_struct_debug_fix branch December 13, 2023 00:41
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-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

5 participants