From 4518429a5e5b1ef2d1762d3a84835b40090509f6 Mon Sep 17 00:00:00 2001 From: aparajit-pratap Date: Wed, 21 Nov 2018 18:48:08 -0500 Subject: [PATCH 1/3] fix crash with cbn in custom node --- src/DynamoCore/Engine/CodeGeneration/AstBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DynamoCore/Engine/CodeGeneration/AstBuilder.cs b/src/DynamoCore/Engine/CodeGeneration/AstBuilder.cs index 0a6a2447564..4b828b98ce0 100644 --- a/src/DynamoCore/Engine/CodeGeneration/AstBuilder.cs +++ b/src/DynamoCore/Engine/CodeGeneration/AstBuilder.cs @@ -472,7 +472,7 @@ internal void CompileCustomNodeDefinition( else { // For single output, directly return that identifier or null. - AssociativeNode returnValue = outputs.Count == 1 ? outputs[0] : new NullNode(); + AssociativeNode returnValue = outputs.Count == 1 && outputs[0] != null ? outputs[0] : new NullNode(); functionBody.Body.Add(AstFactory.BuildReturnStatement(returnValue)); } From 12bd66fa18243fd63708c07f20a6340a738e3146 Mon Sep 17 00:00:00 2001 From: aparajit-pratap Date: Mon, 26 Nov 2018 12:23:19 -0500 Subject: [PATCH 2/3] add recorded test --- test/DynamoCoreWpfTests/RecordedTests.cs | 7 ++++ .../recorded/CreateCustomNodeSyntaxError.xml | 32 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 test/core/recorded/CreateCustomNodeSyntaxError.xml diff --git a/test/DynamoCoreWpfTests/RecordedTests.cs b/test/DynamoCoreWpfTests/RecordedTests.cs index 5c2e460fa7d..f7733388b12 100644 --- a/test/DynamoCoreWpfTests/RecordedTests.cs +++ b/test/DynamoCoreWpfTests/RecordedTests.cs @@ -709,6 +709,13 @@ public void TestCustomNode() AssertPreviewValue("04f6dab5-0a0b-4563-9f20-d0e58fcae7a5", 1.0); } + [Test] + public void TestCustomNodeSyntaxError_DoesNotCrash() + { + Assert.DoesNotThrow(() => RunCommandsFromFile("CreateCustomNodeSyntaxError.xml")); + } + + [Test] public void TestCustomNodeUI() { diff --git a/test/core/recorded/CreateCustomNodeSyntaxError.xml b/test/core/recorded/CreateCustomNodeSyntaxError.xml new file mode 100644 index 00000000000..80b3c5bee68 --- /dev/null +++ b/test/core/recorded/CreateCustomNodeSyntaxError.xml @@ -0,0 +1,32 @@ + + + 00000000-0000-0000-0000-000000000000 + + + 0ebfb690-5ed7-4cc1-ac59-f797c3c330a2 + + + 00000000-0000-0000-0000-000000000000 + + + d826ffc3-759e-4eb6-968e-82c0fa0a13f2 + + + + + + d826ffc3-759e-4eb6-968e-82c0fa0a13f2 + + + 00000000-0000-0000-0000-000000000000 + + + d826ffc3-759e-4eb6-968e-82c0fa0a13f2 + + + 00000000-0000-0000-0000-000000000000 + + + d826ffc3-759e-4eb6-968e-82c0fa0a13f2 + + \ No newline at end of file From f8439f60d060e8d93f528299ffa22f962959d9f6 Mon Sep 17 00:00:00 2001 From: aparajit-pratap Date: Mon, 26 Nov 2018 12:27:23 -0500 Subject: [PATCH 3/3] add test description --- test/DynamoCoreWpfTests/RecordedTests.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/DynamoCoreWpfTests/RecordedTests.cs b/test/DynamoCoreWpfTests/RecordedTests.cs index f7733388b12..d8de0f9f044 100644 --- a/test/DynamoCoreWpfTests/RecordedTests.cs +++ b/test/DynamoCoreWpfTests/RecordedTests.cs @@ -712,6 +712,13 @@ public void TestCustomNode() [Test] public void TestCustomNodeSyntaxError_DoesNotCrash() { + //Create custom node + //Scenario: + //1. Create custom node + //2. Create code block node + //3. Type in a range expression (1..10) and commit the node + //4. Update the code block by introducing syntax error like "1...10" + //5. Test for crash Assert.DoesNotThrow(() => RunCommandsFromFile("CreateCustomNodeSyntaxError.xml")); }