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

Cannot use language keywords as the name of a component #1032

Closed
PopSlime opened this issue Sep 22, 2022 · 3 comments
Closed

Cannot use language keywords as the name of a component #1032

PopSlime opened this issue Sep 22, 2022 · 3 comments
Labels

Comments

@PopSlime
Copy link

PopSlime commented Sep 22, 2022

Describe the bug

When language keywords like Event are used as the name of a component, the code generator fails to handle the component name correctly.

To Reproduce

Generate code for the following component.

[Game]
public sealed class EventComponent : IComponent {
	public MyEvent Event;
}

Generated code:

public partial class GameEntity {

    public EventComponent event { get { return (EventComponent)GetComponent(GameComponentsLookup.Event); } }
    // ...
}

Compilation error:

Assets\Generated\Game\Components\EventComponent.cs: error CS1519: Invalid token 'event' in class, record, struct, or interface member declaration

Potential Solution

Prefix the component name with a verbatim identifier @ if it is a language keyword. For example, event becomes @event.

Entitas Version

  • Entitas 1.14.0
@PopSlime PopSlime added the bug label Sep 22, 2022
@PopSlime PopSlime changed the title Cannot use language keywords as the name of a component field Cannot use language keywords as the name of a component Sep 22, 2022
@sschmid
Copy link
Owner

sschmid commented Sep 22, 2022

I removed the check for reserved keywords temporarily, because I had issues with CodeDom. I will re-add in next version.

@sschmid
Copy link
Owner

sschmid commented Sep 22, 2022

for reference, here's the commit to blame:
bf344c8

@sschmid
Copy link
Owner

sschmid commented Sep 26, 2022

Fixed in Entitas 1.14.1
/~https://github.com/sschmid/Entitas/releases/tag/1.14.1

@sschmid sschmid closed this as completed Sep 26, 2022
@sschmid sschmid added this to Entitas Jul 2, 2023
@github-project-automation github-project-automation bot moved this to Todo in Entitas Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

2 participants