From db36f0e22672729b74a6e1ac8303cf0631d0095c Mon Sep 17 00:00:00 2001 From: michael kirschner Date: Fri, 27 Mar 2020 17:41:40 -0400 Subject: [PATCH 1/4] check if this works - it does --- src/Engine/ProtoScript/Runners/LiveRunner.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Engine/ProtoScript/Runners/LiveRunner.cs b/src/Engine/ProtoScript/Runners/LiveRunner.cs index fa99b67567e..50f01be38d5 100644 --- a/src/Engine/ProtoScript/Runners/LiveRunner.cs +++ b/src/Engine/ProtoScript/Runners/LiveRunner.cs @@ -959,6 +959,17 @@ private bool CompileToSSA(Guid guid, List astList, out List /// Creates a list of null assignment statements where the lhs is retrieved from an ast list /// @@ -982,7 +993,7 @@ private List BuildNullAssignments(List as } IdentifierNode leftNode = bNode.LeftNode as IdentifierNode; - if (leftNode == null || leftNode.ArrayDimensions != null) + if (leftNode == null || leftNode.ArrayDimensions != null || IsLogicalOP(bNode.Optr)) { continue; } From c7d133f80d2519d1d73f1640405144eb4a456658 Mon Sep 17 00:00:00 2001 From: mjkkirschner Date: Wed, 1 Apr 2020 17:57:57 -0400 Subject: [PATCH 2/4] add micro test ignore all expressions which are not assigments in the nullifyBinaryExpression code --- src/Engine/ProtoScript/Runners/LiveRunner.cs | 16 +--- .../LiveRunnerTests/MicroFeatureTests.cs | 87 +++++++++++++++++++ 2 files changed, 90 insertions(+), 13 deletions(-) diff --git a/src/Engine/ProtoScript/Runners/LiveRunner.cs b/src/Engine/ProtoScript/Runners/LiveRunner.cs index 50f01be38d5..3eea0563f7a 100644 --- a/src/Engine/ProtoScript/Runners/LiveRunner.cs +++ b/src/Engine/ProtoScript/Runners/LiveRunner.cs @@ -959,19 +959,9 @@ private bool CompileToSSA(Guid guid, List astList, out List - /// Creates a list of null assignment statements where the lhs is retrieved from an ast list + /// Creates a list of null assignment statements where the lhs is retrieved from an ast list. + /// Any expressions which are not assignments are not modified. /// /// /// @@ -993,7 +983,7 @@ private List BuildNullAssignments(List as } IdentifierNode leftNode = bNode.LeftNode as IdentifierNode; - if (leftNode == null || leftNode.ArrayDimensions != null || IsLogicalOP(bNode.Optr)) + if (leftNode == null || leftNode.ArrayDimensions != null || bNode.Optr != Operator.assign) { continue; } diff --git a/test/Engine/ProtoTest/LiveRunnerTests/MicroFeatureTests.cs b/test/Engine/ProtoTest/LiveRunnerTests/MicroFeatureTests.cs index df9f1a52279..09c51206570 100644 --- a/test/Engine/ProtoTest/LiveRunnerTests/MicroFeatureTests.cs +++ b/test/Engine/ProtoTest/LiveRunnerTests/MicroFeatureTests.cs @@ -852,6 +852,93 @@ public void GraphILTest_DeletedNode01() } + [Test] + public void GraphILTest_DeletedBinaryExpresionDoesNotEffectReferences() + { + //==================================== + // Create a = true; + // b = true; + // c = a & b; + // d = a & b; + // Execute and verify a = true + // b= true + // c = true + // d = true + // Delete c = a&b + // + // Execute and verify d = true; + //==================================== + + // Create a = true; + // b = true; + // c = a & b; + // d = a & b; + BinaryExpressionNode assign1 = new BinaryExpressionNode( + new IdentifierNode("a"), + new BooleanNode(true), + Operator.assign); + + BinaryExpressionNode assign2 = new BinaryExpressionNode( + new IdentifierNode("b"), + new BooleanNode(true), + Operator.assign); + + BinaryExpressionNode assign3 = new BinaryExpressionNode( + new IdentifierNode("c"), + new BinaryExpressionNode(new IdentifierNode("a"), new IdentifierNode("b") + , Operator.and) + ,Operator.assign); + + BinaryExpressionNode assign4 = new BinaryExpressionNode( + new IdentifierNode("d"), + new BinaryExpressionNode(new IdentifierNode("a"), new IdentifierNode("b") + , Operator.and) + ,Operator.assign); + + List astList = new List() {assign1,assign2,assign3,assign4}; + + + + Guid guid = System.Guid.NewGuid(); + + + // Instantiate GraphSyncData + List addedList = new List(); + addedList.Add(new Subtree(astList,guid)); + + GraphSyncData syncData = new GraphSyncData(null, addedList, null); + + // emit the DS code from the AST tree + liveRunner = new ProtoScript.Runners.LiveRunner(); + liveRunner.UpdateGraph(syncData); + + // Execute and verify c = true + // Execute and verify d = true + RuntimeMirror mirrorc = liveRunner.InspectNodeValue("c"); + Assert.IsTrue((bool)mirrorc.GetData().Data == true); + RuntimeMirror mirrord = liveRunner.InspectNodeValue("d"); + Assert.IsTrue((bool)mirrord.GetData().Data == true); + + + + // Delete c = a&b + var deleteGuid = Guid.NewGuid(); + var deletedsb = new Subtree(new List { assign3 }, deleteGuid); + List deletedList = new List(); + deletedList.Add(deletedsb); + syncData = new GraphSyncData(deletedList, null, null); + liveRunner.UpdateGraph(syncData); + + // Execute and verify c = true + // Execute and verify d = true + RuntimeMirror mirrorc2 = liveRunner.InspectNodeValue("c"); + Assert.IsTrue(mirrorc2.GetData().Data == null); + RuntimeMirror mirrord2 = liveRunner.InspectNodeValue("d"); + Assert.IsTrue((bool)mirrord2.GetData().Data == true); + + + } + private void AssertValue(string varname, object value) { var mirror = liveRunner.InspectNodeValue(varname); From 3609a614640b7960161dbebe676e7e0e7ffdd0fd Mon Sep 17 00:00:00 2001 From: mjkkirschner Date: Wed, 1 Apr 2020 18:33:58 -0400 Subject: [PATCH 3/4] add new dynamo model test --- test/DynamoCoreTests/DSEvaluationModelTest.cs | 20 ++ test/core/dsevaluation/testuilogicnodes.dyn | 203 ++++++++++++++++++ 2 files changed, 223 insertions(+) create mode 100644 test/core/dsevaluation/testuilogicnodes.dyn diff --git a/test/DynamoCoreTests/DSEvaluationModelTest.cs b/test/DynamoCoreTests/DSEvaluationModelTest.cs index e468e3498ea..3a1080d961c 100644 --- a/test/DynamoCoreTests/DSEvaluationModelTest.cs +++ b/test/DynamoCoreTests/DSEvaluationModelTest.cs @@ -1373,6 +1373,26 @@ public void Regression_Magn_10015() RunModel(dynFilePath); AssertPreviewValue("deb457c6-1b4b-4703-9476-db312b34a8e2", new object[] { null, null, null, null }); } + + [Test] + public void LogicUINodesDeleted() + { + RunModel(@"core\dsevaluation\testuilogicnodes.dyn"); + this.CurrentDynamoModel.CurrentWorkspace.RequestRun(); + var codeblock = this.CurrentDynamoModel.CurrentWorkspace.Nodes.Where(x => x.Name == "Code Block").First(); + var uiANDnode = this.CurrentDynamoModel.CurrentWorkspace.Nodes.Where(x => x.Name == "And").First(); + var ztANDnode = this.CurrentDynamoModel.CurrentWorkspace.Nodes.Where(x => x.Name == "&&").First(); + AssertPreviewValue(ztANDnode.GUID.ToString(), true); + + + //delete binary expression AND node + this.CurrentDynamoModel.CurrentWorkspace.RemoveAndDisposeNode(uiANDnode); + this.CurrentDynamoModel.CurrentWorkspace.RequestRun(); + + //assert other node value is still valid + AssertPreviewValue(ztANDnode.GUID.ToString(), true); + AssertPreviewValue(codeblock.GUID.ToString(), true); + } } [Category("GithubIssues")] diff --git a/test/core/dsevaluation/testuilogicnodes.dyn b/test/core/dsevaluation/testuilogicnodes.dyn new file mode 100644 index 00000000000..ec915bfa86d --- /dev/null +++ b/test/core/dsevaluation/testuilogicnodes.dyn @@ -0,0 +1,203 @@ +{ + "Uuid": "f92363c3-5707-41ec-8a63-06acf36b45ae", + "IsCustomNode": false, + "Description": null, + "Name": "testuilogicnodes", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "true;\ntrue;", + "Id": "85bc989a337a45f1b5848734338ae673", + "Inputs": [], + "Outputs": [ + { + "Id": "5683b294f10446c8b5839420e34dab9c", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "30a412eb4e714626a97c37a8a69d19ed", + "Name": "", + "Description": "Value of expression at line 2", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows for DesignScript code to be authored directly" + }, + { + "ConcreteType": "CoreNodeModels.Logic.And, CoreNodeModels", + "VariableInputPorts": true, + "NodeType": "ExtensionNode", + "Id": "d6fcc6b732b44a8b90a2ad58876ac009", + "Inputs": [ + { + "Id": "7fb42091df0d4b8abe4c5ccdf6fe435f", + "Name": "bool0", + "Description": "operand", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "44d8b83a99ef4b4094e09613b4e635c7", + "Name": "bool1", + "Description": "operand", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "51e23dadf91f4cd2ba97fa4b953a9b7e", + "Name": "", + "Description": "result", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Boolean AND: Returns true only if both of the inputs are true. If either is false, returns false." + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "NodeType": "FunctionNode", + "FunctionSignature": "&&@var[]..[],var[]..[]", + "Id": "f206cdb1d1be467fbffdfb7138d14162", + "Inputs": [ + { + "Id": "31bf8f9d6a0a4be7a15a5b2955ce181a", + "Name": "x", + "Description": "x value.\n\nvar[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "8b45739b667749cb8bba69cab5fc985f", + "Name": "y", + "Description": "y value.\n\nvar[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "a767c3b1a709403c881f6c9bedaf3c2d", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "x and y?\n\n&& (x: var[]..[], y: var[]..[]): var[]..[]" + } + ], + "Connectors": [ + { + "Start": "5683b294f10446c8b5839420e34dab9c", + "End": "7fb42091df0d4b8abe4c5ccdf6fe435f", + "Id": "08f517ed5b874462b5715116b8dd7acf" + }, + { + "Start": "5683b294f10446c8b5839420e34dab9c", + "End": "31bf8f9d6a0a4be7a15a5b2955ce181a", + "Id": "cfe744626fde4fdf81926898e7b5269d" + }, + { + "Start": "30a412eb4e714626a97c37a8a69d19ed", + "End": "8b45739b667749cb8bba69cab5fc985f", + "Id": "25fe7c834a644402a87135db0681882d" + }, + { + "Start": "30a412eb4e714626a97c37a8a69d19ed", + "End": "44d8b83a99ef4b4094e09613b4e635c7", + "Id": "5ccd3af80efd4a5e960dcd0166bd7ebf" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "2.7.0.8216", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "NodeViews": [ + { + "ShowGeometry": true, + "Name": "Code Block", + "Id": "85bc989a337a45f1b5848734338ae673", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 235.0, + "Y": 265.0 + }, + { + "ShowGeometry": true, + "Name": "And", + "Id": "d6fcc6b732b44a8b90a2ad58876ac009", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 505.5, + "Y": 233.0 + }, + { + "ShowGeometry": true, + "Name": "&&", + "Id": "f206cdb1d1be467fbffdfb7138d14162", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 506.5, + "Y": 365.0 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file From 57884d13fda233c6ff15da686f9455f288ac0194 Mon Sep 17 00:00:00 2001 From: mjkkirschner Date: Thu, 2 Apr 2020 14:01:40 -0400 Subject: [PATCH 4/4] review comment --- src/Engine/ProtoScript/Runners/LiveRunner.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Engine/ProtoScript/Runners/LiveRunner.cs b/src/Engine/ProtoScript/Runners/LiveRunner.cs index 3eea0563f7a..6386b36e92d 100644 --- a/src/Engine/ProtoScript/Runners/LiveRunner.cs +++ b/src/Engine/ProtoScript/Runners/LiveRunner.cs @@ -977,13 +977,13 @@ private List BuildNullAssignments(List as while (workingStack.Any()) { var bNode = workingStack.Pop() as BinaryExpressionNode; - if (bNode == null) + if (bNode == null || bNode.Optr != Operator.assign) { continue; } IdentifierNode leftNode = bNode.LeftNode as IdentifierNode; - if (leftNode == null || leftNode.ArrayDimensions != null || bNode.Optr != Operator.assign) + if (leftNode == null || leftNode.ArrayDimensions != null) { continue; }