0
Under Review

Bolt 2.0.0a3 - C# generation - Operation is not valid due to the current state of the object.

TowerCrow 4 months ago • updated by Lazlo Bonin (Lead Developer) 4 months ago 4

I made a simple 2D character controller. Really similar to what the official platformer tutorial has. It works fine in-game even with this error. The error appeared only after I used the new collapse feature to clean up my graph. 

Graph before using collapse/chunking - works good without errors and generates proper C#:

Graph after using collapse/chunking as an embed. Still works in-game when pressing play but C# generation fails with the error pasted below. 



Inside the superunit:

InvalidOperationException: Operation is not valid due to the current state of the object.
Bolt.GraphInputGenerator.GenerateValueOutputExpression (Bolt.FlowMethodGenerationContext context, Bolt.ValueOutput valueOutput) (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Nesting/GraphInputGenerator.cs:107)
Bolt.UnitGeneratorUtility.GenerateSourceExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:242)
Bolt.UnitGeneratorUtility.GenerateExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context, System.Type destinationType, System.Boolean bind) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:287)
Bolt.UnitGeneratorUtility.GenerateExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context, System.Boolean bind) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:282)
Bolt.InvokeMemberGenerator.GenerateArgumentExpression (Bolt.FlowMethodGenerationContext context, System.Reflection.ParameterInfo parameterInfo, System.Int32 index) (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Codebase/InvokeMemberGenerator.cs:186)
Bolt.InvokeMemberGenerator+<>c__DisplayClass6_0.b__0 (System.Reflection.ParameterInfo parameterInfo, System.Int32 index) (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Codebase/InvokeMemberGenerator.cs:134)
System.Linq.Enumerable+d__154`2[TSource,TResult].MoveNext () (at <1b13ba6391c74847bbc3eddc86df7eee>:0)
System.Collections.Generic.List`1[T].InsertRange (System.Int32 index, System.Collections.Generic.IEnumerable`1[T] collection) (at :0)
System.Collections.Generic.List`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] collection) (at :0)
Ludiq.CodeDom.CodeMethodInvokeExpression..ctor (Ludiq.CodeDom.CodeMethodReferenceExpression method, System.Collections.Generic.IEnumerable`1[T] arguments) (at Assets/Ludiq/Ludiq.Core/Editor/CodeDom/Nodes/Expressions/CodeMethodInvokeExpression.cs:18)
Ludiq.CodeDom.CodeFactory.Invoke (Ludiq.CodeDom.CodeMethodReferenceExpression method, System.Collections.Generic.IEnumerable`1[T] arguments) (at Assets/Ludiq/Ludiq.Core/Editor/CodeDom/CodeFactory.cs:24)
Bolt.InvokeMemberGenerator.GenerateInvokeExpression (Bolt.FlowMethodGenerationContext context) (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Codebase/InvokeMemberGenerator.cs:159)
Bolt.InvokeMemberGenerator.GenerateValueOutputExpression (Bolt.FlowMethodGenerationContext context, Bolt.ValueOutput valueOutput) (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Codebase/InvokeMemberGenerator.cs:101)
Bolt.UnitGeneratorUtility.GenerateSourceExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:242)
Bolt.UnitGeneratorUtility.GenerateExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context, System.Type destinationType, System.Boolean bind) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:287)
Bolt.BinaryOperatorUnitGenerator.GenerateValueOutputExpression (Bolt.FlowMethodGenerationContext context, Bolt.ValueOutput valueOutput) (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Codebase/BinaryOperatorUnitGenerator.cs:25)
Bolt.UnitGeneratorUtility.GenerateSourceExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:242)
Bolt.UnitGeneratorUtility.GenerateExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context, System.Type destinationType, System.Boolean bind) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:287)
Bolt.UnitGeneratorUtility.GenerateExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context, System.Boolean bind) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:282)
Bolt.SuperUnitGenerator.GenerateValueOutputExpression (Bolt.FlowMethodGenerationContext context, Bolt.ValueOutput valueOutput) (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Nesting/SuperUnitGenerator.cs:159)
Bolt.UnitGeneratorUtility.GenerateSourceExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:242)
Bolt.UnitGeneratorUtility.GenerateExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context, System.Type destinationType, System.Boolean bind) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:287)
Bolt.UnitGeneratorUtility.GenerateExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context, System.Boolean bind) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:282)
Bolt.SetVariableGenerator+d__1.MoveNext () (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Variables/SetVariableGenerator.cs:17)
Ludiq.GraphGeneratorUtility+d__3`1[TElement].MoveNext () (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphGenerationUtility.cs:39)
Bolt.UnitGeneratorUtility+d__0.MoveNext () (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:41)
System.Collections.Generic.List`1[T]..ctor (System.Collections.Generic.IEnumerable`1[T] collection) (at :0)
System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <1b13ba6391c74847bbc3eddc86df7eee>:0)
Ludiq.GraphMethodGenerationContext`2[TGraphMethodGenerationContext,TGraphMethodGenerationScope].GenerateMethodBody (System.Collections.Generic.IEnumerable`1[T] parameters, System.Func`2[T,TResult] generator) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphMethodGenerationContext.cs:82)
Ludiq.GraphMethodGenerationContext`2[TGraphMethodGenerationContext,TGraphMethodGenerationScope].GenerateMethod (Ludiq.CodeDom.CodeMemberModifiers modifiers, Ludiq.CodeDom.CodeTypeReference returnType, System.String name, System.Collections.Generic.IEnumerable`1[T] parameters, System.Func`2[T,TResult] generator) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphMethodGenerationContext.cs:50)
Bolt.EventUnitGenerator`2+d__25[TUnit,TArgs].MoveNext () (at Assets/Ludiq/Bolt.Flow/Editor/Events/EventUnitGenerator.cs:56)
Ludiq.GraphGeneratorUtility+d__1`1[TElement].MoveNext () (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphGenerationUtility.cs:22)
System.Collections.Generic.List`1[T].InsertRange (System.Int32 index, System.Collections.Generic.IEnumerable`1[T] collection) (at :0)
System.Collections.Generic.List`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] collection) (at :0)
Bolt.FlowGraphGenerator.PopulateGraphScript (Ludiq.GraphClassGenerationContext context) (at Assets/Ludiq/Bolt.Flow/Editor/FlowGraphGenerator.cs:55)
Ludiq.GraphGenerator`1[TGraph].GenerateGraphScript (Ludiq.GraphGenerationSystem generationSystem, System.String namePrefix) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphGenerator.cs:44)
Ludiq.GraphGenerator`1[TGraph].Generate (Ludiq.GraphGenerationSystem generationSystem, System.String namePrefix) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphGenerator.cs:23)
Ludiq.GraphGenerationSystem.GenerateGraph (Ludiq.IGraphParent graphParent) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphGenerationSystem.cs:58)
Ludiq.CodePreviewWindow.Generate () (at Assets/Ludiq/Ludiq.Graphs/Editor/Windows/CodePreviewWindow.cs:405)
UnityEngine.Debug:LogException(Exception)
Ludiq.CodePreviewWindow:OnGUI() (at Assets/Ludiq/Ludiq.Graphs/Editor/Windows/CodePreviewWindow.cs:252)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Bolt Version:
2.0.0a3
Unity Version:
2018.3.0f2
.NET Version:
4.x
Bolt 2

Update - this generates just fine. The issue seems to be with the inline string value on a superunit. 

Got it again in another project. Not sure what causes this because I had 2 nearly empty flow machines in the scene with just Start() in them and maybe a branch node:

InvalidOperationException: Operation is not valid due to the current state of the object.
Bolt.GraphInputGenerator.GenerateValueOutputExpression (Bolt.FlowMethodGenerationContext context, Bolt.ValueOutput valueOutput) (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Nesting/GraphInputGenerator.cs:107)
Bolt.UnitGeneratorUtility.GenerateSourceExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:242)
Bolt.UnitGeneratorUtility.GenerateExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context, System.Type destinationType, System.Boolean bind) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:287)
Bolt.UnitGeneratorUtility.GenerateExpression (Bolt.ValueInput valueInput, Bolt.FlowMethodGenerationContext context, System.Boolean bind) (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:282)
Bolt.InvokeMemberGenerator.GenerateArgumentExpression (Bolt.FlowMethodGenerationContext context, System.Reflection.ParameterInfo parameterInfo, System.Int32 index) (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Codebase/InvokeMemberGenerator.cs:186)
Bolt.InvokeMemberGenerator+<>c__DisplayClass6_0.b__0 (System.Reflection.ParameterInfo parameterInfo, System.Int32 index) (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Codebase/InvokeMemberGenerator.cs:134)
System.Linq.Enumerable+d__154`2[TSource,TResult].MoveNext () (at <1b13ba6391c74847bbc3eddc86df7eee>:0)
System.Collections.Generic.List`1[T].InsertRange (System.Int32 index, System.Collections.Generic.IEnumerable`1[T] collection) (at :0)
System.Collections.Generic.List`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] collection) (at :0)
Ludiq.CodeDom.CodeMethodInvokeExpression..ctor (Ludiq.CodeDom.CodeMethodReferenceExpression method, System.Collections.Generic.IEnumerable`1[T] arguments) (at Assets/Ludiq/Ludiq.Core/Editor/CodeDom/Nodes/Expressions/CodeMethodInvokeExpression.cs:18)
Ludiq.CodeDom.CodeFactory.Invoke (Ludiq.CodeDom.CodeMethodReferenceExpression method, System.Collections.Generic.IEnumerable`1[T] arguments) (at Assets/Ludiq/Ludiq.Core/Editor/CodeDom/CodeFactory.cs:24)
Bolt.InvokeMemberGenerator.GenerateInvokeExpression (Bolt.FlowMethodGenerationContext context) (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Codebase/InvokeMemberGenerator.cs:159)
Bolt.InvokeMemberGenerator+d__1.MoveNext () (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Codebase/InvokeMemberGenerator.cs:25)
Ludiq.GraphGeneratorUtility+d__3`1[TElement].MoveNext () (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphGenerationUtility.cs:39)
Bolt.UnitGeneratorUtility+d__0.MoveNext () (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:41)
Bolt.SuperUnitGenerator+d__8.MoveNext () (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Nesting/SuperUnitGenerator.cs:101)
Bolt.UnitGeneratorUtility+d__0.MoveNext () (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:48)
Bolt.UnitGeneratorUtility+d__1.MoveNext () (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:59)
System.Collections.Generic.List`1[T].InsertRange (System.Int32 index, System.Collections.Generic.IEnumerable`1[T] collection) (at :0)
System.Collections.Generic.List`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] collection) (at :0)
Ludiq.CodeDom.CodeWhileStatement..ctor (Ludiq.CodeDom.CodeExpression condition, System.Collections.Generic.IEnumerable`1[T] statements) (at Assets/Ludiq/Ludiq.Core/Editor/CodeDom/Nodes/Statements/CodeWhileStatement.cs:11)
Bolt.WhileGenerator+d__1.MoveNext () (at Assets/Ludiq/Bolt.Flow/Editor/Framework/Control/WhileGenerator.cs:22)
Ludiq.GraphGeneratorUtility+d__3`1[TElement].MoveNext () (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphGenerationUtility.cs:39)
Bolt.UnitGeneratorUtility+d__0.MoveNext () (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:41)
Bolt.UnitGeneratorUtility+d__0.MoveNext () (at Assets/Ludiq/Bolt.Flow/Editor/Units/UnitGeneratorUtility.cs:48)
System.Collections.Generic.List`1[T]..ctor (System.Collections.Generic.IEnumerable`1[T] collection) (at :0)
System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <1b13ba6391c74847bbc3eddc86df7eee>:0)
Ludiq.GraphMethodGenerationContext`2[TGraphMethodGenerationContext,TGraphMethodGenerationScope].GenerateMethodBody (System.Collections.Generic.IEnumerable`1[T] parameters, System.Func`2[T,TResult] generator) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphMethodGenerationContext.cs:82)
Ludiq.GraphMethodGenerationContext`2[TGraphMethodGenerationContext,TGraphMethodGenerationScope].GenerateMethod (Ludiq.CodeDom.CodeMemberModifiers modifiers, Ludiq.CodeDom.CodeTypeReference returnType, System.String name, System.Collections.Generic.IEnumerable`1[T] parameters, System.Func`2[T,TResult] generator) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphMethodGenerationContext.cs:50)
Bolt.EventUnitGenerator`2+d__25[TUnit,TArgs].MoveNext () (at Assets/Ludiq/Bolt.Flow/Editor/Events/EventUnitGenerator.cs:56)
Ludiq.GraphGeneratorUtility+d__1`1[TElement].MoveNext () (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphGenerationUtility.cs:22)
System.Collections.Generic.List`1[T].InsertRange (System.Int32 index, System.Collections.Generic.IEnumerable`1[T] collection) (at :0)
System.Collections.Generic.List`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] collection) (at :0)
Bolt.FlowGraphGenerator.PopulateGraphScript (Ludiq.GraphClassGenerationContext context) (at Assets/Ludiq/Bolt.Flow/Editor/FlowGraphGenerator.cs:55)
Ludiq.GraphGenerator`1[TGraph].GenerateGraphScript (Ludiq.GraphGenerationSystem generationSystem, System.String namePrefix) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphGenerator.cs:44)
Ludiq.GraphGenerator`1[TGraph].Generate (Ludiq.GraphGenerationSystem generationSystem, System.String namePrefix) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphGenerator.cs:23)
Ludiq.GraphGenerationSystem.GenerateGraph (Ludiq.IGraphParent graphParent) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/GraphGenerationSystem.cs:58)
Ludiq.Generation.Generate (Ludiq.GraphGenerationSystem system, Ludiq.IGraphRoot root, System.Nullable`1[T] scene) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/Generation.cs:121)
Ludiq.Generation+<>c__DisplayClass0_1.b__2 (Ludiq.Task assetsGeneration) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/Generation.cs:40)
Ludiq.Task.Run () (at Assets/Ludiq/Ludiq.Core/Editor/Tasks/Task.cs:68)
Ludiq.WindowTaskRunner.RunSynchronous (Ludiq.Task task) (at Assets/Ludiq/Ludiq.Core/Editor/Tasks/Runners/WindowTaskRunner.cs:61)
UnityEngine.Debug:LogException(Exception)
Ludiq.WindowTaskRunner:RunSynchronous(Task) (at Assets/Ludiq/Ludiq.Core/Editor/Tasks/Runners/WindowTaskRunner.cs:67)
Ludiq.WindowTaskRunner:Run(Task) (at Assets/Ludiq/Ludiq.Core/Editor/Tasks/Runners/WindowTaskRunner.cs:44)
Ludiq.Task:Run(String, Int32, Action`1) (at Assets/Ludiq/Ludiq.Core/Editor/Tasks/Task.cs:197)
Ludiq.<>c__DisplayClass0_0:b__0(Task) (at Assets/Ludiq/Ludiq.Graphs/Editor/Generation/Generation.cs:35)
Ludiq.Task:Run() (at Assets/Ludiq/Ludiq.Core/Editor/Tasks/Task.cs:68)
Ludiq.WindowTaskRunner:RunSynchronous(Task) (at Assets/Ludiq/Ludiq.Core/Editor/Tasks/Runners/WindowTaskRunner.cs:61)
Ludiq.<>c__DisplayClass10_0:b__0() (at Assets/Ludiq/Ludiq.Core/Editor/Tasks/Runners/WindowTaskRunner.cs:33)
System.Threading.ThreadHelper:ThreadStart()

Got it too.  It appears to be having a port with a default value (string), and then NOT filling the port with a string literal.

Problem:



Not a problem:



Here's the dupe paste:

bolt problem.txt

Under Review

Thanks for the report, I'll forward this to Andy!