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

[Merged by Bors] - Add reflection for resources #5175

Closed
wants to merge 5 commits into from
Closed

[Merged by Bors] - Add reflection for resources #5175

wants to merge 5 commits into from

Conversation

Shatur
Copy link
Contributor

@Shatur Shatur commented Jul 2, 2022

Objective

We don't have reflection for resources.

Solution

Introduce reflection for resources.

Continues #3580 (by @Davier), related to #3576.


Changelog

Added

  • Reflection on a resource type (by adding ReflectResource):
#[derive(Reflect)]
#[reflect(Resource)]
struct MyResourse;

@alice-i-cecile alice-i-cecile added C-Enhancement A new feature A-Reflection Runtime information about types labels Jul 2, 2022
@alice-i-cecile alice-i-cecile added this to the Bevy 0.8 milestone Jul 2, 2022
@alice-i-cecile
Copy link
Member

Can you credit @Davier as a co-author in the PR description to make sure this gets into the release notes properly? :)

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Just like in the previous PR, I'm very happy that this exists and content with the underlying code.

Only thing I think this needs is basic docs on ReflectResource.

I won't block on this, but if you want to put more work into this PR:

  1. Docs on ReflectResource methods.
  2. Consider enabling reflection for more resource types.

Copy link
Contributor

@PROMETHIA-27 PROMETHIA-27 left a comment

Choose a reason for hiding this comment

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

I like it! Looks very useful. I have some docstring suggestions for the functions; feel free to modify them, especially if the doclinks don't work. They should, but sometimes doclinks are wonky.

crates/bevy_ecs/src/reflect.rs Show resolved Hide resolved
crates/bevy_ecs/src/reflect.rs Show resolved Hide resolved
crates/bevy_ecs/src/reflect.rs Show resolved Hide resolved
crates/bevy_ecs/src/reflect.rs Show resolved Hide resolved
crates/bevy_ecs/src/reflect.rs Show resolved Hide resolved
crates/bevy_ecs/src/reflect.rs Show resolved Hide resolved
@Shatur
Copy link
Contributor Author

Shatur commented Jul 2, 2022

Thanks for the tips. Updated the documentation. Please, take a look.

@Shatur
Copy link
Contributor Author

Shatur commented Jul 2, 2022

Some thoughts for the future PRs:

  • Maybe it worth to rename add_component into insert_component?
  • Maybe not panic in apply_resource / apply_component? Or introduce another function apply_or_insert?

Copy link
Contributor

@PROMETHIA-27 PROMETHIA-27 left a comment

Choose a reason for hiding this comment

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

Just one little nitpick, but otherwise LGTM!

crates/bevy_ecs/src/reflect.rs Outdated Show resolved Hide resolved
@alice-i-cecile
Copy link
Member

One final round of doc nits. I'll merge this on Monday during my weekly round :)

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
@alice-i-cecile alice-i-cecile 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 Jul 2, 2022
@Shatur
Copy link
Contributor Author

Shatur commented Jul 2, 2022

Maybe it worth to rename add_component into insert_component?

Can this be included here for consistency with the added insert_resource or out of scope?

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Jul 2, 2022

No strong feelings. Feel free to include it if you'd like; reflection is getting basically a full rewrite in this release anyways.

If you do, note it in the migration guide.

@Shatur
Copy link
Contributor Author

Shatur commented Jul 2, 2022

Okay, thanks, done!

@alice-i-cecile alice-i-cecile added the C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide label Jul 2, 2022
@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Jul 4, 2022
# Objective

We don't have reflection for resources.

## Solution

Introduce reflection for resources.

Continues #3580 (by @Davier), related to #3576.

---

## Changelog

### Added

* Reflection on a resource type (by adding `ReflectResource`):

```rust
#[derive(Reflect)]
#[reflect(Resource)]
struct MyResourse;
```

### Changed

* Rename `ReflectComponent::add_component` into `ReflectComponent::insert_component` for consistency.

## Migration Guide

* Rename `ReflectComponent::add_component` into `ReflectComponent::insert_component`.
@bors bors bot changed the title Add reflection for resources [Merged by Bors] - Add reflection for resources Jul 4, 2022
@bors bors bot closed this Jul 4, 2022
@Shatur
Copy link
Contributor Author

Shatur commented Jul 4, 2022

Okay, thanks, done!

Forgot to push it :D
Opened #5201

inodentry pushed a commit to IyesGames/bevy that referenced this pull request Aug 8, 2022
# Objective

We don't have reflection for resources.

## Solution

Introduce reflection for resources.

Continues bevyengine#3580 (by @Davier), related to bevyengine#3576.

---

## Changelog

### Added

* Reflection on a resource type (by adding `ReflectResource`):

```rust
#[derive(Reflect)]
#[reflect(Resource)]
struct MyResourse;
```

### Changed

* Rename `ReflectComponent::add_component` into `ReflectComponent::insert_component` for consistency.

## Migration Guide

* Rename `ReflectComponent::add_component` into `ReflectComponent::insert_component`.
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
# Objective

We don't have reflection for resources.

## Solution

Introduce reflection for resources.

Continues bevyengine#3580 (by @Davier), related to bevyengine#3576.

---

## Changelog

### Added

* Reflection on a resource type (by adding `ReflectResource`):

```rust
#[derive(Reflect)]
#[reflect(Resource)]
struct MyResourse;
```

### Changed

* Rename `ReflectComponent::add_component` into `ReflectComponent::insert_component` for consistency.

## Migration Guide

* Rename `ReflectComponent::add_component` into `ReflectComponent::insert_component`.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

We don't have reflection for resources.

## Solution

Introduce reflection for resources.

Continues bevyengine#3580 (by @Davier), related to bevyengine#3576.

---

## Changelog

### Added

* Reflection on a resource type (by adding `ReflectResource`):

```rust
#[derive(Reflect)]
#[reflect(Resource)]
struct MyResourse;
```

### Changed

* Rename `ReflectComponent::add_component` into `ReflectComponent::insert_component` for consistency.

## Migration Guide

* Rename `ReflectComponent::add_component` into `ReflectComponent::insert_component`.
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-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide C-Enhancement A new feature S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants