diff --git a/src/DynamoCore/Graph/Nodes/NodeLoaders/ZeroTouchNodeLoader.cs b/src/DynamoCore/Graph/Nodes/NodeLoaders/ZeroTouchNodeLoader.cs index 446bb47a76b..a95d503e8db 100644 --- a/src/DynamoCore/Graph/Nodes/NodeLoaders/ZeroTouchNodeLoader.cs +++ b/src/DynamoCore/Graph/Nodes/NodeLoaders/ZeroTouchNodeLoader.cs @@ -43,7 +43,7 @@ public NodeModel CreateNodeFromXml(XmlElement nodeElement, SaveContext context, string xmlSignature = nodeElement.Attributes["function"].Value; string hintedSigniture = - libraryServices.FunctionSignatureFromFunctionSignatureHint(xmlSignature); + libraryServices.GetFunctionSignatureFromFunctionSignatureHint(xmlSignature); if (hintedSigniture != null) { diff --git a/src/DynamoCore/Graph/Workspaces/SerializationConverters.cs b/src/DynamoCore/Graph/Workspaces/SerializationConverters.cs index cf6045def56..ab042466b34 100644 --- a/src/DynamoCore/Graph/Workspaces/SerializationConverters.cs +++ b/src/DynamoCore/Graph/Workspaces/SerializationConverters.cs @@ -230,15 +230,8 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist else if (typeof(DSFunctionBase).IsAssignableFrom(type)) { var mangledName = obj["FunctionSignature"].Value(); - var priorNames = libraryServices.GetPriorNames(); - var functionDescriptor = libraryServices.GetFunctionDescriptor(mangledName); - string newName; - - // Update the function descriptor if a newer migrated version of the node exists - if (priorNames.TryGetValue(mangledName, out newName)) - { - functionDescriptor = libraryServices.GetFunctionDescriptor(newName); - } + var lookupSignature = libraryServices.GetFunctionSignatureFromFunctionSignatureHint(mangledName) ?? mangledName; + var functionDescriptor = libraryServices.GetFunctionDescriptor(lookupSignature); // Use the functionDescriptor to try and restore the proper node if possible if (functionDescriptor == null) diff --git a/src/DynamoCore/Library/LibraryServices.cs b/src/DynamoCore/Library/LibraryServices.cs index 4e2a2cbba58..4a1da13199c 100644 --- a/src/DynamoCore/Library/LibraryServices.cs +++ b/src/DynamoCore/Library/LibraryServices.cs @@ -305,7 +305,7 @@ internal string NameFromFunctionSignature(string functionSignature) return splitted[splitted.Length - 2] + "." + splitted[splitted.Length - 1]; } - internal string FunctionSignatureFromFunctionSignatureHint(string functionSignature) + internal string GetFunctionSignatureFromFunctionSignatureHint(string functionSignature) { // if the hint is explicit, we can simply return the mapped function if (priorNameHints.ContainsKey(functionSignature)) diff --git a/test/DynamoCoreTests/MigrationTestFramework.cs b/test/DynamoCoreTests/MigrationTestFramework.cs index e58e356ab91..1e129620077 100644 --- a/test/DynamoCoreTests/MigrationTestFramework.cs +++ b/test/DynamoCoreTests/MigrationTestFramework.cs @@ -17,6 +17,7 @@ protected override void GetLibrariesToPreload(List libraries) libraries.Add("DSOffice.dll"); libraries.Add("FunctionObject.ds"); libraries.Add("BuiltIn.ds"); + libraries.Add("FFITarget.dll"); base.GetLibrariesToPreload(libraries); } diff --git a/test/DynamoCoreTests/NodeMigrationTests.cs b/test/DynamoCoreTests/NodeMigrationTests.cs index 363d7d8afde..b3265535a97 100644 --- a/test/DynamoCoreTests/NodeMigrationTests.cs +++ b/test/DynamoCoreTests/NodeMigrationTests.cs @@ -25,6 +25,7 @@ protected override void GetLibrariesToPreload(List libraries) libraries.Add("DSOffice.dll"); libraries.Add("FunctionObject.ds"); libraries.Add("BuiltIn.ds"); + libraries.Add("FFITarget.dll"); base.GetLibrariesToPreload(libraries); } @@ -2271,6 +2272,19 @@ public void TestPackageNodeMigrationForJSONGraphs() // Verify all 4 nodes exist in the workspace and were properly loaded/opened from above Assert.AreEqual(4, this.CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); } + + [Test] + [Category("UnitTests")] + public void TestZTNodeMigrationJSON_WithDifferentMethodNameAndParams() + { + var legacyGraph = Path.Combine(TestDirectory, "core","migration","TestMigrationFFIClass.dyn"); + TestMigration(legacyGraph); + + Assert.AreEqual(8, this.CurrentDynamoModel.CurrentWorkspace.Nodes.Count()); + AssertPreviewValue("408bd6b17f7f43b28a29175bf12fb01f", "hello"); + AssertPreviewValue("013bd08a0f574e85b1d9676ba7004990", "migrated"); + AssertPreviewValue("df483e75085340b2a8c359a59dc8ea7a", "migrated"); + } #endregion #region Private Helper Methods diff --git a/test/Engine/FFITarget/ClassWithMigratedMembers.cs b/test/Engine/FFITarget/ClassWithMigratedMembers.cs new file mode 100644 index 00000000000..fdb062449a7 --- /dev/null +++ b/test/Engine/FFITarget/ClassWithMigratedMembers.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FFITarget +{ + public class ClassWithMigratedMembers + { + + public static ClassWithMigratedMembers ByNothing() + { + return new ClassWithMigratedMembers(); + } + + //we test by opening a file that references a node with three params + public string AMemberWithTwoParams(string a, string b) + { + return a + b; + } + public string AMemberWithThreeParams(string a, string b,string c ="abc") + { + return "migrated"; + } + public string AnOverloadedMember(string a, string b) + { + return "original"; + } + public string AnOverloadedMember(string a, string b, string c = "abc") + { + return "migrated"; + } + + //we test a file that uses the node AMemberWithAChangedName1 + public string AMemberWithAChangedName2(string a) + { + return a; + } + /* public string AMemberWithAChangedName1(string a) + { + return a; + }*/ + } +} diff --git a/test/Engine/FFITarget/FFITarget.Migrations.xml b/test/Engine/FFITarget/FFITarget.Migrations.xml new file mode 100644 index 00000000000..bbb3358e3cf --- /dev/null +++ b/test/Engine/FFITarget/FFITarget.Migrations.xml @@ -0,0 +1,15 @@ + + + + FFITarget.ClassWithMigratedMembers.AMemberWithAChangedName1 + FFITarget.ClassWithMigratedMembers.AMemberWithAChangedName2 + + + FFITarget.ClassWithMigratedMembers.AMemberWithTwoParams@string,string + FFITarget.ClassWithMigratedMembers.AMemberWithThreeParams@string,string,string + + + FFITarget.ClassWithMigratedMembers.AnOverloadedMember@string,string + FFITarget.ClassWithMigratedMembers.AnOverloadedMember@string,string,string + + \ No newline at end of file diff --git a/test/Engine/FFITarget/FFITarget.csproj b/test/Engine/FFITarget/FFITarget.csproj index 33941deee04..e8a9ee5e0c6 100644 --- a/test/Engine/FFITarget/FFITarget.csproj +++ b/test/Engine/FFITarget/FFITarget.csproj @@ -52,6 +52,7 @@ + @@ -98,6 +99,11 @@ False + + + PreserveNewest + +