diff --git a/src/DynamoCore/Graph/Nodes/PortModel.cs b/src/DynamoCore/Graph/Nodes/PortModel.cs index 481a060cd93..2e404eef09f 100644 --- a/src/DynamoCore/Graph/Nodes/PortModel.cs +++ b/src/DynamoCore/Graph/Nodes/PortModel.cs @@ -473,17 +473,19 @@ internal string GetInputPortType() { if (PortType == PortType.Output) return null; - if (Owner is DSFunction ztNode) + if (Owner is DSFunctionBase ztNode) { var fd = ztNode.Controller.Definition; string type; + var parameters = fd.Parameters.ToList(); // In the case of a node for an instance method, the first port // type is the declaring class type of the method itself. if (fd.Type == FunctionType.InstanceMethod || fd.Type == FunctionType.InstanceProperty) { if (Index > 0) { - var param = fd.Parameters.ElementAt(Index - 1); + var paramIndex = ztNode is DSVarArgFunction ? Math.Min(Index - 1, parameters.Count - 1) : Index - 1; + var param = parameters.ElementAt(paramIndex); type = param.Type.ToString(); } else @@ -493,7 +495,8 @@ internal string GetInputPortType() } else { - var param = fd.Parameters.ElementAt(Index); + var paramIndex = ztNode is DSVarArgFunction ? Math.Min(Index, parameters.Count - 1) : Index; + var param = parameters.ElementAt(paramIndex); type = param.Type.ToString(); } return type; @@ -548,7 +551,7 @@ internal string GetOutPortType() { if (PortType == PortType.Input) return null; - if (Owner is DSFunction ztNode) + if (Owner is DSFunctionBase ztNode) { var fd = ztNode.Controller.Definition; diff --git a/src/Libraries/CoreNodeModels/CurveMapperNodeModel.cs b/src/Libraries/CoreNodeModels/CurveMapperNodeModel.cs index 3045a1a5d82..c45728a6806 100644 --- a/src/Libraries/CoreNodeModels/CurveMapperNodeModel.cs +++ b/src/Libraries/CoreNodeModels/CurveMapperNodeModel.cs @@ -20,6 +20,7 @@ namespace CoreNodeModels [NodeSearchTags("CurveMapperSearchTags", typeof(Properties.Resources))] [InPortNames("x-MinLimit", "x-MaxLimit", "y-MinLimit", "y-MaxLimit", "values")] [InPortTypes("int", "int", "int", "int", "double")] + [OutPortTypes("double[]", "double[]")] public class CurveMapperNodeModel : NodeModel { diff --git a/src/Libraries/CoreNodeModels/Input/BaseTypes.cs b/src/Libraries/CoreNodeModels/Input/BaseTypes.cs index c729ce70073..826b33c064a 100644 --- a/src/Libraries/CoreNodeModels/Input/BaseTypes.cs +++ b/src/Libraries/CoreNodeModels/Input/BaseTypes.cs @@ -19,6 +19,7 @@ namespace CoreNodeModels.Input [NodeName("String")] [NodeCategory(BuiltinNodeCategories.CORE_INPUT)] [NodeDescription("StringInputNodeDescription", typeof(Resources))] + [OutPortTypes("string")] [IsDesignScriptCompatible] [AlsoKnownAs("Dynamo.Nodes.StringInput", "Dynamo.Nodes.dynStringInput", "DSCoreNodesUI.Input.StringInput")] public class StringInput : String diff --git a/test/DynamoCoreTests/CoreTests.cs b/test/DynamoCoreTests/CoreTests.cs index 6b5408a9d76..b1cc3b162c2 100644 --- a/test/DynamoCoreTests/CoreTests.cs +++ b/test/DynamoCoreTests/CoreTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -705,6 +705,43 @@ public void CanCopyAndPasteDSVarArgFunctionNode() }); } + [Test] + [Category("UnitTests")] + public void DSVarArgFunctionPortsReportInputAndOutputTypes() + { + var concatNode = new DSVarArgFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("DSCore.String.Concat@string[]")); + + Assert.AreEqual("string[]", concatNode.InPorts[0].GetInputPortType()); + Assert.AreEqual("string", concatNode.OutPorts[0].GetOutPortType()); + + var joinNode = new DSVarArgFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("DSCore.String.Join@string,string[]")); + joinNode.VarInputController.AddInputToModel(); + + Assert.AreEqual("string", joinNode.InPorts[0].GetInputPortType()); + Assert.AreEqual("string[]", joinNode.InPorts[1].GetInputPortType()); + Assert.AreEqual("string[]", joinNode.InPorts[2].GetInputPortType()); + Assert.AreEqual("string", joinNode.OutPorts[0].GetOutPortType()); + } + + [Test] + [Category("UnitTests")] + public void CurveMapperOutputsReportPortTypes() + { + var curveMapperNode = new CurveMapperNodeModel(); + + Assert.AreEqual("double[]", curveMapperNode.OutPorts[0].GetOutPortType()); + Assert.AreEqual("double[]", curveMapperNode.OutPorts[1].GetOutPortType()); + } + + [Test] + [Category("UnitTests")] + public void StringInputOutputReportsPortType() + { + var stringNode = new StringInput(); + + Assert.AreEqual("string", stringNode.OutPorts[0].GetOutPortType()); + } + /// /// Pasting an Input or Output node into the Home Workspace converts them /// to a Code Block node.