Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyNotFoundException while trying to generate with Rosyln #536

Closed
jwvanderbeck opened this issue Jan 2, 2018 · 5 comments
Closed

KeyNotFoundException while trying to generate with Rosyln #536

jwvanderbeck opened this issue Jan 2, 2018 · 5 comments

Comments

@jwvanderbeck
Copy link

jwvanderbeck commented Jan 2, 2018

"D:\Unity Projects\seti\CodeGenerator\Jenny.exe" -v gen
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at DesperateDevs.Serialization.Properties.get_Item(String key)
   at DesperateDevs.CodeGeneration.CodeGenerator.CodeGeneratorConfig.get_searchPaths()
   at DesperateDevs.CodeGeneration.CodeGenerator.CodeGeneratorUtil.LoadTypesFromPlugins(Preferences preferences)
   at DesperateDevs.CodeGeneration.CodeGenerator.CodeGeneratorUtil.CodeGeneratorFromPreferences(Preferences preferences)
   at DesperateDevs.CodeGeneration.CodeGenerator.CLI.Generate.run()
   at DesperateDevs.CodeGeneration.CodeGenerator.CLI.AbstractPreferencesCommand.Run(String[] args)
   at DesperateDevs.CLI.CLIProgram.runCommand(String[] args)

This just started happening today and I have no idea why, and without the code to be able to try and track it down I am really kind of stuck :( It was working just fine yesterday.

I really wish you would reconsider making the source code available for Asset Store owners. Many other paid assets do that and I tend to personally favor those as it makes it a lot easier to deal with problems without having to be held up while waiting on support.

@jwvanderbeck
Copy link
Author

jwvanderbeck commented Jan 2, 2018

Even though it was working fine before this, I ran jenny fix and it.. was acted rather weird as it seemed to add a bunch of keys and them proceed to claim they were unused and offer to remove them.

PS D:\Unity Projects\seti> .\CodeGenerator\Jenny.exe fix
??  Will add missing key: 'CodeGenerator.SearchPaths' (press any key)
Added: CodeGenerator.SearchPaths
??  Will add missing key: 'CodeGenerator.Plugins' (press any key)
Added: CodeGenerator.Plugins
??  Will add missing key: 'CodeGenerator.PreProcessors' (press any key)
Added: CodeGenerator.PreProcessors
??  Will add missing key: 'CodeGenerator.DataProviders' (press any key)
Added: CodeGenerator.DataProviders
??  Will add missing key: 'CodeGenerator.CodeGenerators' (press any key)
Added: CodeGenerator.CodeGenerators
??  Will add missing key: 'CodeGenerator.PostProcessors' (press any key)
Added: CodeGenerator.PostProcessors
??  Will add missing key: 'CodeGenerator.Server.Port' (press any key)
Added: CodeGenerator.Server.Port
??  Will add missing key: 'CodeGenerator.Client.Host' (press any key)
Added: CodeGenerator.Client.Host
??  Will add missing key: 'CodeGenerator.CLI.Ignore.UnusedKeys' (press any key)
Added: CodeGenerator.CLI.Ignore.UnusedKeys
?  Remove unused key: 'Entitas.CodeGeneration.CodeGenerator.SearchPaths' ? (y / n / (i)gnore)
Removed: Entitas.CodeGeneration.CodeGenerator.SearchPaths
?  Remove unused key: 'Entitas.CodeGeneration.CodeGenerator.Plugins' ? (y / n / (i)gnore)
Removed: Entitas.CodeGeneration.CodeGenerator.Plugins
?  Remove unused key: 'Entitas.CodeGeneration.CodeGenerator.DataProviders' ? (y / n / (i)gnore)
Removed: Entitas.CodeGeneration.CodeGenerator.DataProviders
?  Remove unused key: 'Entitas.CodeGeneration.CodeGenerator.CodeGenerators' ? (y / n / (i)gnore)
Removed: Entitas.CodeGeneration.CodeGenerator.CodeGenerators
?  Remove unused key: 'Entitas.CodeGeneration.CodeGenerator.PostProcessors' ? (y / n / (i)gnore)
Removed: Entitas.CodeGeneration.CodeGenerator.PostProcessors
?  Remove unused key: 'Entitas.VisualDebugging.Unity.Editor.SystemWarningThreshold' ? (y / n / (i)gnore)
Removed: Entitas.VisualDebugging.Unity.Editor.SystemWarningThreshold
?  Remove unused key: 'Entitas.VisualDebugging.Unity.Editor.DefaultInstanceCreatorFolderPath' ? (y / n / (i)gnore)
Removed: Entitas.VisualDebugging.Unity.Editor.DefaultInstanceCreatorFolderPath
?  Remove unused key: 'Entitas.VisualDebugging.Unity.Editor.TypeDrawerFolderPath' ? (y / n / (i)gnore)
Removed: Entitas.VisualDebugging.Unity.Editor.TypeDrawerFolderPath
?  Remove unused key: 'Entitas.CodeGeneration.Plugins.Assemblies' ? (y / n / (i)gnore)
Removed: Entitas.CodeGeneration.Plugins.Assemblies
?  Remove unused key: 'Entitas.CodeGeneration.Plugins.Contexts' ? (y / n / (i)gnore)
Removed: Entitas.CodeGeneration.Plugins.Contexts
?  Remove unused key: 'Entitas.CodeGeneration.Plugins.IgnoreNamespaces' ? (y / n / (i)gnore)
Removed: Entitas.CodeGeneration.Plugins.IgnoreNamespaces
?  Remove unused key: 'Entitas.CodeGeneration.Plugins.TargetDirectory' ? (y / n / (i)gnore)
Removed: Entitas.CodeGeneration.Plugins.TargetDirectory
?  Remove unused key: 'Entitas.CodeGeneration.Plugins.ProjectPath' ? (y / n / (i)gnore)
Removed: Entitas.CodeGeneration.Plugins.ProjectPath
?  Remove unused key: 'Entitas.CodeGeneration.CodeGenerator.CLI.Ignore.UnusedKeys' ? (y / n / (i)gnore)
Removed: Entitas.CodeGeneration.CodeGenerator.CLI.Ignore.UnusedKeys
PS D:\Unity Projects\seti>

Then I ran jenny gen again and I get no errors, but it also doesn't actually generate anything. The generated code doesn't change.

PS D:\Unity Projects\seti> .\CodeGenerator\Jenny.exe gen
PS D:\Unity Projects\seti>

@jwvanderbeck
Copy link
Author

I suspect that jenny fix actually broke my properties file. I'm going to try deleting it and starting from scratch (not fun) but for posterity this is what it current looks like:

Preferences.Entitas = Entitas.Unity.Editor.EntitasPreferencesDrawer, \
                      DesperateDevs.CodeGeneration.CodeGenerator.Unity.Editor.CodeGeneratorPreferencesDrawer, \
                      Entitas.VisualDebugging.Unity.Editor.VisualDebuggingPreferencesDrawer

CodeGenerator.SearchPaths = CodeGenerator/Plugins, \
                            Assets\Entitas\Editor, \
                            CodeGenerator\Plugins\Entitas, \
                            CodeGenerator\Plugins\Entitas.Roslyn, \
                            CodeGenerator\Plugins\Jenny

CodeGenerator.Plugins = Entitas.CodeGeneration.Plugins, \
                        Entitas.VisualDebugging.CodeGeneration.Plugins, \
                        DesperateDevs.CodeGeneration.Plugins, \
                        Entitas.Roslyn.CodeGeneration.Plugins, \
                        DesperateDevs.CodeGeneration.Unity.Plugins

CodeGenerator.PreProcessors = DesperateDevs.CodeGeneration.Plugins.TargetFrameworkProfilePreProcessor
CodeGenerator.DataProviders = Entitas.CodeGeneration.Plugins.ContextDataProvider, \
                              Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider, \
                              Entitas.Roslyn.CodeGeneration.Plugins.EntityIndexDataProvider

CodeGenerator.CodeGenerators = Entitas.CodeGeneration.Plugins.ComponentContextGenerator, \
                               Entitas.CodeGeneration.Plugins.ComponentEntityGenerator, \
                               Entitas.CodeGeneration.Plugins.ComponentEntityInterfaceGenerator, \
                               Entitas.CodeGeneration.Plugins.ComponentGenerator, \
                               Entitas.CodeGeneration.Plugins.ComponentMatcherGenerator, \
                               Entitas.CodeGeneration.Plugins.ComponentsLookupGenerator, \
                               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.VisualDebugging.CodeGeneration.Plugins.ContextObserverGenerator, \
                               Entitas.VisualDebugging.CodeGeneration.Plugins.FeatureClassGenerator

CodeGenerator.PostProcessors = DesperateDevs.CodeGeneration.Plugins.AddFileHeaderPostProcessor, \
                               DesperateDevs.CodeGeneration.Plugins.CleanTargetDirectoryPostProcessor, \
                               DesperateDevs.CodeGeneration.Plugins.MergeFilesPostProcessor, \
                               DesperateDevs.CodeGeneration.Plugins.NewLinePostProcessor, \
                               DesperateDevs.CodeGeneration.Plugins.UpdateCSProjPostProcessor, \
                               DesperateDevs.CodeGeneration.Plugins.WriteToDiskPostProcessor, \
                               DesperateDevs.CodeGeneration.Plugins.ConsoleWriteLinePostProcessor

CodeGenerator.Server.Port = 3333
CodeGenerator.Client.Host = localhost
Entitas.VisualDebugging.Unity.Editor.SystemWarningThreshold = 5
Entitas.VisualDebugging.Unity.Editor.DefaultInstanceCreatorFolderPath = Assets/Editor/DefaultInstanceCreator
Entitas.VisualDebugging.Unity.Editor.TypeDrawerFolderPath = Assets/Editor/TypeDrawer
DesperateDevs.CodeGeneration.Plugins.ProjectPath = Assembly-CSharp.csproj
Entitas.CodeGeneration.Plugins.Assemblies = Library/ScriptAssemblies/Assembly-CSharp.dll
Entitas.CodeGeneration.Plugins.Contexts = Game, \
                                          Input

Entitas.CodeGeneration.Plugins.IgnoreNamespaces = false
DesperateDevs.CodeGeneration.Plugins.TargetDirectory = Assets/Source/Entitas
CodeGenerator.CLI.Ignore.UnusedKeys = Preferences.Entitas, \
                                      Entitas.VisualDebugging.Unity.Editor.SystemWarningThreshold, \
                                      Entitas.VisualDebugging.Unity.Editor.DefaultInstanceCreatorFolderPath, \
                                      Entitas.VisualDebugging.Unity.Editor.TypeDrawerFolderPath

@jwvanderbeck
Copy link
Author

Ok fixed the issue.

Turns out my NAS sync setup had erroneously copied over an old preferences file, but the thing is that file had a completely different name from the default so I am unsure why Jenny decided to start using it instead of the default one all of a sudden? When I deleted that errant file things started working again. The sync runs nightly which is why it was working yesterday.

I'm confused why Jenny started using this other file though without being told to do so. Does it just use the first .properties file that it finds rather than by filename?

@sschmid
Copy link
Owner

sschmid commented Jan 3, 2018

Explanation:
Jenny tries to find a properties file automatically if you don't specify one along with a command. If you specify a properties file with a command it will be used, e.g.

$ jenny gen MyPreferences.properties

If there are multiple properties files found, jenny uses the first one found. Coincidentally I was already working a feature last week that will tell if it found more files and which one it is using. I added this to the Unity preferences and to jenny. Will be in the next release. Sorry for the confusion.

@sschmid
Copy link
Owner

sschmid commented Jan 10, 2018

Hi, fixed in Entitas 0.47.0

@sschmid sschmid closed this as completed Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants