[CodeGenerator:] Generate component interfaces
See original GitHub issueThe problem
You are allowed to write this
entity.health.value = 42;
but you shouldn’t. You always should replace components like this
entity.ReplaceHealth(42);
The solution
This
entity.health.value = 42;
should result in a compile error.
The Plan
Declare your components with the partial keyword and getters and setters
public partial class HealthComponent : IComponent {
public int value { get; set; }
}
The code generator should generate
// Getter only
public interface IHealthComponent : IComponent {
int value { get; }
}
// Make component sealed and implement interface
public sealed partial class HealthComponent : IHealthComponent {
}
All the generated API of other generators will use the interface instead of the component which means this
entity.health.value = 42;
will result in a compile error 👍
Make Entitas safe again!
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (10 by maintainers)
Top Results From Across the Web
[CodeGenerator:] Generate component interfaces #340
F.e. you have global component with counters that is affected by multiple systems almost every frame, but no one need to react on...
Read more >Configure Code Interfaces for Code Generation
The code generator uses the mappings to produce code that can interact with target platform services. You configure a model with a data...
Read more >Generating code for component diagrams
The following code generation semantics apply to component diagrams: Code generation is provided for library and executable build type components.
Read more >Generating PeopleCode Templates to Access Component ...
To access a component interface using PeopleCode, PeopleSoft Application Designer generates a template in the form of boilerplate PeopleCode that you can ...
Read more >Widget Code Generator by Figma
The Widget Code Generator plugin for Figma design allows you to design FigJam widgets and easily translate your designs into code.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The goal is not to remove flexibility but to make it harder to write code with bugs
just had another real-life issue from a user that called e.position.x = 42; I think that feature really helps reducing bugs