GameDevTecnico / cubos

A still very barebones game engine focused on voxels and data-oriented programming
https://cubosengine.org
MIT License
84 stars 34 forks source link

Ensure reflectable types with `FieldsTrait` expose all of their fields #640

Open RiscadoA opened 1 year ago

RiscadoA commented 1 year ago

Problem

It hasn't happened yet but it seems that someone adding a new field to a reflectable type and forgetting to add it to the trait will be a common problem. It will probably will be hard to debug, at least in the near future.

In a more distant future, it probably won't be that bad for game devs using our engine, as they would probably notice quickly that the new field isn't saved to scene files and won't appear on the editor.

Solution

We could have a CI action to check that this isn't violated, or extend clang-tidy to do so.

roby2014 commented 11 months ago

Maybe also relevant for EnumTrait (#579)

RiscadoA commented 11 months ago

Maybe also relevant for EnumTrait (#579)

We previously discussed a partial solution to this problem which doesn't cover the EnumTrait scenario, which was checking if the size of the type we're reflecting actually makes sense considering the fields we're reflecting. In retrospective, that isn't a good approach as we possibly want to avoid reflecting some fields anyway. But yeah, that solution wasn't perfect anyway.