Skip to content

Conversation

@ivaylo-matov
Copy link
Contributor

@ivaylo-matov ivaylo-matov commented Jun 16, 2025

Purpose

This PR aims to address DYN-8997.

Changes:

  • CBN outports now display the left-hand variable/identifier of each code statement (previously just “>”). If there is no left-hand side, it displays the object type of the statement
  • Outports are displayed in condensed size and each shows the left side of its statement.
  • Each outport is vertically aligned with its respective statement line.
  • The above behaviors are also applied to proxy ports in collapsed groups.

DYN-8997-CodeBlockNode outputs_v2

Declarations

Check these if you believe they are true

  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB
  • This PR introduces new feature code involve network connecting and is tested with no-network mode.

Release Notes

The output port of code block node now displays the left side of the statement.

Reviewers

@DynamoDS/eidos
@jasonstratton.

FYIs

@dnenov
@achintyabhat

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-8997

@zeusongit zeusongit requested review from a team and Copilot June 18, 2025 01:59

This comment was marked as outdated.

@aparajit-pratap
Copy link
Contributor

aparajit-pratap commented Jun 18, 2025

This looks weird and is a deviation from current output port alignment:
image

The output port should always be placed against the identifier.

Copy link
Contributor

@aparajit-pratap aparajit-pratap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest removing the special condition for a single statement CBN to have the output port always placed at the topmost line. I don't see why it's needed. I agree with the idea of showing the single output port be bigger than when there are multiple ports but I strongly feel that the output port should always align with the code statement, even when there are whitespaces or comments.

In other words, the placement of the output port should be like it is currently:
image

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the CBN output port behavior so that it displays the variable name used on the left-hand side of code statements, ensuring proper alignment and tooltip display for both single and multiple statement code blocks. It also fixes a connector restoration issue by enforcing unique port identification.

  • Outport controls are updated to adjust styling and margins based on the number of code block outputs.
  • A new property (IsOnlyOutputPortInCodeBlock) has been introduced to differentiate single from multiple output ports.
  • Layout adjustments and API documentation updates have been applied across several files to support these changes.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs Adjusted outport margins and styling for CodeBlockNodes based on port count.
src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs Added property to check for a single output port in code blocks.
src/DynamoCoreWpf/ViewModels/Core/OutPortViewModel.cs Updated condensed port condition to incorporate single port logic.
src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs Revised port positioning and introduced a constant for collapsed port height.
src/DynamoCoreWpf/PublicAPI.Unshipped.txt Exposed the new IsOnlyOutputPortInCodeBlock property.
src/DynamoCoreWpf/Controls/OutPorts.xaml.cs Modified UI element margins and sizes based on the port type.
src/DynamoCore/Graph/Nodes/PortModel.cs Adjusted center position calculation to correctly offset code block outputs.
src/DynamoCore/Graph/Nodes/CodeBlockNode.cs Cleared and built output port labels with adjusted line indexing for single vs. multiple ports.

OutPorts.Clear();
InPorts.Clear();
inputPortNames.Clear();
outputPortNames.Clear();
Copy link

Copilot AI Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] There are multiple calls to outputPortNames.Clear() in the ProcessCode method. Consolidating these calls may prevent potential redundancy and clarify the port name collection process.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@jasonstratton jasonstratton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change appears pretty straightforward. I do understand Aparajit's objection and barring a change in the requirements there, I think this looks good to go.

@zeusongit
Copy link
Contributor

And just to validate the current state can you share an updated gif?

@ivaylo-matov
Copy link
Contributor Author

@zeusongit , the cbn related test should pass now.
CollapsingGroupWillCreateInportAndOuportCollections was addressed earlier in #16302

@zeusongit
Copy link
Contributor

@zeusongit zeusongit requested a review from aparajit-pratap July 8, 2025 20:20
@zeusongit zeusongit dismissed aparajit-pratap’s stale review July 9, 2025 00:47

Dismissing review, to enable merge, please leave comments if you feel the need for more changes. Merging now.

@zeusongit zeusongit merged commit 1fc55b5 into DynamoDS:master Jul 9, 2025
28 of 30 checks passed
case IdentifierNode idNode:
return idNode.Value;
case IdentifierListNode:
return "[identifier list]";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is a user-friendly description. I'm confident that many users will not understand this technical wording.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, what will be your suggestion in this case?

Copy link
Contributor

@aparajit-pratap aparajit-pratap Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no straightforward answer, unfortunately. An IdentifierListNode can be a function call (DSCore.List.Sort()), or property invocation (circle.CenterPoint.X). It's essentially any complex expression containing a chain (list) of identifiers, where each identifier can either be a namespace, class, variable, function, or property. I suppose the ideal solution here would be to break down the identifier list and inspect its rightmost AST to see if it's a function or property (a getter function in DS), then to label it as either a function or property.

case InlineConditionalNode:
return "[conditional]";
default:
return "[unknown]";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about imperative language blocks?

[Imperative]
{ ... }


foreach (var def in allDefs)
{
if (i >= outputPortNames.Count) break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a finite loop. It runs for each def in allDefs. Why are you breaking out of it in between?

.Where(expr => !string.IsNullOrEmpty(expr))
.Select(expr => expr + ";")
.ToList();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this function needs to be entirely rewritten, as it shouldn't be using custom string manipulation when we have a full-fledged parser for DesignScript code and syntax. Will send another PR to clean this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants