jeffcampbellmakesgames / Entitas-Redux

An entity-component framework for Unity with code generation and visual debugging
MIT License
103 stars 13 forks source link

[BUG] Component name collision on code generation #2

Closed jeffcampbellmakesgames closed 4 years ago

jeffcampbellmakesgames commented 4 years ago

Describe the bug

Two Components belonging to the same Context with the same short name, but different fully-qualified type names will result in a compilation error post-code generation since the Entity, Matcher, and ComponentsLookup member names for both will be the same.

To Reproduce

  1. Create two components with the same name, one in a global namespace and one in a custom namespace.
using JCMG.EntitasRedux;
using UnityEngine;

namespace ExampleContent
{
    public class FooComponent : IComponent
    {
    }
}

public class FooComponent : IComponent
    {
    }
  1. Run code generation.

  2. Compiler errors will occur.

Expected behavior A warning/exception should be issued prior to code-generation and halts the code-gen process.

Screenshots

image

jeffcampbellmakesgames commented 4 years ago

This has been resolved and merged to develop as of today. If two or more components for a context have a duplicate name, either due to a default or custom name, a warning will be issued for each instance of duplicates found (one per multiple dupes) and finally an DuplicateComponentNameException will be thrown to prevent code generation from occurring.