diff --git a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs
index f7f2118e863..e3e9b459f41 100644
--- a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs
+++ b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs
@@ -646,7 +646,9 @@ internal void Save(string filePath, bool isBackup = false, EngineController engi
// If a new CustomNodeWorkspaceModel is created, store that info in CustomNodeManager without creating an instance of the custom node.
if (this.Model is CustomNodeWorkspaceModel customNodeWorkspaceModel)
{
- customNodeWorkspaceModel.SetInfo(Path.GetFileNameWithoutExtension(filePath));
+ //If the custom node Name is already set and the FileName is already set then we don't need to change the Name with "backup"
+ if(string.IsNullOrEmpty(customNodeWorkspaceModel.Name) && string.IsNullOrEmpty(customNodeWorkspaceModel.FileName))
+ customNodeWorkspaceModel.SetInfo(Path.GetFileNameWithoutExtension(filePath));
}
}
catch (Exception ex)
diff --git a/test/DynamoCoreWpfTests/WorkspaceSaving.cs b/test/DynamoCoreWpfTests/WorkspaceSaving.cs
index 59344bb1865..d44b8d16b48 100644
--- a/test/DynamoCoreWpfTests/WorkspaceSaving.cs
+++ b/test/DynamoCoreWpfTests/WorkspaceSaving.cs
@@ -16,6 +16,7 @@
using Dynamo.ViewModels;
using Dynamo.Wpf;
using Dynamo.Wpf.ViewModels;
+using Dynamo.Wpf.ViewModels.Core;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
@@ -1411,6 +1412,53 @@ public void CustomNodeWorkspaceViewTestAfterSaving()
Assert.AreEqual(oldJObject["View"], newJObject["View"]);
}
+
+ ///
+ /// When focusing the Custom Node tab if the Save functionality is triggered was changing the CustomNode name automatically, then this test is validating that is not happening anymore
+ ///
+ [Test]
+ public void CustomNodeWorkspaceSaveBackupKeepNodeName()
+ {
+ var funcguid = GuidUtility.Create(GuidUtility.UrlNamespace, "NewCustomNodeKeepName");
+ var initialNodeName = "testnode";
+ //first create a new custom node.
+ this.ViewModel.ExecuteCommand(new DynamoModel.CreateCustomNodeCommand(funcguid, initialNodeName, "testcategory", "atest", true));
+
+ var customNodeWorspaceViewModel = this.ViewModel.Workspaces.OfType().FirstOrDefault();
+ var homeWorspaceViewModel = this.ViewModel.Workspaces.OfType().FirstOrDefault();
+
+ //Adds the CustomNode to the HomeWorkspaceViewModel so later we can check that the node name is not renamed after saving
+ var customNodeInstance = this.ViewModel.Model.CustomNodeManager.CreateCustomNodeInstance(funcguid);
+ homeWorspaceViewModel.Model.AddAndRegisterNode(customNodeInstance);
+
+ Assert.True(initialNodeName == customNodeInstance.Name);
+
+ //Create nodes that will be added to the Custom Node Workspace
+ var outnode1 = new Output();
+ outnode1.Symbol = "out1";
+ var outnode2 = new Output();
+ outnode1.Symbol = "out2";
+ var cbn = new CodeBlockNodeModel(this.ViewModel.EngineController.LibraryServices);
+ cbn.SetCodeContent("5;", this.ViewModel.CurrentSpace.ElementResolver);
+
+ //Add nodes to the Custom Node Workspace
+ customNodeWorspaceViewModel.Model.AddAndRegisterNode(cbn);
+ customNodeWorspaceViewModel.Model.AddAndRegisterNode(outnode1);
+ customNodeWorspaceViewModel.Model.AddAndRegisterNode(outnode2);
+
+ //Get the path in which the temporary dyf file is created and then Save
+ var savePath = GetNewFileNameOnTempPath("dyf");
+
+ //Change to the CustomNodeWorkspaceViewModel (like focusing the Custom Node tab)
+ ViewModel.CurrentWorkspaceIndex = 1;
+
+ //Before was changing the CustomNode name but it shouldn't be changed
+ ViewModel.SaveAs(savePath, SaveContext.SaveAs, true);
+
+ //Verify that the CustomNode name remains in the same value that was created previously
+ Assert.True(initialNodeName == customNodeInstance.Name);
+ Assert.False(Path.GetFileNameWithoutExtension(savePath) == customNodeInstance.Name);
+ }
#endregion
}
}