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

Jenny gen error "Could not resolve type with token " [1.14.1] #1050

Closed GuyChriqui closed 1 year ago

GuyChriqui commented 1 year ago

Describe the bug

When trying to generate for the first time after installing Entitas and Jenny according to tutorial (from .zip), I am getting the following error :

Could not resolve type with token 01000018 from typeref (expected class 'System.Threading.CancellationToken' in assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')

Also when trying to do it from terminal :

[EDIT]

After Installing dotnet 6 SDK and upgrade unity to 2021.3.15f i was able to dotnet Jenny/Jenny.Generator.Cli.dll Then dotnet Jenny/Jenny.Generator.Cli.dll auto-import -s

But When im using dotnet Jenny/Jenny.Generator.Cli.dll gen

I got the following error :

Guys-iMac:Sweet-Merge guychriqui$ dotnet Jenny/Jenny.Generator.Cli.dll gen -v
Loading assemblies from /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny
Name:Jenny.Generator.Cli
There are no context policies. load: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/Jenny.Generator.dll
  ➜ Loading: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/Jenny.Generator.dll
Name:Jenny.Generator.Cli
There are no context policies. load: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/DesperateDevs.Extensions.dll
  ➜ Loading: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/DesperateDevs.Extensions.dll
Name:Jenny.Generator.Cli
There are no context policies. load: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/DesperateDevs.Serialization.dll
  ➜ Loading: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/DesperateDevs.Serialization.dll
Name:Jenny.Generator.Cli
There are no context policies. load: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/Jenny.Generator.Cli.dll
  ➜ Loading: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/Jenny.Generator.Cli.dll
Name:Jenny.Generator.Cli
There are no context policies. load: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/DesperateDevs.Serialization.Cli.Utils.dll
  ➜ Loading: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/DesperateDevs.Serialization.Cli.Utils.dll
Name:Jenny.Generator.Cli
There are no context policies. load: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/Sherlog.Formatters.dll
  ➜ Loading: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/Sherlog.Formatters.dll
Name:Jenny.Generator.Cli
There are no context policies. load: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/TCPeasy.dll
  ➜ Loading: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/TCPeasy.dll
Name:Jenny.Generator.Cli
There are no context policies. load: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/Sherlog.dll
  ➜ Loading: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/Sherlog.dll
Name:Jenny.Generator.Cli
There are no context policies. load: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/DesperateDevs.Cli.Utils.dll
  ➜ Loading: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/DesperateDevs.Cli.Utils.dll
Name:Jenny.Generator.Cli
There are no context policies. load: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/DesperateDevs.Reflection.dll
  ➜ Loading: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/DesperateDevs.Reflection.dll
Name:Jenny.Generator.Cli
There are no context policies. load: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/Jenny.dll
  ➜ Loading: /Users/guychriqui/Documents/GummyTail/GitHub/Sweet-Merge/Jenny/Jenny.dll
Generating using Jenny.properties
Name:Jenny.Generator.Cli
There are no context policies. load: Entitas.CodeGeneration.Plugins
  ➜ Loading: Entitas.CodeGeneration.Plugins
    ➜ Resolved: Jenny/Plugins/Entitas/Entitas.CodeGeneration.Plugins.dll
Name:Jenny.Generator.Cli
There are no context policies. load: Entitas.Roslyn.CodeGeneration.Plugins
  ➜ Loading: Entitas.Roslyn.CodeGeneration.Plugins
    ➜ Resolved: Jenny/Plugins/Entitas/Entitas.Roslyn.CodeGeneration.Plugins.dll
Name:Jenny.Generator.Cli
There are no context policies. load: Entitas.VisualDebugging.CodeGeneration.Plugins
  ➜ Loading: Entitas.VisualDebugging.CodeGeneration.Plugins
    ➜ Resolved: Jenny/Plugins/Entitas/Entitas.VisualDebugging.CodeGeneration.Plugins.dll
Name:Jenny.Generator.Cli
There are no context policies. load: Jenny.Plugins
  ➜ Loading: Jenny.Plugins
    ➜ Resolved: Jenny/Plugins/Jenny/Jenny.Plugins.dll
Name:Jenny.Generator.Cli
There are no context policies. load: Jenny.Plugins.Unity
  ➜ Loading: Jenny.Plugins.Unity
    ➜ Resolved: Jenny/Plugins/Jenny/Jenny.Plugins.Unity.dll
  ➜ Loading dependency: Entitas.CodeGeneration.Attributes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
  ➜ Loading dependency: Entitas.CodeGeneration.Attributes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
  ➜ Loading dependency: Microsoft.CodeAnalysis, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  ➜ Loading dependency: Microsoft.CodeAnalysis, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    ➜ Resolved: Jenny/Plugins/Jenny/Microsoft.CodeAnalysis.dll
  ℹ️  Not adding Microsoft.CodeAnalysis, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 because AssemblyResolver is disposed
  ➜ Loading dependency: Entitas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
  ➜ Loading dependency: Entitas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
**System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'Entitas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

File name: 'Entitas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
   at Entitas.Roslyn.CodeGeneration.Plugins.MemberDataComponentDataProvider..ctor()
   at Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider.getComponentDataProviders()
   at Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider..ctor(INamedTypeSymbol[] types)
   at Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider..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.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.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 DesperateDevs.Cli.Utils.CliProgram.RunCommand(String[] args)**

When trying with editor still same error as in the image

To Reproduce Steps to reproduce the behavior:

  1. Added Jenny for root project folder
  2. Click on 'Auto generate' from Tools->Jenny->Preferences
  3. Click on 'Generate'
  4. See error

Expected behavior Generated folder will appear without error.

Screenshots Screen Shot 2022-12-03 at 15 30 24

Screenshot 2022-12-03 at 21 21 05

Additional context Unity version - 2021.3.15f (SILICON) Entitas Version - Entitas 1.14.1

Jenny.properties :

Jenny.SearchPaths = Jenny/Plugins/Entitas, \
                    Jenny/Plugins/Jenny, \
                    Assets/Entitas
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.Plugins.ReferenceAssemblyPathsPreProcessor
Jenny.DataProviders = Entitas.CodeGeneration.Plugins.ContextDataProvider, \
                      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
Entitas.CodeGeneration.Plugins.Contexts = Game, \
                                          Input, \
                                          Debug
Entitas.CodeGeneration.Plugins.IgnoreNamespaces = true
Jenny.Plugins.TargetDirectory = Assets/Scripts/Entitas
Dethrail commented 1 year ago

Hi @GuyChriqui

Try to use from Jenny.properties and Entitas.properties from https://github.com/sschmid/Match-One

then dotnet Jenny/Jenny.Generator.Cli.dll gen

dubrovskyiOleksii commented 1 year ago

@GuyChriqui Have you found a solution to the problem?

lightjiao commented 1 year ago

I have same problem like this, have you found a solution to the problem?

Unity 2021.3.5f1 Entitas 1.14.1 dotnet 7.0.102

deathcraft commented 1 year ago

I am getting the same error when trying to generate code from Unity, but was able to generate the code from cmd. Make sure that Jenny.properties contains correct folder name pointing to the Entitas Jenny.SearchPaths = Jenny/Plugins/Entitas, Jenny/Plugins/Jenny, Assets/Thirdparty/Entitas I've put all the stuff to the Thirdparty folder, so this is where SearchPath was supposed to point to in my case. Don't know how to resolve the type token error though.

sschmid commented 1 year ago

Hi! With the dotnet 6.0 upgrade that happened in Entitas 1.14.x, you can generate from the terminal but not yet from within Unity, which doesn't yet fully support dotnet 6.

In the meantime generate from the terminal, ideally using jenny server, which will be the fastest way to generate.

Also, starting with Entitas 1.14.x the roslyn code generator are now free and included in the GitHub releases.

From your jenny doctor output I can see you're not yet using them

Available: Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider
Available: Entitas.Roslyn.CodeGeneration.Plugins.EntityIndexDataProvider

The roslyn ones are now default and recommended, replacing the soon to obsolete reflection-based ones

sschmid commented 1 year ago

As suggested above, you will always find the latest sample Jenny.properties in the Match-One repo

https://github.com/sschmid/Match-One/blob/main/Jenny.properties