question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[CodeGenerator:] Generate component interfaces

See original GitHub issue

The 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:closed
  • Created 7 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
sschmidcommented, Mar 18, 2017

The goal is not to remove flexibility but to make it harder to write code with bugs

1reaction
sschmidcommented, Mar 23, 2017

just had another real-life issue from a user that called e.position.x = 42; I think that feature really helps reducing bugs

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found