sschmid / Entitas

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

Could not resolve type with token ... expected class System.Threading.CancellationToken #1072

Closed Atlinx closed 1 year ago

Atlinx commented 1 year ago

Hey all, I'm using Unity 2022.3.4f1 and I'm getting the following error when I run generate through the Jenny window in the editor. I'm using the 1.14.1 version of Entitas, and I following the installation steps mentioned in this issue https://github.com/sschmid/Entitas/issues/1055.

image

What's causing this error?

sschmid commented 1 year ago

@Atlinx have a look at https://github.com/sschmid/Entitas/issues/1050

make sure you have dotnet 6.0 installed

https://dotnet.microsoft.com/en-us/download

Atlinx commented 1 year ago

I have dotnet 6 installed and the result is unfortunately still the same. Do I need to delete dotnet 7.0? I'm using a global.json file in the root of the repository which should in theory make all dotnet calls within the project use 6.0.

sschmid commented 1 year ago

Ok, all should work, if you have dotnet 6 and a similar Jenny.properties to Match-One. Please compare your Jenny.properties, it looks like you're using plugins that only work in Unity, like the old reflection-based plugins, same as described #1050

sschmid commented 1 year ago

You can share your Jenny.properties and I can have a look

Atlinx commented 1 year ago

Here's my Jenny.properties for the Match-One repository I cloned locally:

Jenny.SearchPaths = Assets/Entitas, \
                    Assets\Jenny\Editor\Jenny, \
                    Jenny/Plugins/Entitas, \
                    Jenny/Plugins/Jenny, \
                    Jenny\Plugins\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.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, \
                                          Input, \
                                          GameState, \
                                          Config
Entitas.CodeGeneration.Plugins.IgnoreNamespaces = false
Jenny.Plugins.ProjectPath = Assembly-CSharp.csproj
Jenny.Plugins.TargetDirectory = Assets
Entitas.CodeGeneration.Plugins.Assemblies = Library/ScriptAssemblies/Assembly-CSharp.dll

I'm also running this in Windows 11 if that makes a difference.

sschmid commented 1 year ago

There are differences in the Jenny.properties compared to the one from Match-One. Same issue as #1050

I recommend using the one from Match-One as a starting point.

E.g. your Jenny.properties contains old and obsolete Entitas.CodeGeneration.Plugins.ComponentDataProvider (and others)

Use the one from Match-One and all should be fine

sschmid commented 1 year ago

Explanation: The old non-roslyn data providers like Entitas.CodeGeneration.Plugins.ComponentDataProvider and Entitas.CodeGeneration.Plugins.EntityIndexDataProvider have been replaced with the roslyn ones.

They used to be part of the paid Unity Asset store version, but for a while now thats all free and included in the GitHub version, too.

More about this here

Atlinx commented 1 year ago

Ah, overwriting my Jenny.properties with the new Match-One Jenny.properties fixed it! :D I think the reason why my properties file looks like this is because I pressed auto import in the Jenny window at some point, and I never thought about resetting the properties file to test again with dotnet 6.0.

I'm able to get the generation to run through the CLI command but the editor window is still broken, unfortunately.

sschmid commented 1 year ago

The new roslyn data providers are "too new" to run in Unity, that's why for now ti will only run in the terminal. I think that's fine, because using jenny server is also the fastest way to gerate and the recommended way. Since your Jenny.properties files contained the old data providers they probably had to load Unity related assemblies (because of reflection). This can work in the terminal, but is not recommended because it basically needs to load Unity. So I will skip instructions to make it work the old way and save you some time ;)

sschmid commented 1 year ago

Fyi, I'm working on replacing Jenny altogether and use c# source generators instead. This will simplify the setup and there won't be any Jenny.properties anymore that causes confusion.

See #1005

Stay tuned!