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

Fix crash with incorrect syntax in CBN in custom node #9258

Merged
merged 3 commits into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DynamoCore/Engine/CodeGeneration/AstBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
14 changes: 14 additions & 0 deletions test/DynamoCoreWpfTests/RecordedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,20 @@ public void TestCustomNode()
AssertPreviewValue("04f6dab5-0a0b-4563-9f20-d0e58fcae7a5", 1.0);
}

[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"));
}


[Test]
public void TestCustomNodeUI()
{
Expand Down
32 changes: 32 additions & 0 deletions test/core/recorded/CreateCustomNodeSyntaxError.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Commands ExitAfterPlayback="true" PauseAfterPlaybackInMs="10" CommandIntervalInMs="20">
<SelectModelCommand Modifiers="0">
<ModelGuid>00000000-0000-0000-0000-000000000000</ModelGuid>
</SelectModelCommand>
<CreateCustomNodeCommand Name="fdg" Category="Fdsg" Description="fdgs" MakeCurrent="true">
<ModelGuid>0ebfb690-5ed7-4cc1-ac59-f797c3c330a2</ModelGuid>
</CreateCustomNodeCommand>
<SelectModelCommand Modifiers="0">
<ModelGuid>00000000-0000-0000-0000-000000000000</ModelGuid>
</SelectModelCommand>
<CreateNodeCommand X="357.333333333333" Y="231.333333333333" DefaultPosition="false" TransformCoordinates="true">
<ModelGuid>d826ffc3-759e-4eb6-968e-82c0fa0a13f2</ModelGuid>
<Dynamo.Graph.Nodes.CodeBlockNodeModel guid="d826ffc3-759e-4eb6-968e-82c0fa0a13f2" type="Dynamo.Graph.Nodes.CodeBlockNodeModel" nickname="Code Block" x="265" y="200" isVisible="true" lacing="Disabled" isSelectedInput="False" isSelectedOutput="False" IsFrozen="false" isPinned="false" CodeText="1...10;" ShouldFocus="false">
<OutPortInfo LineIndex="0" />
</Dynamo.Graph.Nodes.CodeBlockNodeModel>
</CreateNodeCommand>
<UpdateModelValueCommand Name="Code" Value="1...10" WorkspaceGuid="e6953cd6-586f-442f-845c-cd7d93dacbc6">
<ModelGuid>d826ffc3-759e-4eb6-968e-82c0fa0a13f2</ModelGuid>
</UpdateModelValueCommand>
<SelectModelCommand Modifiers="0">
<ModelGuid>00000000-0000-0000-0000-000000000000</ModelGuid>
</SelectModelCommand>
<UpdateModelValueCommand Name="Code" Value="1..10;" WorkspaceGuid="e6953cd6-586f-442f-845c-cd7d93dacbc6">
<ModelGuid>d826ffc3-759e-4eb6-968e-82c0fa0a13f2</ModelGuid>
</UpdateModelValueCommand>
<SelectModelCommand Modifiers="0">
<ModelGuid>00000000-0000-0000-0000-000000000000</ModelGuid>
</SelectModelCommand>
<UpdateModelValueCommand Name="Code" Value="1...10;" WorkspaceGuid="e6953cd6-586f-442f-845c-cd7d93dacbc6">
<ModelGuid>d826ffc3-759e-4eb6-968e-82c0fa0a13f2</ModelGuid>
</UpdateModelValueCommand>
</Commands>