sschmid / Entitas

Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
MIT License
7k stars 1.11k forks source link

[1.14.1]code gen twice and compile error #1075

Closed sgamerw closed 10 months ago

sgamerw commented 10 months ago

Describe the bug after setup entitas alone wiki, run dotnet Jenny/Jenny.Generator.Cli.dll gen success, but component gen twice which lead to compile error.

➜  Solitaire git:(feature/import_entitas) ✗ dotnet Jenny/Jenny.Generator.Cli.dll gen
Generating using Jenny.properties
Game/Components/GameSuitComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator
Game/GameComponentsLookup.cs - Entitas.CodeGeneration.Plugins.ComponentLookupGenerator
Input/InputComponentsLookup.cs - Entitas.CodeGeneration.Plugins.ComponentLookupGenerator
Game/GameAttribute.cs - Entitas.CodeGeneration.Plugins.ContextAttributeGenerator
Input/InputAttribute.cs - Entitas.CodeGeneration.Plugins.ContextAttributeGenerator
Game/GameContext.cs - Entitas.CodeGeneration.Plugins.ContextGenerator
Input/InputContext.cs - Entitas.CodeGeneration.Plugins.ContextGenerator
Game/GameMatcher.cs - Entitas.CodeGeneration.Plugins.ContextMatcherGenerator
Input/InputMatcher.cs - Entitas.CodeGeneration.Plugins.ContextMatcherGenerator
Contexts.cs - Entitas.CodeGeneration.Plugins.ContextsGenerator, Entitas.VisualDebugging.CodeGeneration.Plugins.ContextObserverGenerator
Game/GameEntity.cs - Entitas.CodeGeneration.Plugins.EntityGenerator
Input/InputEntity.cs - Entitas.CodeGeneration.Plugins.EntityGenerator
Feature.cs - Entitas.VisualDebugging.CodeGeneration.Plugins.FeatureClassGenerator

why GameSuitComponent.cs generate twice, and the code like this:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public partial class GameEntity {

    public SuitComponent suit { get { return (SuitComponent)GetComponent(GameComponentsLookup.Suit); } }
    public bool hasSuit { get { return HasComponent(GameComponentsLookup.Suit); } }

    public void AddSuit(Suit newSuit) {
        var index = GameComponentsLookup.Suit;
        var component = (SuitComponent)CreateComponent(index, typeof(SuitComponent));
        component.Suit = newSuit;
        AddComponent(index, component);
    }

    public void ReplaceSuit(Suit newSuit) {
        var index = GameComponentsLookup.Suit;
        var component = (SuitComponent)CreateComponent(index, typeof(SuitComponent));
        component.Suit = newSuit;
        ReplaceComponent(index, component);
    }

    public void RemoveSuit() {
        RemoveComponent(GameComponentsLookup.Suit);
    }
}

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public partial class GameEntity {

    public SuitComponent suit { get { return (SuitComponent)GetComponent(GameComponentsLookup.Suit); } }
    public bool hasSuit { get { return HasComponent(GameComponentsLookup.Suit); } }

    public void AddSuit(int newS) {
        var index = GameComponentsLookup.Suit;
        var component = (SuitComponent)CreateComponent(index, typeof(SuitComponent));
        component.s = newS;
        AddComponent(index, component);
    }

    public void ReplaceSuit(int newS) {
        var index = GameComponentsLookup.Suit;
        var component = (SuitComponent)CreateComponent(index, typeof(SuitComponent));
        component.s = newS;
        ReplaceComponent(index, component);
    }

    public void RemoveSuit() {
        RemoveComponent(GameComponentsLookup.Suit);
    }
}

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public sealed partial class GameMatcher {

    static Entitas.IMatcher<GameEntity> _matcherSuit;

    public static Entitas.IMatcher<GameEntity> Suit {
        get {
            if (_matcherSuit == null) {
                var matcher = (Entitas.Matcher<GameEntity>)Entitas.Matcher<GameEntity>.AllOf(GameComponentsLookup.Suit);
                matcher.componentNames = GameComponentsLookup.componentNames;
                _matcherSuit = matcher;
            }

            return _matcherSuit;
        }
    }
}

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public sealed partial class GameMatcher {

    static Entitas.IMatcher<GameEntity> _matcherSuit;

    public static Entitas.IMatcher<GameEntity> Suit {
        get {
            if (_matcherSuit == null) {
                var matcher = (Entitas.Matcher<GameEntity>)Entitas.Matcher<GameEntity>.AllOf(GameComponentsLookup.Suit);
                matcher.componentNames = GameComponentsLookup.componentNames;
                _matcherSuit = matcher;
            }

            return _matcherSuit;
        }
    }
}

the same code exists.

below is my Jenny.Properties:

Jenny.SearchPaths = Assets/Plugins/Entitas/Entitas, \
                    Jenny/Plugins/Entitas, \
                    Jenny/Plugins/Jenny
Jenny.Plugins = Entitas.CodeGeneration.Plugins, \
                Entitas.Roslyn.CodeGeneration.Plugins, \
                Entitas.VisualDebugging.CodeGeneration.Plugins, \
                Jenny.Plugins, \
                Jenny.Plugins.Unity
Jenny.PreProcessors = Jenny.Plugins.ValidateProjectPathPreProcessor, \
                      Jenny.Plugins.TargetFrameworkProfilePreProcessor
Jenny.DataProviders = Entitas.CodeGeneration.Plugins.ComponentDataProvider, \
                      Entitas.CodeGeneration.Plugins.ContextDataProvider, \
                      Entitas.CodeGeneration.Plugins.EntityIndexDataProvider, \
                      Entitas.Roslyn.CodeGeneration.Plugins.CleanupDataProvider, \
                      Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider, \
                      Entitas.Roslyn.CodeGeneration.Plugins.EntityIndexDataProvider
Jenny.CodeGenerators = Entitas.CodeGeneration.Plugins.ComponentContextApiGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentEntityApiInterfaceGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentLookupGenerator, \
                       Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator, \
                       Entitas.CodeGeneration.Plugins.ContextAttributeGenerator, \
                       Entitas.CodeGeneration.Plugins.ContextGenerator, \
                       Entitas.CodeGeneration.Plugins.ContextMatcherGenerator, \
                       Entitas.CodeGeneration.Plugins.ContextsGenerator, \
                       Entitas.CodeGeneration.Plugins.EntityGenerator, \
                       Entitas.CodeGeneration.Plugins.EntityIndexGenerator, \
                       Entitas.CodeGeneration.Plugins.EventEntityApiGenerator, \
                       Entitas.CodeGeneration.Plugins.EventListenerComponentGenerator, \
                       Entitas.CodeGeneration.Plugins.EventListenerInterfaceGenerator, \
                       Entitas.CodeGeneration.Plugins.EventSystemGenerator, \
                       Entitas.CodeGeneration.Plugins.EventSystemsGenerator, \
                       Entitas.Roslyn.CodeGeneration.Plugins.CleanupSystemGenerator, \
                       Entitas.Roslyn.CodeGeneration.Plugins.CleanupSystemsGenerator, \
                       Entitas.VisualDebugging.CodeGeneration.Plugins.ContextObserverGenerator, \
                       Entitas.VisualDebugging.CodeGeneration.Plugins.FeatureClassGenerator
Jenny.PostProcessors = Jenny.Plugins.AddFileHeaderPostProcessor, \
                       Jenny.Plugins.CleanTargetDirectoryPostProcessor, \
                       Jenny.Plugins.MergeFilesPostProcessor, \
                       Jenny.Plugins.NewLinePostProcessor, \
                       Jenny.Plugins.UpdateCsprojPostProcessor, \
                       Jenny.Plugins.WriteToDiskPostProcessor, \
                       Jenny.Plugins.ConsoleWriteLinePostProcessor
Jenny.Server.Port = 3333
Jenny.Client.Host = localhost
Jenny.Plugins.ProjectPath = Assembly-CSharp.csproj
Jenny.Plugins.TargetDirectory = Assets/Scripts
Entitas.CodeGeneration.Plugins.Assemblies = Library/ScriptAssemblies/Assembly-CSharp.dll
Entitas.CodeGeneration.Plugins.Contexts = Game, \
                                          Input
Entitas.CodeGeneration.Plugins.IgnoreNamespaces = false

dotnet 6 installed:

➜  ~ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.413
 Commit:    10710f7d8e

To Reproduce Steps to reproduce the behavior:

  1. just run dotnet Jenny/Jenny.Generator.Cli.dll gen

Expected behavior generate code correctly and no compile error.

sgamerw commented 10 months ago

after run doctor and fix command, every thing works well, my operation here:

1030