Entitas icon indicating copy to clipboard operation
Entitas copied to clipboard

1.14 gen code with jenny, meet some error.

Open woshihuo12 opened this issue 3 years ago • 2 comments

File name: 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at Entitas.Roslyn.CodeGeneration.Plugins.CleanupDataProvider..ctor at Entitas.Roslyn.CodeGeneration.Plugins.CleanupDataProvider..ctor() at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions) --- End of inner exception stack trace --- at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions) at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions) at System.Activator.CreateInstance(Type type) at Jenny.Generator.CodeGeneratorUtil.<>c.<LoadFromPlugins>b__3_0(Type type) at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.ToArray() at Jenny.Generator.CodeGeneratorUtil.LoadFromPlugins(Preferences preferences) at Jenny.Generator.CodeGeneratorUtil.CodeGeneratorFromPreferences(Preferences preferences) at Jenny.Generator.Cli.GenerateCommand.Run() at DesperateDevs.Cli.Utils.AbstractCommand.Run(CliProgram program, String[] args) at DesperateDevs.Serialization.Cli.Utils.AbstractPreferencesCommand.Run(CliProgram program, String[] args) at Jenny.Generator.Cli.ServerCommand.OnReceived(AbstractTcpSocket socket, Socket client, Byte[] bytes)Exception has been thrown by the target of an invocation.

woshihuo12 avatar Sep 20 '22 17:09 woshihuo12

Microsoft.CodeAnalysis is part of the default Jenny plugin. Can you share your Jenny.properties?

I recommend using Match-One Jenny.properties if you have problems.

Update the search paths accordingly, if your folder structure is different. https://github.com/sschmid/Match-One/blob/main/Jenny.properties

sschmid avatar Sep 20 '22 18:09 sschmid

Someone from the Entitas Discord chat had a similar issue which is now fixed for him: https://discord.com/channels/599321316377624601/1020245560776720425

Quote from Rene:

Quick guess here. You downloaded the .zip and there's still the windows protection that prevents from loading .dll files Please check when you download the file before unzipping if you toggled this here in properties of the file:

After you toggled unblock you can unzip and then it should work

sschmid avatar Sep 20 '22 18:09 sschmid

@woshihuo12 did you make it work?

sschmid avatar Sep 21 '22 18:09 sschmid

Jenny.SearchPaths = Assets/Library/Entitas/Entitas, \
                    Assets/Library/Entitas/Jenny/Editor/Jenny, \
                    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.Unity.WarnIfCompilationErrorsPreProcessor, \
                      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.Plugins.Unity.DebugLogPostProcessor
Jenny.Server.Port = 3333
Jenny.Client.Host = localhost
Entitas.CodeGeneration.Plugins.Contexts = Game, \
                                          Time
Entitas.CodeGeneration.Plugins.IgnoreNamespaces = false
Jenny.Plugins.ProjectPath = Assembly-CSharp.csproj
Jenny.Plugins.TargetDirectory = Assets
Entitas.CodeGeneration.Plugins.Assemblies = Library/ScriptAssemblies/Assembly-CSharp.dll

woshihuo12 avatar Sep 25 '22 09:09 woshihuo12

and i meet a new error with jenny gen. gen Jenny.properties Generating using Jenny.properties Could not load file or assembly 'UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

but i can generate without server mode.

woshihuo12 avatar Sep 25 '22 09:09 woshihuo12

@woshihuo12 I see your Jenny.properties is not setup correctly. A good start is to use the one from Match-One: https://github.com/sschmid/Match-One/blob/main/Jenny.properties

Jenny can fix those issue for you by running

dotnet Jenny/Jenny.Generator.Cli.dll fix

but try using the Jenny.properties from Match-One first, because it's setup correctly already.

Also, please make sure you have dotnet 6.0 installed. You can check the version by running

dotnet --version

sschmid avatar Sep 25 '22 11:09 sschmid

If you don't have Entitas installed at the default location (Assets/Entitas), please update your Jenny.SearchPaths accordingly

sschmid avatar Sep 25 '22 11:09 sschmid

same error here, after I run doctor and fix command, every thing work well.

below is my operation:

➜  Solitaire git:(feature/import_entitas) ✗ dotnet Jenny/Jenny.Generator.Cli.dll gen  
Generating using Jenny.properties
Could not load file or assembly 'UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

Use -v to enable verbose logging
➜  Solitaire git:(feature/import_entitas) ✗ dotnet --version
6.0.413
➜  Solitaire git:(feature/import_entitas) ✗ dotnet Jenny/Jenny.Generator.Cli.dll doctor
⚠️  Potential collision detected: ComponentDataProvider -> Entitas.CodeGeneration.Plugins.ComponentDataProvider
⚠️  Potential collision detected: ComponentDataProvider -> Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider
⚠️  Potential collision detected: EntityIndexDataProvider -> Entitas.CodeGeneration.Plugins.EntityIndexDataProvider
⚠️  Potential collision detected: EntityIndexDataProvider -> Entitas.Roslyn.CodeGeneration.Plugins.EntityIndexDataProvider
👨‍⚕️  Symptoms: Entitas.CodeGeneration.Plugins.ComponentDataProvider loads and reflects Library/ScriptAssemblies/Assembly-CSharp.dll and therefore doesn't support server mode!
💊  Treatment: Don't use the code generator in server mode with Entitas.CodeGeneration.Plugins.ComponentDataProvider
👨‍⚕️  Symptoms: Entitas.CodeGeneration.Plugins.EntityIndexDataProvider loads and reflects Library/ScriptAssemblies/Assembly-CSharp.dll and therefore doesn't support server mode!
💊  Treatment: Don't use the code generator in server mode with Entitas.CodeGeneration.Plugins.EntityIndexDataProvider
👨‍⚕️  Symptoms: Jenny.Plugins.Unity.DebugLogPostProcessor uses Unity APIs but is used outside of Unity!
💊  Treatment: Remove Jenny.Plugins.Unity.DebugLogPostProcessor from CodeGenerator.PostProcessors
👨‍⚕️  Symptoms: Jenny.Plugins.Unity.WarnIfCompilationErrorsPreProcessor uses Unity APIs but is used outside of Unity!
💊  Treatment: Remove Jenny.Plugins.Unity.WarnIfCompilationErrorsPreProcessor from CodeGenerator.PreProcessors
Use 'jenny fix' to apply treatments
Use -v to enable verbose logging
➜  Solitaire git:(feature/import_entitas) ✗ dotnet Jenny/Jenny.Generator.Cli.dll fix   
⚠️  Potential plugin collision: ComponentDataProvider
0: Keep all (no changes)
1: Keep Entitas.CodeGeneration.Plugins.ComponentDataProvider
2: Keep Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider
Removed: Entitas.CodeGeneration.Plugins.ComponentDataProvider
⚠️  Potential plugin collision: EntityIndexDataProvider
0: Keep all (no changes)
1: Keep Entitas.CodeGeneration.Plugins.EntityIndexDataProvider
2: Keep Entitas.Roslyn.CodeGeneration.Plugins.EntityIndexDataProvider
Removed: Entitas.CodeGeneration.Plugins.EntityIndexDataProvider
❌  Remove unused key: 'Entitas.CodeGeneration.Plugins.Assemblies' ? (y / n)
Removed: Entitas.CodeGeneration.Plugins.Assemblies
💉  Apply fix: Remove Jenny.Plugins.Unity.DebugLogPostProcessor from CodeGenerator.PostProcessors
to treat symptoms: Jenny.Plugins.Unity.DebugLogPostProcessor uses Unity APIs but is used outside of Unity! ? (y / n)
💉  Apply fix: Remove Jenny.Plugins.Unity.WarnIfCompilationErrorsPreProcessor from CodeGenerator.PreProcessors
to treat symptoms: Jenny.Plugins.Unity.WarnIfCompilationErrorsPreProcessor uses Unity APIs but is used outside of Unity! ? (y / n)
❌  Remove unused search path: 'Assets/Plugins/Entitas/Entitas' ? (y / n)
❌  Remove unused search path: 'Jenny/Plugins/Jenny' ? (y / n)
➜  Solitaire git:(feature/import_entitas) ✗ dotnet Jenny/Jenny.Generator.Cli.dll doctor
ℹ️  Available: Jenny.Plugins.Unity.WarnIfCompilationErrorsPreProcessor
ℹ️  Available: Entitas.CodeGeneration.Plugins.ComponentDataProvider
ℹ️  Available: Entitas.CodeGeneration.Plugins.EntityIndexDataProvider
ℹ️  Available: Jenny.Plugins.Unity.DebugLogPostProcessor
Dry Run
Game/Components/GameSuitComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, 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

👨‍🔬  No problems detected. Happy coding :)

sgamerw avatar Aug 22 '23 12:08 sgamerw