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

DYN-1261 Escape StringInputNode value when converting NodeToCode #2

Closed

Conversation

StudioLE
Copy link
Owner

@StudioLE StudioLE commented Nov 10, 2020

Purpose

JIRA: DYN-1261

Related Issues:

Ensure that string containing " and \ are correctly escaped when converting StringInputNode using NodeToCode.

Behaviour before:

DYN-1261 Escape-NodeToCode-Before

Behaviour after:
DYN-1261 Escape-NodeToCode-Completed

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • 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
  • All tests pass using the self-service CI.
  • 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

Reviewers

(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)

(FILL ME IN, optional) Any additional notes to reviewers or testers.

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

@StudioLE StudioLE changed the title Escape StringInputNode value when converting NodeToCode DYN 1261 Escape StringInputNode value when converting NodeToCode Nov 12, 2020
@StudioLE StudioLE force-pushed the DYN-1261-Escape-NodeToCode-Strings branch from 2512513 to cf8a79a Compare November 13, 2020 16:37
@StudioLE StudioLE changed the base branch from Internal-Review-RC2.8 to internal-review-master November 13, 2020 16:37
@StudioLE StudioLE marked this pull request as ready for review November 13, 2020 16:41
@StudioLE StudioLE added this to the 20Q4 milestone Nov 13, 2020
@SHKnudsen SHKnudsen self-requested a review November 13, 2020 17:09
@StudioLE StudioLE changed the title DYN 1261 Escape StringInputNode value when converting NodeToCode DYN-1261 Escape StringInputNode value when converting NodeToCode Nov 13, 2020
@StudioLE StudioLE requested a review from SHKnudsen November 23, 2020 16:15
@StudioLE StudioLE closed this Nov 23, 2020
@StudioLE StudioLE reopened this Nov 23, 2020
@StudioLE
Copy link
Owner Author

I've added a simple test in 6526482 so figured you might have further comments? @SHKnudsen

test/DynamoCoreTests/NodeToCodeTest.cs Show resolved Hide resolved
Comment on lines 1198 to 1207
var nodes = CurrentDynamoModel.CurrentWorkspace.Nodes;
var engine = CurrentDynamoModel.EngineController;
var result = engine.ConvertNodesToCode(nodes, nodes);
Assert.IsNotNull(result.AstNodes);

var assignment = result.AstNodes.FirstOrDefault();
Assert.IsNotNull(assignment);

var binaryExpr = assignment as BinaryExpressionNode;
Assert.IsNotNull(binaryExpr);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is all of this actually needed and if it is what are we using it for?

Shouldnt we just test that the nodes preview value is the expected?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I looked into this further and the other NodeToCode tests are extracting the the BinaryExpressionNode and checking the RightNode in order to check the value of the CodeBlockNode itself. As this seems to be a more explicit way of checking that that NodeToCode has worked as expected I've revised the test to follow this methodology in 3e11fc3.

.ToList();

// Assert
var expect = new List<string>
Copy link
Collaborator

@SHKnudsen SHKnudsen Nov 24, 2020

Choose a reason for hiding this comment

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

Nice, makes sense now!

If we are really picky the expect list should probably go into the Arrange section

@StudioLE StudioLE closed this Nov 24, 2020
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.

2 participants