-
Notifications
You must be signed in to change notification settings - Fork 636
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
Python engine property should copy/paste and undo correctly. #11006
Conversation
python node update valure core can handle engine python nodeview right click uses umv commands
…irst test case as well as subsequent tests.
{ | ||
libraries.Add("DSCPython.dll"); | ||
libraries.Add("DSIronPython.dll"); | ||
base.Start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remind me what does base.Start()
do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bunch of stuff, it basically starts the DynamoModel, and in this case the View as well.
Assert.AreEqual(new List<string> { "2.7.9", "3.8.3" }, pynode2.CachedValue.GetElements().Select(x => x.Data)); | ||
DispatcherUtil.DoEvents(); | ||
Model.CurrentWorkspace.Undo(); | ||
Assert.AreEqual(new List<string> { "3.8.3", "3.8.3" }, pynode2.CachedValue.GetElements().Select(x => x.Data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding tests for the other newly supported commands within this PR. Looks good to me
@@ -251,6 +269,10 @@ protected override void SerializeCore(XmlElement element, SaveContext context) | |||
XmlElement script = element.OwnerDocument.CreateElement("Script"); | |||
script.InnerText = this.script; | |||
element.AppendChild(script); | |||
XmlElement engine = element.OwnerDocument.CreateElement(nameof(Engine)); | |||
engine.InnerText = Enum.GetName(typeof(PythonEngineVersion), Engine); | |||
element.AppendChild(engine); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems these can still be easily converted to use Json in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. The fact that there are things in Dynamo depending on XML serialization, when we have obsoleted it, is scary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will file a task to do a spike on this, I believe we did one way back when we looked at JSON originally, maybe I can dig up some notes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some minor comments. Looks good overall
nodeLogic.IsSetAsInput = value; | ||
RaisePropertyChanged("IsSetAsInput"); | ||
DynamoViewModel.ExecuteCommand( | ||
new DynamoModel.UpdateModelValueCommand( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check formatting here? If this was Python the statement would be outside the if :)
nodeLogic.IsSetAsOutput = value; | ||
RaisePropertyChanged("IsSetAsOutput"); | ||
DynamoViewModel.ExecuteCommand( | ||
new DynamoModel.UpdateModelValueCommand( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
RaisePropertyChanged("IsDisplayingLabels"); | ||
|
||
DynamoViewModel.ExecuteCommand( | ||
new DynamoModel.UpdateModelValueCommand( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No if for this property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I'm not sure why that is, I didn't touch it because it didn't exist before and was present for those other properties - I can make the change and see if there are any test failures if you would like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it would be more consistent but not really required. Your call
@@ -251,6 +269,10 @@ protected override void SerializeCore(XmlElement element, SaveContext context) | |||
XmlElement script = element.OwnerDocument.CreateElement("Script"); | |||
script.InnerText = this.script; | |||
element.AppendChild(script); | |||
XmlElement engine = element.OwnerDocument.CreateElement(nameof(Engine)); | |||
engine.InnerText = Enum.GetName(typeof(PythonEngineVersion), Engine); | |||
element.AppendChild(engine); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. The fact that there are things in Dynamo depending on XML serialization, when we have obsoleted it, is scary.
test/DynamoCoreTests/CoreTests.cs
Outdated
@@ -386,6 +386,111 @@ public void CanAdd100NodesToClipboardAndPaste() | |||
Assert.AreEqual(numNodes * 2, CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); | |||
} | |||
|
|||
[Test] | |||
[Category("UnitTests")] | |||
public void CanCopydAndPasteAndUndoShowLabels() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo Copyd
=> Copy
. I see this is consistently copied over to other tests.
…S#11006) merging this in and will cp to 2.8
Purpose
https://jira.autodesk.com/browse/DYN-3022
Some properties of nodeModel cannot be undone using
undo/redo
and do notcopy/paste
correctly. This includes the new Engine property on Python nodes.This PR does the following:
adds xml serialization and deserialization of the missing properties to
NodeModel
andPythonNodeModel
classes, as the undo redo recorder and copy/paste rely on legacy xml model serialization.adds cases for the
updateModelValue
command handler on NodeModel to handle the properties we want to be undoable.in the viewModel layer - anywhere we wish to have undoable property settings, we use a
UpdateModelValueCommand
to set the property, these are automatically serialized into the undo/redo recorder.tests are added for the nodeModel properties, and for the Python engine properties.
Fix a small issue with the PythonNodeViewCustmizationTests and when the python engines were being scanned for to update the available engines.
Declarations
Check these if you believe they are true
*.resx
files