Skip to content
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
11 changes: 7 additions & 4 deletions src/DynamoCore/Graph/Nodes/PortModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,17 +473,19 @@
{
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.
Comment on lines 478 to 482
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);

Check warning on line 488 in src/DynamoCore/Graph/Nodes/PortModel.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Indexing should be used instead of the "Enumerable" extension method "ElementAt"

See more on https://sonarcloud.io/project/issues?id=DynamoDS_Dynamo&issues=AZ84VDPZ6xLRZGh_3Qcs&open=AZ84VDPZ6xLRZGh_3Qcs&pullRequest=17208
type = param.Type.ToString();
}
else
Expand All @@ -493,7 +495,8 @@
}
else
{
var param = fd.Parameters.ElementAt(Index);
var paramIndex = ztNode is DSVarArgFunction ? Math.Min(Index, parameters.Count - 1) : Index;
var param = parameters.ElementAt(paramIndex);

Check warning on line 499 in src/DynamoCore/Graph/Nodes/PortModel.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Indexing should be used instead of the "Enumerable" extension method "ElementAt"

See more on https://sonarcloud.io/project/issues?id=DynamoDS_Dynamo&issues=AZ84VDPZ6xLRZGh_3Qct&open=AZ84VDPZ6xLRZGh_3Qct&pullRequest=17208
type = param.Type.ToString();
}
return type;
Expand Down Expand Up @@ -548,7 +551,7 @@
{
if (PortType == PortType.Input) return null;

if (Owner is DSFunction ztNode)
if (Owner is DSFunctionBase ztNode)
{
var fd = ztNode.Controller.Definition;

Expand Down
1 change: 1 addition & 0 deletions src/Libraries/CoreNodeModels/CurveMapperNodeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
1 change: 1 addition & 0 deletions src/Libraries/CoreNodeModels/Input/BaseTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 38 additions & 1 deletion test/DynamoCoreTests/CoreTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -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());
}

/// <summary>
/// Pasting an Input or Output node into the Home Workspace converts them
/// to a Code Block node.
Expand Down
Loading