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 inconsistency between Debug and serialized representation of Entity #12469

Merged
merged 2 commits into from
Mar 14, 2024

Conversation

Zeenobit
Copy link
Contributor

Objective

Fixes #12139

Solution

  • Derive Debug impl for Entity
  • Add impl Display for Entity
  • Add entity_display test to check the output contains all required info

I decided to go with 0v0|1234 format as opposed to the 0v0[1234] which was initially discussed in the issue.

My rationale for this is that [1234] may be confused for index values, which may be common in logs, and so searching for entities by text would become harder. I figured |1234 would help the entity IDs stand out more.

Additionally, I'm a little concerned that this change is gonna break existing logging for projects because Debug is now going to be a multi-line output. But maybe this is ok.

We could implement Debug to be a single-line output, but then I don't see why it would be different from Display at all.

@alice-i-cecile Let me know if we'd like to make any changes based on these points.

- Derive `Debug` impl for `Entity`
- Add impl `Display` for `Entity`
- Add `entity_display` display to check the output contains all required info
@hymm
Copy link
Contributor

hymm commented Mar 14, 2024

could you give this PR a more descriptive title? The title ends up in the commit history of the main branch

@alice-i-cecile alice-i-cecile changed the title Fix #12139 Fix inconsistency between Debug and serialized representation of Entity Mar 14, 2024
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use C-Needs-Release-Note Work that should be called out in the blog due to impact labels Mar 14, 2024
@james7132 james7132 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 Mar 14, 2024
@james7132
Copy link
Member

james7132 commented Mar 14, 2024

Does this need a release note? Not to knock on the work here, but I don't think it does.

@alice-i-cecile alice-i-cecile removed the C-Needs-Release-Note Work that should be called out in the blog due to impact label Mar 14, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 14, 2024
Merged via the queue into bevyengine:main with commit 7d816aa Mar 14, 2024
29 checks passed
@Zeenobit Zeenobit deleted the entity_debug_impl branch March 14, 2024 23:54
Luracasmus pushed a commit to Luracasmus/bevy that referenced this pull request Jun 25, 2024
# Objective

bevyengine#12469 changed the `Debug` impl for `Entity`, making sure it's actually
accurate for debugging. To ensure that its can still be readily logged
in error messages and inspectors, this PR added a more concise and
human-friendly `Display` impl.

However, users found this form too verbose: the `to_bits` information
was unhelpful and too long. Fixes bevyengine#13980.

## Solution

- Don't include `Entity::to_bits` in the `Display` implementation for
`Entity`. This information can readily be accessed and logged for users
who need it.
- Also clean up the implementation of `Display` for `DebugName`,
introduced in bevyengine#13760, to simply
use the new `Display` impl (since this was the desired format there).

## Testing

I've updated an existing test to verify the output of `Entity::display`.

---------

Co-authored-by: Kristoffer Søholm <k.soeholm@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistency between Debug and serialized representation of Entity
4 participants