[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

Deleting assignment statements after function definition in CBN now updates output ports #10736

Merged
merged 8 commits into from
Jun 8, 2020

Conversation

aparajit-pratap
Copy link
Contributor
@aparajit-pratap aparajit-pratap commented Jun 4, 2020

Purpose

  1. Fixes DYN-2778 - deleting assignment statements after function definition in CBN now updates output ports
  2. Cached value when set to null now raises property changed event which updates node preview (see updated gif)
  3. Remove QueryMirrorDataAsyncTask as all usages were removed in Fix MAGN-9568 Crash in preview control #6240

func_def_cbn_fixed

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.

Reviewers

@DynamoDS/dynamo

Copy link
Collaborator
@mmisol mmisol left a comment

Choose a reason for hiding this comment

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

Code change looks good. Can we add a unit test?

src/DynamoCore/Graph/Nodes/CodeBlockNode.cs Show resolved Hide resolved
@aparajit-pratap
Copy link
Contributor Author

I find it strange that the node preview for the CBN containing the function definition continues to show the previous value (see gif). I'm trying to fix that as well.

@aparajit-pratap aparajit-pratap changed the title Deleting assignment statements after function definition in CBN updates output ports Deleting assignment statements after function definition in CBN now updates output ports Jun 4, 2020
@aparajit-pratap aparajit-pratap added PTAL Please Take A Look 👀 and removed WIP labels Jun 4, 2020
@aparajit-pratap
Copy link
Contributor Author

I find it strange that the node preview for the CBN containing the function definition continues to show the previous value (see gif). I'm trying to fix that as well.

Also fixed (see updated gif)

// requested to update its value. When the QueryMirrorDataAsyncTask
// returns, it will update cachedMirrorData with the latest value.
//
lock (cachedValueMutex)
Copy link
Member

Choose a reason for hiding this comment

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

can the mutex be removed? What else locks on it? Why remove it?

Copy link
Member

Choose a reason for hiding this comment

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

is there behavior that depended on cachedValue being set null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CachedValue is still being set to null in certain cases, one such case being this one where code is deleted from the CBN, leaving only the function definition in place. This is now happening in line: 2354 below. Earlier only the field was being set to null and not the property because of which the property changed event wasn't being raised. As a result, the preview of the node didn't update to null upon updating the CBN.
As CachedValue is being set to a non-null value outside of the lock anyway, I thought it would be safe to set it to null in cases where the mirror is null. Also the lock was in place specifically for QueryMirrorDataAsyncTask as per the comments, which has now been removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can check if the mutex is being used elsewhere and if it can be removed altogether.

Copy link
Contributor Author
@aparajit-pratap aparajit-pratap Jun 8, 2020

Choose a reason for hiding this comment

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

Ok, I just checked the cachedValueMutex is being used implicitly in the CachedValue getter and setter itself so it is safe to remove from here. Nothing more to do here.

Assert.AreEqual(0, cbn.OutPorts.Count);
Assert.AreEqual(0, cbn.AllConnectors.Count());
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a test for a case in which we have the same initial state but after the edit we also have the assignment a = [ 1, 2 ];?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mmisol done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice. Thanks!

Copy link
Collaborator
@mmisol mmisol left a comment

Choose a reason for hiding this comment

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

Looks good to me

Assert.AreEqual(0, cbn.OutPorts.Count);
Assert.AreEqual(0, cbn.AllConnectors.Count());
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice. Thanks!

@@ -3708,7 +3708,7 @@ public void Defect_MAGN_3212()

//Check the CBN for input/output ports
Assert.AreNotEqual(ElementState.Error, cbn.State);
Assert.AreEqual(1, cbn.OutPorts.Count);
Assert.AreEqual(0, cbn.OutPorts.Count);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this test doing an assertion that was incorrect and is now fixed by the change here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. Now that we remove the output ports for a function def, the count was updated to zero for this particular test.

@aparajit-pratap aparajit-pratap merged commit 7b432bc into DynamoDS:master Jun 8, 2020
@aparajit-pratap aparajit-pratap deleted the dyn-2778 branch June 8, 2020 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PTAL Please Take A Look 👀
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants