From 72d31ddb6a4f95aed1c69703659b4a42ec902209 Mon Sep 17 00:00:00 2001 From: aparajit-pratap Date: Fri, 18 Dec 2020 12:33:20 -0500 Subject: [PATCH 1/3] return original node for single Identifier AST --- src/DynamoCore/Engine/ShortestQualifiedNameReplacer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DynamoCore/Engine/ShortestQualifiedNameReplacer.cs b/src/DynamoCore/Engine/ShortestQualifiedNameReplacer.cs index 1a0f1b9be43..ab062e2e6bc 100644 --- a/src/DynamoCore/Engine/ShortestQualifiedNameReplacer.cs +++ b/src/DynamoCore/Engine/ShortestQualifiedNameReplacer.cs @@ -106,7 +106,7 @@ public override AssociativeNode VisitIdentifierNode(IdentifierNode node) // return IdentifierNode if identifier string is not separated by '.' if (strIdentList.Length == 1) { - return new IdentifierNode(strIdentList[0]); + return node; } // create IdentifierListNode from string such that From 91fb224ab2cb92b8c60e8a4b5c315b2e7f1c5f90 Mon Sep 17 00:00:00 2001 From: aparajit-pratap Date: Fri, 18 Dec 2020 13:08:45 -0500 Subject: [PATCH 2/3] add unit test --- test/DynamoCoreTests/NodeToCodeTest.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/DynamoCoreTests/NodeToCodeTest.cs b/test/DynamoCoreTests/NodeToCodeTest.cs index ee75958b780..9d6f39855c5 100644 --- a/test/DynamoCoreTests/NodeToCodeTest.cs +++ b/test/DynamoCoreTests/NodeToCodeTest.cs @@ -1398,6 +1398,24 @@ public void TestNodeWithVarArgument() AssertPreviewValue(guid, new[] { "foo", "bar", "qux" }); } + [Test] + public void TestNodeToCodeWithBuiltInAddMethod() + { + OpenModel(@"core\node2code\builtinAddNode.dyn"); + var nodes = CurrentDynamoModel.CurrentWorkspace.Nodes; + SelectAll(nodes); + + var command = new DynamoModel.ConvertNodesToCodeCommand(); + CurrentDynamoModel.ExecuteCommand(command); + CurrentDynamoModel.ForceRun(); + + var cbn = CurrentDynamoModel.CurrentWorkspace.Nodes.OfType().FirstOrDefault(); + Assert.IsNotNull(cbn); + + var guid = cbn.GUID.ToString(); + AssertPreviewValue(guid, 49); + } + [Test] [Category("RegressionTests")] public void TestMultioutputNode() From 46c7bae5d81634929da226fece86798d9bd520bc Mon Sep 17 00:00:00 2001 From: aparajit-pratap Date: Fri, 18 Dec 2020 13:09:14 -0500 Subject: [PATCH 3/3] add dyn file for test --- test/core/node2code/builtinAddNode.dyn | 144 +++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 test/core/node2code/builtinAddNode.dyn diff --git a/test/core/node2code/builtinAddNode.dyn b/test/core/node2code/builtinAddNode.dyn new file mode 100644 index 00000000000..ab21e6db3ba --- /dev/null +++ b/test/core/node2code/builtinAddNode.dyn @@ -0,0 +1,144 @@ +{ + "Uuid": "2c2cfb4e-70f7-4462-bca2-facc02603823", + "IsCustomNode": false, + "Description": null, + "Name": "builtinAddNode", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "NodeType": "FunctionNode", + "FunctionSignature": "+@var[]..[],var[]..[]", + "Id": "b9ce5822dce94a8bbd13d11b36c2c5b2", + "Inputs": [ + { + "Id": "44f8e12394444e529e6dff105400cea8", + "Name": "x", + "Description": "x value.\n\nvar[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "95db0f3d6dd74a7298ecbcc325a9e530", + "Name": "y", + "Description": "y value.\n\nvar[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "452c6cbeaf7a4e0faa31d9336ad6a288", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "Adds x to y.\n\n+ (x: var[]..[], y: var[]..[]): var[]..[]" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "32;\n17;", + "Id": "969d2265352c4e1ca335049dca655ad4", + "Inputs": [], + "Outputs": [ + { + "Id": "b5754723e63f4537bb1a0e632f96716a", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "7ce41a3ce4864602b533dc5112c29b32", + "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" + } + ], + "Connectors": [ + { + "Start": "b5754723e63f4537bb1a0e632f96716a", + "End": "44f8e12394444e529e6dff105400cea8", + "Id": "abb969fc755a4d9d8b8230a33b95d4ec" + }, + { + "Start": "7ce41a3ce4864602b533dc5112c29b32", + "End": "95db0f3d6dd74a7298ecbcc325a9e530", + "Id": "81f9f996548d48fb9d686bca6ce3548c" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "2.11.0.3451", + "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": [ + { + "Id": "b9ce5822dce94a8bbd13d11b36c2c5b2", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Name": "+", + "ShowGeometry": true, + "Excluded": false, + "X": 333.5, + "Y": 175.0 + }, + { + "Id": "969d2265352c4e1ca335049dca655ad4", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Name": "Code Block", + "ShowGeometry": true, + "Excluded": false, + "X": 167.0, + "Y": 181.0 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file