From ec9ef14a8a41d36a31954884041e0464b5dbc8ab Mon Sep 17 00:00:00 2001 From: Aparajit Pratap Date: Thu, 9 Jan 2025 19:52:37 -0500 Subject: [PATCH 1/9] fix dictionary preview by adding support for more types --- .../AssemblySharedInfo.cs | 4 ++-- .../ViewModels/Preview/WatchViewModel.cs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs b/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs index 5f8fc463f66..8a898fc9e3a 100644 --- a/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs +++ b/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs @@ -45,7 +45,7 @@ // to distinguish one build from another. AssemblyFileVersion is specified // in AssemblyVersionInfo.cs so that it can be easily incremented by the // automated build process. -[assembly: AssemblyVersion("3.5.0.6885")] +[assembly: AssemblyVersion("3.5.0.7395")] // By default, the "Product version" shown in the file properties window is @@ -64,4 +64,4 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("3.5.0.6885")] +[assembly: AssemblyFileVersion("3.5.0.7395")] diff --git a/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs b/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs index 733859f8db7..43affaa9cef 100644 --- a/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs @@ -272,7 +272,15 @@ private static string GetStringFromObject(object obj) case TypeCode.DateTime: return ((DateTime)obj).ToString(PreferenceSettings.DefaultDateFormat, CultureInfo.InvariantCulture); case TypeCode.Object: + if (obj is byte[] byteArray) + return Encoding.UTF8.GetString(byteArray); return ObjectToLabelString(obj); + case TypeCode.Byte: + return ((byte)obj).ToString(CultureInfo.InvariantCulture); + case TypeCode.UInt32: + return ((uint)obj).ToString(CultureInfo.InvariantCulture); + case TypeCode.UInt64: + return ((ulong)obj).ToString(CultureInfo.InvariantCulture); default: return (string)obj; }; @@ -313,6 +321,12 @@ private string GetDisplayType(object obj) return nameof(TypeCode.Object); case TypeCode.String: return nameof(TypeCode.String); + case TypeCode.Byte: + return nameof(TypeCode.Byte); + case TypeCode.UInt32: + return nameof(TypeCode.UInt32); + case TypeCode.UInt64: + return nameof(TypeCode.UInt64); case TypeCode.Empty: return String.Empty; default: From ab6bad8c0a565b6685adaaf025366e6683436f27 Mon Sep 17 00:00:00 2001 From: Aparajit Pratap Date: Thu, 9 Jan 2025 19:54:37 -0500 Subject: [PATCH 2/9] revert assemblyinfo --- src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs b/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs index 8a898fc9e3a..5f8fc463f66 100644 --- a/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs +++ b/src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs @@ -45,7 +45,7 @@ // to distinguish one build from another. AssemblyFileVersion is specified // in AssemblyVersionInfo.cs so that it can be easily incremented by the // automated build process. -[assembly: AssemblyVersion("3.5.0.7395")] +[assembly: AssemblyVersion("3.5.0.6885")] // By default, the "Product version" shown in the file properties window is @@ -64,4 +64,4 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("3.5.0.7395")] +[assembly: AssemblyFileVersion("3.5.0.6885")] From 5fb2728c18b09a58a3880f36f2b1041d61bc6a3a Mon Sep 17 00:00:00 2001 From: Aparajit Pratap Date: Fri, 10 Jan 2025 14:32:45 -0500 Subject: [PATCH 3/9] process json object for preview --- src/DynamoCoreWpf/Interfaces/IWatchHandler.cs | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs b/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs index 1f0d0daa730..ed3fde07f2f 100644 --- a/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs +++ b/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs @@ -1,15 +1,18 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Windows.Forms; using Dynamo.Configuration; using Dynamo.Extensions; using Dynamo.ViewModels; using Dynamo.Wpf.Properties; +using Newtonsoft.Json.Linq; using ProtoCore.DSASM; using ProtoCore.Mirror; using ProtoCore.Utils; +using static Lucene.Net.Queries.Function.ValueSources.MultiFunction; namespace Dynamo.Interfaces { @@ -83,7 +86,18 @@ private WatchViewModel ProcessThing(object value, ProtoCore.RuntimeCore runtimeC return node; } + if (value is JObject obj) + { + var dict = ConvertJObjectToDictionary(obj); + var node = new WatchViewModel(dict.Keys.Any() ? WatchViewModel.DICTIONARY : WatchViewModel.EMPTY_DICTIONARY, tag, RequestSelectGeometry, true); + + foreach (var e in dict.Keys.Zip(dict.Values, (key, val) => new { key, val })) + { + node.Children.Add(ProcessThing(e.val, runtimeCore, tag + ":" + e.key, showRawData, callback)); + } + return node; + } if (!(value is string) && value is IEnumerable) { var list = (value as IEnumerable).Cast().ToList(); @@ -122,6 +136,28 @@ private WatchViewModel ProcessThing(object value, ProtoCore.RuntimeCore runtimeC return new WatchViewModel(value, tag, RequestSelectGeometry); } + private static Dictionary ConvertJObjectToDictionary(JObject jObject) + { + var dictionary = new Dictionary(); + + foreach (var property in jObject.Properties()) + { + if (property.Value is JObject nestedObject) + { + dictionary[property.Name] = ConvertJObjectToDictionary(nestedObject); + } + else if (property.Value is JArray nestedArray) + { + dictionary[property.Name] = nestedArray.ToObject>(); + } + else + { + dictionary[property.Name] = property.Value.ToObject(); + } + } + return dictionary; + } + private WatchViewModel ProcessThing(double value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback) { return new WatchViewModel(value, tag, RequestSelectGeometry); From 4569a8149119e24ac92104e4173eafe45500fbae Mon Sep 17 00:00:00 2001 From: Aparajit Pratap Date: Fri, 10 Jan 2025 14:34:48 -0500 Subject: [PATCH 4/9] cleanup --- src/DynamoCoreWpf/Interfaces/IWatchHandler.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs b/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs index ed3fde07f2f..824348a2d47 100644 --- a/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs +++ b/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs @@ -1,18 +1,17 @@ + using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Windows.Forms; -using Dynamo.Configuration; +using Newtonsoft.Json.Linq; + using Dynamo.Extensions; using Dynamo.ViewModels; using Dynamo.Wpf.Properties; -using Newtonsoft.Json.Linq; using ProtoCore.DSASM; using ProtoCore.Mirror; using ProtoCore.Utils; -using static Lucene.Net.Queries.Function.ValueSources.MultiFunction; namespace Dynamo.Interfaces { From 432af98682d3a1bf5a3ffdae359421c2d48871b6 Mon Sep 17 00:00:00 2001 From: Aparajit Pratap Date: Mon, 13 Jan 2025 22:39:07 -0500 Subject: [PATCH 5/9] add tests for byte and uint previews --- .../ViewModels/Preview/WatchViewModel.cs | 2 - test/DynamoCoreWpfTests/WatchNodeTests.cs | 82 +++++++ test/Engine/FFITarget/DummyZeroTouchClass.cs | 38 +++- ...hDictionaryByteValuesDisplaysCorrectly.dyn | 150 +++++++++++++ ...hDictionaryUintValuesDisplaysCorrectly.dyn | 181 ++++++++++++++++ .../WatchJSONObjectDisplaysCorrectly.dyn | 203 ++++++++++++++++++ 6 files changed, 653 insertions(+), 3 deletions(-) create mode 100644 test/core/watch/WatchDictionaryByteValuesDisplaysCorrectly.dyn create mode 100644 test/core/watch/WatchDictionaryUintValuesDisplaysCorrectly.dyn create mode 100644 test/core/watch/WatchJSONObjectDisplaysCorrectly.dyn diff --git a/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs b/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs index 43affaa9cef..1e0106e9f2d 100644 --- a/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs @@ -272,8 +272,6 @@ private static string GetStringFromObject(object obj) case TypeCode.DateTime: return ((DateTime)obj).ToString(PreferenceSettings.DefaultDateFormat, CultureInfo.InvariantCulture); case TypeCode.Object: - if (obj is byte[] byteArray) - return Encoding.UTF8.GetString(byteArray); return ObjectToLabelString(obj); case TypeCode.Byte: return ((byte)obj).ToString(CultureInfo.InvariantCulture); diff --git a/test/DynamoCoreWpfTests/WatchNodeTests.cs b/test/DynamoCoreWpfTests/WatchNodeTests.cs index 374d0048442..aa452432e38 100644 --- a/test/DynamoCoreWpfTests/WatchNodeTests.cs +++ b/test/DynamoCoreWpfTests/WatchNodeTests.cs @@ -23,6 +23,7 @@ protected override void GetLibrariesToPreload(List libraries) libraries.Add("VMDataBridge.dll"); libraries.Add("ProtoGeometry.dll"); libraries.Add("DesignScriptBuiltin.dll"); + libraries.Add("DSCoreNodes.dll"); libraries.Add("FunctionObject.ds"); libraries.Add("FFITarget.dll"); base.GetLibrariesToPreload(libraries); @@ -363,6 +364,87 @@ public void WatchMultiReturnNodeOrder() Assert.AreEqual("1", children[3].NodeLabel); } + [Test] + public void WatchJSONObjectDisplaysCorrectly() + { + string openPath = Path.Combine(TestDirectory, @"core\watch\WatchJSONObjectDisplaysCorrectly.dyn"); + ViewModel.OpenCommand.Execute(openPath); + ViewModel.HomeSpace.Run(); + + var watchNode = ViewModel.Model.CurrentWorkspace.FirstNodeFromWorkspace(); + var watchVM = ViewModel.WatchHandler.GenerateWatchViewModelForData( + watchNode.CachedValue, watchNode.OutPorts.Select(p => p.Name), + ViewModel.Model.EngineController.LiveRunnerRuntimeCore, + watchNode.AstIdentifierForPreview.Name, true); + + var list = watchVM.Children; + Assert.AreEqual(1, list.Count); + var children = list[0].Children; + Assert.AreEqual("Dictionary", list[0].NodeLabel); + Assert.AreEqual(3, children.Count); + Assert.AreEqual("Dictionary", children[2].NodeLabel); + + children = children[2].Children; + Assert.AreEqual(7, children.Count); + Assert.AreEqual(" author ", children[2].ViewPath); + Assert.AreEqual("KBJ6N6Z8R2W3", children[2].NodeLabel); + } + + [Test] + public void WatchDictionaryByteValuesDisplaysCorrectly() + { + string openPath = Path.Combine(TestDirectory, @"core\watch\WatchDictionaryByteValuesDisplaysCorrectly.dyn"); + ViewModel.OpenCommand.Execute(openPath); + ViewModel.HomeSpace.Run(); + + var watchNode = ViewModel.Model.CurrentWorkspace.FirstNodeFromWorkspace(); + var watchVM = ViewModel.WatchHandler.GenerateWatchViewModelForData( + watchNode.CachedValue, watchNode.OutPorts.Select(p => p.Name), + ViewModel.Model.EngineController.LiveRunnerRuntimeCore, + watchNode.AstIdentifierForPreview.Name, true); + + var list = watchVM.Children; + Assert.AreEqual(1, list.Count); + var children = list[0].Children; + Assert.AreEqual(12, children.Count); + Assert.AreEqual("Byte", children[0].ValueType); + Assert.AreEqual("72", children[0].NodeLabel); + } + + [Test] + public void WatchDictionaryUintValuesDisplaysCorrectly() + { + string openPath = Path.Combine(TestDirectory, @"core\watch\WatchDictionaryUintValuesDisplaysCorrectly.dyn"); + ViewModel.OpenCommand.Execute(openPath); + ViewModel.HomeSpace.Run(); + + var watchNode = ViewModel.Model.CurrentWorkspace.FirstNodeFromWorkspace(); + var watchVM = ViewModel.WatchHandler.GenerateWatchViewModelForData( + watchNode.CachedValue, watchNode.OutPorts.Select(p => p.Name), + ViewModel.Model.EngineController.LiveRunnerRuntimeCore, + watchNode.AstIdentifierForPreview.Name, true); + + var list = watchVM.Children; + Assert.AreEqual(1, list.Count); + var children = list[0].Children; + Assert.AreEqual(5, children.Count); + Assert.AreEqual("UInt32", children[0].ValueType); + Assert.AreEqual("3", children[2].NodeLabel); + + var uint64node = ViewModel.Model.CurrentWorkspace.GetDSFunctionNodeFromWorkspace("DummyZeroTouchClass.DecodeToUint64Dictionary"); + var vm = ViewModel.WatchHandler.GenerateWatchViewModelForData( + uint64node.CachedValue, watchNode.OutPorts.Select(p => p.Name), + ViewModel.Model.EngineController.LiveRunnerRuntimeCore, + watchNode.AstIdentifierForPreview.Name, true); + + list = vm.Children; + Assert.AreEqual(1, list.Count); + children = list[0].Children; + Assert.AreEqual(5, children.Count); + Assert.AreEqual("UInt64", children[0].ValueType); + Assert.AreEqual("3", children[2].NodeLabel); + } + [Test] public void WatchNestedDictionaryPreviewFromMlutiReturnNode() { diff --git a/test/Engine/FFITarget/DummyZeroTouchClass.cs b/test/Engine/FFITarget/DummyZeroTouchClass.cs index 966d1b2bce8..0a922fd95e1 100644 --- a/test/Engine/FFITarget/DummyZeroTouchClass.cs +++ b/test/Engine/FFITarget/DummyZeroTouchClass.cs @@ -1,4 +1,7 @@ -using Dynamo.Graph.Nodes; +using Dynamo.Graph.Nodes; +using System.Text; +using System; +using System.Collections.Generic; namespace FFITarget { @@ -14,5 +17,38 @@ public int FunctionWithoutDescription(int a) { return 0; } + + public static Dictionary DecodeToByteDictionary() + { + // Example base64 encoded string + string encodedString = "SGVsbG8gV29ybGQh"; + + // Decode the base64 encoded string + byte[] decodedBytes = Convert.FromBase64String(encodedString); + var result = new Dictionary(); + result.Add("decodedBytes", decodedBytes); + + return result; + } + + public static Dictionary DecodeToUint32Dictionary() + { + // Example base64 encoded string + var uintArray = new uint[] { 1, 2, 3, 4, 5 }; + var result = new Dictionary(); + result.Add("uint32List", uintArray); + + return result; + } + + public static Dictionary DecodeToUint64Dictionary() + { + // Example base64 encoded string + var uintArray = new ulong[] { 1, 2, 3, 4, 5 }; + var result = new Dictionary(); + result.Add("uint64List", uintArray); + + return result; + } } } diff --git a/test/core/watch/WatchDictionaryByteValuesDisplaysCorrectly.dyn b/test/core/watch/WatchDictionaryByteValuesDisplaysCorrectly.dyn new file mode 100644 index 00000000000..dd10becf48f --- /dev/null +++ b/test/core/watch/WatchDictionaryByteValuesDisplaysCorrectly.dyn @@ -0,0 +1,150 @@ +{ + "Uuid": "8a5b5d45-b86d-4b1f-9d04-bec0e4fefd1c", + "IsCustomNode": false, + "Description": "", + "Name": "WatchDictionaryByteValuesDisplaysCorrectly", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "CoreNodeModels.Watch, CoreNodeModels", + "WatchWidth": 200.0, + "WatchHeight": 200.0, + "Id": "e72bcbe3c45044399237b0f63ff261cd", + "NodeType": "ExtensionNode", + "Inputs": [ + { + "Id": "3f76a802ad484a90b7a466783baad45a", + "Name": "", + "Description": "Node to show output from", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "fa2127ef2e864999aae8a00dcc13489f", + "Name": "", + "Description": "Node output", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Visualizes a node's output" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "Id": "1590b6b5eec749978ede96d3e3f794e6", + "NodeType": "FunctionNode", + "Inputs": [], + "Outputs": [ + { + "Id": "661d3132a5df4bbaae2dc74ccdbd562f", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "FunctionSignature": "FFITarget.DummyZeroTouchClass.DecodeToByteDictionary", + "Replication": "Auto", + "Description": "DummyZeroTouchClass.DecodeToByteDictionary ( ): var[]..[]" + } + ], + "Connectors": [ + { + "Start": "661d3132a5df4bbaae2dc74ccdbd562f", + "End": "3f76a802ad484a90b7a466783baad45a", + "Id": "0a3e7eb777b243b3819acbdb41346e7b", + "IsHidden": "False" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [ + { + "Name": "FFITarget.dll", + "ReferenceType": "ZeroTouch", + "Nodes": [ + "1590b6b5eec749978ede96d3e3f794e6" + ] + } + ], + "EnableLegacyPolyCurveBehavior": true, + "Thumbnail": "", + "GraphDocumentationURL": null, + "ExtensionWorkspaceData": [ + { + "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", + "Name": "Properties", + "Version": "3.5", + "Data": {} + } + ], + "Author": "", + "Linting": { + "activeLinter": "None", + "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", + "warningCount": 0, + "errorCount": 0 + }, + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "3.5.0.6885", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "_Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "ConnectorPins": [], + "NodeViews": [ + { + "Id": "e72bcbe3c45044399237b0f63ff261cd", + "Name": "Watch", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 558.0000000000003, + "Y": 134.0 + }, + { + "Id": "1590b6b5eec749978ede96d3e3f794e6", + "Name": "DummyZeroTouchClass.DecodeToByteDictionary", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 70.40000000000003, + "Y": 416.00000000000006 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file diff --git a/test/core/watch/WatchDictionaryUintValuesDisplaysCorrectly.dyn b/test/core/watch/WatchDictionaryUintValuesDisplaysCorrectly.dyn new file mode 100644 index 00000000000..0547eaa37fb --- /dev/null +++ b/test/core/watch/WatchDictionaryUintValuesDisplaysCorrectly.dyn @@ -0,0 +1,181 @@ +{ + "Uuid": "44be9033-1237-4074-b64a-04f5e4fbee18", + "IsCustomNode": false, + "Description": "", + "Name": "WatchDictionaryUintValuesDisplaysCorrectly", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "Id": "323e1fa982d44e28994147ca1d3ab92a", + "NodeType": "FunctionNode", + "Inputs": [], + "Outputs": [ + { + "Id": "652af580d4e54c67ab6b77e33a615c89", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "FunctionSignature": "FFITarget.DummyZeroTouchClass.DecodeToUint32Dictionary", + "Replication": "Auto", + "Description": "DummyZeroTouchClass.DecodeToUint32Dictionary ( ): var[]..[]" + }, + { + "ConcreteType": "CoreNodeModels.Watch, CoreNodeModels", + "WatchWidth": 200.0, + "WatchHeight": 200.0, + "Id": "9b8b6b2f0d7043389c77e60936da1153", + "NodeType": "ExtensionNode", + "Inputs": [ + { + "Id": "a28f58656c4e48e395d218f370d104ec", + "Name": "", + "Description": "Node to show output from", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "a4d6f3613d34421ca298fe5ebca40062", + "Name": "", + "Description": "Node output", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Visualizes a node's output" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "Id": "1c54f75b46ed441d8e2cb39d68e6ba06", + "NodeType": "FunctionNode", + "Inputs": [], + "Outputs": [ + { + "Id": "c1cb61dc2b4e48e99f6ee50e710ea411", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "FunctionSignature": "FFITarget.DummyZeroTouchClass.DecodeToUint64Dictionary", + "Replication": "Auto", + "Description": "DummyZeroTouchClass.DecodeToUint64Dictionary ( ): var[]..[]" + } + ], + "Connectors": [ + { + "Start": "652af580d4e54c67ab6b77e33a615c89", + "End": "a28f58656c4e48e395d218f370d104ec", + "Id": "029069936ad54e278817548aa765b156", + "IsHidden": "False" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [ + { + "Name": "FFITarget.dll", + "ReferenceType": "ZeroTouch", + "Nodes": [ + "323e1fa982d44e28994147ca1d3ab92a", + "1c54f75b46ed441d8e2cb39d68e6ba06" + ] + } + ], + "EnableLegacyPolyCurveBehavior": true, + "Thumbnail": "", + "GraphDocumentationURL": null, + "ExtensionWorkspaceData": [ + { + "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", + "Name": "Properties", + "Version": "3.5", + "Data": {} + } + ], + "Author": "", + "Linting": { + "activeLinter": "None", + "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", + "warningCount": 0, + "errorCount": 0 + }, + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "3.5.0.6885", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "_Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "ConnectorPins": [], + "NodeViews": [ + { + "Id": "323e1fa982d44e28994147ca1d3ab92a", + "Name": "DummyZeroTouchClass.DecodeToUint32Dictionary", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 38.799999999999955, + "Y": 73.60000000000007 + }, + { + "Id": "9b8b6b2f0d7043389c77e60936da1153", + "Name": "Watch", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 657.6000000000001, + "Y": 39.20000000000003 + }, + { + "Id": "1c54f75b46ed441d8e2cb39d68e6ba06", + "Name": "DummyZeroTouchClass.DecodeToUint64Dictionary", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 49.19999999999982, + "Y": 352.80000000000007 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file diff --git a/test/core/watch/WatchJSONObjectDisplaysCorrectly.dyn b/test/core/watch/WatchJSONObjectDisplaysCorrectly.dyn new file mode 100644 index 00000000000..49af038c537 --- /dev/null +++ b/test/core/watch/WatchJSONObjectDisplaysCorrectly.dyn @@ -0,0 +1,203 @@ +{ + "Uuid": "eab7724b-226e-40a7-ab9e-a0af83b3aaa6", + "IsCustomNode": false, + "Description": "", + "Name": "WatchJSONObjectDisplaysCorrectly", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "CoreNodeModels.FromArray, CoreNodeModels", + "Id": "3a51552c22684e50a0ebedc704d1a55b", + "NodeType": "ExtensionNode", + "Inputs": [ + { + "Id": "82be642c760e42e4aa46c67f9ae13fb3", + "Name": "array", + "Description": "The array of object to be serialized", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "b5802e2494274a6fbd74fee257b0c4c7", + "Name": "string", + "Description": "String representation of the array", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Converts an array to a string representation" + }, + { + "ConcreteType": "CoreNodeModels.Watch, CoreNodeModels", + "WatchWidth": 200.0, + "WatchHeight": 200.0, + "Id": "377fd521122542619135cbfbe0466eed", + "NodeType": "ExtensionNode", + "Inputs": [ + { + "Id": "649439737ccd434ca0691c896a8a8e0d", + "Name": "", + "Description": "Node to show output from", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "b2af9691e3ad4c108410c6c1b86e7ac4", + "Name": "", + "Description": "Node output", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Visualizes a node's output" + }, + { + "ConcreteType": "CoreNodeModels.Remember, CoreNodeModels", + "Cache": "[{\"virtual\":true,\"category\":\"annotation_label\",\"annotation_label\":{\"text\":\"Tower\",\"color\":\"#222933\",\"author\":\"KBJ6N6Z8R2W3\",\"opacity\":1,\"editedAt\":1736470185590,\"textAlign\":\"start\",\"labelOffset\":{\"x\":0,\"y\":-40}}}]", + "Id": "271c07b4cd4b41938e50cfda285b0053", + "NodeType": "ExtensionNode", + "Inputs": [ + { + "Id": "be460b0e15eb48ffb51b492713f503c5", + "Name": ">", + "Description": "Data to sample and store in the file.", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "8e14610110f440e1aea481559c2233b6", + "Name": ">", + "Description": "Data", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Store data passing through this node to the Dynamo file. Return the stored data if the input is null." + } + ], + "Connectors": [ + { + "Start": "8e14610110f440e1aea481559c2233b6", + "End": "82be642c760e42e4aa46c67f9ae13fb3", + "Id": "5f5ff4a0f50e46aab62e37766cb4118f", + "IsHidden": "False" + }, + { + "Start": "8e14610110f440e1aea481559c2233b6", + "End": "649439737ccd434ca0691c896a8a8e0d", + "Id": "b1aee35a552c4b54b95bd02254e578ea", + "IsHidden": "False" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "EnableLegacyPolyCurveBehavior": true, + "Thumbnail": "", + "GraphDocumentationURL": null, + "ExtensionWorkspaceData": [ + { + "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", + "Name": "Properties", + "Version": "2.19", + "Data": {} + }, + { + "ExtensionGuid": "DFBD9CC0-DB40-457A-939E-8C8555555A9D", + "Name": "Generative Design", + "Version": "6.1", + "Data": {} + } + ], + "Author": "", + "Linting": { + "activeLinter": "None", + "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", + "warningCount": 0, + "errorCount": 0 + }, + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "3.5.0.6885", + "RunType": "Manual", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "_Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "ConnectorPins": [], + "NodeViews": [ + { + "Id": "3a51552c22684e50a0ebedc704d1a55b", + "Name": "String from Array", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 756.7069686704383, + "Y": 191.5204806357242 + }, + { + "Id": "377fd521122542619135cbfbe0466eed", + "Name": "Watch", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 888.0915115605001, + "Y": 479.8711178846082 + }, + { + "Id": "271c07b4cd4b41938e50cfda285b0053", + "Name": "Remember", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 503.90696867043835, + "Y": 504.5204806357242 + } + ], + "Annotations": [], + "X": -16.863020776903483, + "Y": -105.58990750948362, + "Zoom": 0.7344365364544645 + } +} \ No newline at end of file From 688332e15a1abc9cb7dd5a829b110b45e5c668f5 Mon Sep 17 00:00:00 2001 From: Aparajit Pratap Date: Tue, 14 Jan 2025 00:03:32 -0500 Subject: [PATCH 6/9] add test for JSON preview --- test/DynamoCoreWpfTests/WatchNodeTests.cs | 22 +++ test/Engine/FFITarget/DummyZeroTouchClass.cs | 15 +- ...hDictionaryJSONValuesDisplaysCorrectly.dyn | 150 ++++++++++++++++++ 3 files changed, 184 insertions(+), 3 deletions(-) create mode 100644 test/core/watch/WatchDictionaryJSONValuesDisplaysCorrectly.dyn diff --git a/test/DynamoCoreWpfTests/WatchNodeTests.cs b/test/DynamoCoreWpfTests/WatchNodeTests.cs index aa452432e38..04bcfe04fc4 100644 --- a/test/DynamoCoreWpfTests/WatchNodeTests.cs +++ b/test/DynamoCoreWpfTests/WatchNodeTests.cs @@ -445,6 +445,28 @@ public void WatchDictionaryUintValuesDisplaysCorrectly() Assert.AreEqual("3", children[2].NodeLabel); } + [Test] + public void WatchDictionaryJSONValuesDisplaysCorrectly() + { + + string openPath = Path.Combine(TestDirectory, @"core\watch\WatchDictionaryJSONValuesDisplaysCorrectly.dyn"); + ViewModel.OpenCommand.Execute(openPath); + ViewModel.HomeSpace.Run(); + + var watchNode = ViewModel.Model.CurrentWorkspace.FirstNodeFromWorkspace(); + var watchVM = ViewModel.WatchHandler.GenerateWatchViewModelForData( + watchNode.CachedValue, watchNode.OutPorts.Select(p => p.Name), + ViewModel.Model.EngineController.LiveRunnerRuntimeCore, + watchNode.AstIdentifierForPreview.Name, true); + + var list = watchVM.Children; + Assert.AreEqual(1, list.Count); + var children = list[0].Children; + Assert.AreEqual(2, children.Count); + Assert.AreEqual("String", children[0].ValueType); + Assert.AreEqual("value1", children[0].NodeLabel); + } + [Test] public void WatchNestedDictionaryPreviewFromMlutiReturnNode() { diff --git a/test/Engine/FFITarget/DummyZeroTouchClass.cs b/test/Engine/FFITarget/DummyZeroTouchClass.cs index 0a922fd95e1..039875bbda2 100644 --- a/test/Engine/FFITarget/DummyZeroTouchClass.cs +++ b/test/Engine/FFITarget/DummyZeroTouchClass.cs @@ -2,6 +2,7 @@ using System.Text; using System; using System.Collections.Generic; +using Newtonsoft.Json.Linq; namespace FFITarget { @@ -23,7 +24,6 @@ public static Dictionary DecodeToByteDictionary() // Example base64 encoded string string encodedString = "SGVsbG8gV29ybGQh"; - // Decode the base64 encoded string byte[] decodedBytes = Convert.FromBase64String(encodedString); var result = new Dictionary(); result.Add("decodedBytes", decodedBytes); @@ -33,7 +33,6 @@ public static Dictionary DecodeToByteDictionary() public static Dictionary DecodeToUint32Dictionary() { - // Example base64 encoded string var uintArray = new uint[] { 1, 2, 3, 4, 5 }; var result = new Dictionary(); result.Add("uint32List", uintArray); @@ -43,12 +42,22 @@ public static Dictionary DecodeToUint32Dictionary() public static Dictionary DecodeToUint64Dictionary() { - // Example base64 encoded string var uintArray = new ulong[] { 1, 2, 3, 4, 5 }; var result = new Dictionary(); result.Add("uint64List", uintArray); return result; } + + public static Dictionary DecodeToJSONDictionary() + { + var json = new JObject(); + json.Add("key1", "value1"); + json.Add("key2", "value2"); + var result = new Dictionary(); + result.Add("json", json); + + return result; + } } } diff --git a/test/core/watch/WatchDictionaryJSONValuesDisplaysCorrectly.dyn b/test/core/watch/WatchDictionaryJSONValuesDisplaysCorrectly.dyn new file mode 100644 index 00000000000..17e53dc3a00 --- /dev/null +++ b/test/core/watch/WatchDictionaryJSONValuesDisplaysCorrectly.dyn @@ -0,0 +1,150 @@ +{ + "Uuid": "882d7929-ed69-4315-a1c7-4265dd1cf731", + "IsCustomNode": false, + "Description": "", + "Name": "WatchDictionaryJSONValuesDisplaysCorrectly", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "CoreNodeModels.Watch, CoreNodeModels", + "WatchWidth": 200.0, + "WatchHeight": 200.0, + "Id": "7e16a76e05f140f2b3c9f105a402eba5", + "NodeType": "ExtensionNode", + "Inputs": [ + { + "Id": "5edfedb097ba41f4b91a3e7d9c200403", + "Name": "", + "Description": "Node to show output from", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "b03dcd8f66234e4a8c9b4f0a425c1215", + "Name": "", + "Description": "Node output", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Visualizes a node's output" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "Id": "4f6e6a98bbce4e299b5a464f7d6f4a0d", + "NodeType": "FunctionNode", + "Inputs": [], + "Outputs": [ + { + "Id": "081f421cf35c446d8286198718fdec57", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "FunctionSignature": "FFITarget.DummyZeroTouchClass.DecodeToJSONDictionary", + "Replication": "Auto", + "Description": "DummyZeroTouchClass.DecodeToJSONDictionary ( ): var[]..[]" + } + ], + "Connectors": [ + { + "Start": "081f421cf35c446d8286198718fdec57", + "End": "5edfedb097ba41f4b91a3e7d9c200403", + "Id": "61c671a95e28452684392e434b501af8", + "IsHidden": "False" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [ + { + "Name": "FFITarget.dll", + "ReferenceType": "ZeroTouch", + "Nodes": [ + "4f6e6a98bbce4e299b5a464f7d6f4a0d" + ] + } + ], + "EnableLegacyPolyCurveBehavior": true, + "Thumbnail": "", + "GraphDocumentationURL": null, + "ExtensionWorkspaceData": [ + { + "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", + "Name": "Properties", + "Version": "3.5", + "Data": {} + } + ], + "Author": "", + "Linting": { + "activeLinter": "None", + "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", + "warningCount": 0, + "errorCount": 0 + }, + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "3.5.0.6885", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "_Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "ConnectorPins": [], + "NodeViews": [ + { + "Id": "7e16a76e05f140f2b3c9f105a402eba5", + "Name": "Watch", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 558.0000000000003, + "Y": 134.0 + }, + { + "Id": "4f6e6a98bbce4e299b5a464f7d6f4a0d", + "Name": "DummyZeroTouchClass.DecodeToJSONDictionary", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 46.39999999999998, + "Y": 149.2 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file From 836f3f90897be5c283cadf889133d98d0008d10e Mon Sep 17 00:00:00 2001 From: Aparajit Pratap Date: Tue, 14 Jan 2025 00:08:16 -0500 Subject: [PATCH 7/9] remove bad test --- test/DynamoCoreWpfTests/WatchNodeTests.cs | 26 --- .../WatchJSONObjectDisplaysCorrectly.dyn | 203 ------------------ 2 files changed, 229 deletions(-) delete mode 100644 test/core/watch/WatchJSONObjectDisplaysCorrectly.dyn diff --git a/test/DynamoCoreWpfTests/WatchNodeTests.cs b/test/DynamoCoreWpfTests/WatchNodeTests.cs index 04bcfe04fc4..c11ea86eb76 100644 --- a/test/DynamoCoreWpfTests/WatchNodeTests.cs +++ b/test/DynamoCoreWpfTests/WatchNodeTests.cs @@ -364,32 +364,6 @@ public void WatchMultiReturnNodeOrder() Assert.AreEqual("1", children[3].NodeLabel); } - [Test] - public void WatchJSONObjectDisplaysCorrectly() - { - string openPath = Path.Combine(TestDirectory, @"core\watch\WatchJSONObjectDisplaysCorrectly.dyn"); - ViewModel.OpenCommand.Execute(openPath); - ViewModel.HomeSpace.Run(); - - var watchNode = ViewModel.Model.CurrentWorkspace.FirstNodeFromWorkspace(); - var watchVM = ViewModel.WatchHandler.GenerateWatchViewModelForData( - watchNode.CachedValue, watchNode.OutPorts.Select(p => p.Name), - ViewModel.Model.EngineController.LiveRunnerRuntimeCore, - watchNode.AstIdentifierForPreview.Name, true); - - var list = watchVM.Children; - Assert.AreEqual(1, list.Count); - var children = list[0].Children; - Assert.AreEqual("Dictionary", list[0].NodeLabel); - Assert.AreEqual(3, children.Count); - Assert.AreEqual("Dictionary", children[2].NodeLabel); - - children = children[2].Children; - Assert.AreEqual(7, children.Count); - Assert.AreEqual(" author ", children[2].ViewPath); - Assert.AreEqual("KBJ6N6Z8R2W3", children[2].NodeLabel); - } - [Test] public void WatchDictionaryByteValuesDisplaysCorrectly() { diff --git a/test/core/watch/WatchJSONObjectDisplaysCorrectly.dyn b/test/core/watch/WatchJSONObjectDisplaysCorrectly.dyn deleted file mode 100644 index 49af038c537..00000000000 --- a/test/core/watch/WatchJSONObjectDisplaysCorrectly.dyn +++ /dev/null @@ -1,203 +0,0 @@ -{ - "Uuid": "eab7724b-226e-40a7-ab9e-a0af83b3aaa6", - "IsCustomNode": false, - "Description": "", - "Name": "WatchJSONObjectDisplaysCorrectly", - "ElementResolver": { - "ResolutionMap": {} - }, - "Inputs": [], - "Outputs": [], - "Nodes": [ - { - "ConcreteType": "CoreNodeModels.FromArray, CoreNodeModels", - "Id": "3a51552c22684e50a0ebedc704d1a55b", - "NodeType": "ExtensionNode", - "Inputs": [ - { - "Id": "82be642c760e42e4aa46c67f9ae13fb3", - "Name": "array", - "Description": "The array of object to be serialized", - "UsingDefaultValue": false, - "Level": 2, - "UseLevels": false, - "KeepListStructure": false - } - ], - "Outputs": [ - { - "Id": "b5802e2494274a6fbd74fee257b0c4c7", - "Name": "string", - "Description": "String representation of the array", - "UsingDefaultValue": false, - "Level": 2, - "UseLevels": false, - "KeepListStructure": false - } - ], - "Replication": "Disabled", - "Description": "Converts an array to a string representation" - }, - { - "ConcreteType": "CoreNodeModels.Watch, CoreNodeModels", - "WatchWidth": 200.0, - "WatchHeight": 200.0, - "Id": "377fd521122542619135cbfbe0466eed", - "NodeType": "ExtensionNode", - "Inputs": [ - { - "Id": "649439737ccd434ca0691c896a8a8e0d", - "Name": "", - "Description": "Node to show output from", - "UsingDefaultValue": false, - "Level": 2, - "UseLevels": false, - "KeepListStructure": false - } - ], - "Outputs": [ - { - "Id": "b2af9691e3ad4c108410c6c1b86e7ac4", - "Name": "", - "Description": "Node output", - "UsingDefaultValue": false, - "Level": 2, - "UseLevels": false, - "KeepListStructure": false - } - ], - "Replication": "Disabled", - "Description": "Visualizes a node's output" - }, - { - "ConcreteType": "CoreNodeModels.Remember, CoreNodeModels", - "Cache": "[{\"virtual\":true,\"category\":\"annotation_label\",\"annotation_label\":{\"text\":\"Tower\",\"color\":\"#222933\",\"author\":\"KBJ6N6Z8R2W3\",\"opacity\":1,\"editedAt\":1736470185590,\"textAlign\":\"start\",\"labelOffset\":{\"x\":0,\"y\":-40}}}]", - "Id": "271c07b4cd4b41938e50cfda285b0053", - "NodeType": "ExtensionNode", - "Inputs": [ - { - "Id": "be460b0e15eb48ffb51b492713f503c5", - "Name": ">", - "Description": "Data to sample and store in the file.", - "UsingDefaultValue": false, - "Level": 2, - "UseLevels": false, - "KeepListStructure": false - } - ], - "Outputs": [ - { - "Id": "8e14610110f440e1aea481559c2233b6", - "Name": ">", - "Description": "Data", - "UsingDefaultValue": false, - "Level": 2, - "UseLevels": false, - "KeepListStructure": false - } - ], - "Replication": "Disabled", - "Description": "Store data passing through this node to the Dynamo file. Return the stored data if the input is null." - } - ], - "Connectors": [ - { - "Start": "8e14610110f440e1aea481559c2233b6", - "End": "82be642c760e42e4aa46c67f9ae13fb3", - "Id": "5f5ff4a0f50e46aab62e37766cb4118f", - "IsHidden": "False" - }, - { - "Start": "8e14610110f440e1aea481559c2233b6", - "End": "649439737ccd434ca0691c896a8a8e0d", - "Id": "b1aee35a552c4b54b95bd02254e578ea", - "IsHidden": "False" - } - ], - "Dependencies": [], - "NodeLibraryDependencies": [], - "EnableLegacyPolyCurveBehavior": true, - "Thumbnail": "", - "GraphDocumentationURL": null, - "ExtensionWorkspaceData": [ - { - "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", - "Name": "Properties", - "Version": "2.19", - "Data": {} - }, - { - "ExtensionGuid": "DFBD9CC0-DB40-457A-939E-8C8555555A9D", - "Name": "Generative Design", - "Version": "6.1", - "Data": {} - } - ], - "Author": "", - "Linting": { - "activeLinter": "None", - "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", - "warningCount": 0, - "errorCount": 0 - }, - "Bindings": [], - "View": { - "Dynamo": { - "ScaleFactor": 1.0, - "HasRunWithoutCrash": true, - "IsVisibleInDynamoLibrary": true, - "Version": "3.5.0.6885", - "RunType": "Manual", - "RunPeriod": "1000" - }, - "Camera": { - "Name": "_Background Preview", - "EyeX": -17.0, - "EyeY": 24.0, - "EyeZ": 50.0, - "LookX": 12.0, - "LookY": -13.0, - "LookZ": -58.0, - "UpX": 0.0, - "UpY": 1.0, - "UpZ": 0.0 - }, - "ConnectorPins": [], - "NodeViews": [ - { - "Id": "3a51552c22684e50a0ebedc704d1a55b", - "Name": "String from Array", - "IsSetAsInput": false, - "IsSetAsOutput": false, - "Excluded": false, - "ShowGeometry": true, - "X": 756.7069686704383, - "Y": 191.5204806357242 - }, - { - "Id": "377fd521122542619135cbfbe0466eed", - "Name": "Watch", - "IsSetAsInput": false, - "IsSetAsOutput": false, - "Excluded": false, - "ShowGeometry": true, - "X": 888.0915115605001, - "Y": 479.8711178846082 - }, - { - "Id": "271c07b4cd4b41938e50cfda285b0053", - "Name": "Remember", - "IsSetAsInput": false, - "IsSetAsOutput": false, - "Excluded": false, - "ShowGeometry": true, - "X": 503.90696867043835, - "Y": 504.5204806357242 - } - ], - "Annotations": [], - "X": -16.863020776903483, - "Y": -105.58990750948362, - "Zoom": 0.7344365364544645 - } -} \ No newline at end of file From daa15f2dd546a4957f829fd453bf5593ca8f24bf Mon Sep 17 00:00:00 2001 From: Aparajit Pratap Date: Tue, 14 Jan 2025 10:05:50 -0500 Subject: [PATCH 8/9] rename nodes --- test/DynamoCoreWpfTests/WatchNodeTests.cs | 2 +- test/Engine/FFITarget/DummyZeroTouchClass.cs | 8 +- ...hDictionaryByteValuesDisplaysCorrectly.dyn | 22 ++--- ...hDictionaryJSONValuesDisplaysCorrectly.dyn | 70 +++++++-------- ...hDictionaryUintValuesDisplaysCorrectly.dyn | 88 +++++++++---------- 5 files changed, 95 insertions(+), 95 deletions(-) diff --git a/test/DynamoCoreWpfTests/WatchNodeTests.cs b/test/DynamoCoreWpfTests/WatchNodeTests.cs index c11ea86eb76..e20ae2387c1 100644 --- a/test/DynamoCoreWpfTests/WatchNodeTests.cs +++ b/test/DynamoCoreWpfTests/WatchNodeTests.cs @@ -405,7 +405,7 @@ public void WatchDictionaryUintValuesDisplaysCorrectly() Assert.AreEqual("UInt32", children[0].ValueType); Assert.AreEqual("3", children[2].NodeLabel); - var uint64node = ViewModel.Model.CurrentWorkspace.GetDSFunctionNodeFromWorkspace("DummyZeroTouchClass.DecodeToUint64Dictionary"); + var uint64node = ViewModel.Model.CurrentWorkspace.GetDSFunctionNodeFromWorkspace("DummyZeroTouchClass.PreviewUint64Dictionary"); var vm = ViewModel.WatchHandler.GenerateWatchViewModelForData( uint64node.CachedValue, watchNode.OutPorts.Select(p => p.Name), ViewModel.Model.EngineController.LiveRunnerRuntimeCore, diff --git a/test/Engine/FFITarget/DummyZeroTouchClass.cs b/test/Engine/FFITarget/DummyZeroTouchClass.cs index 039875bbda2..a4d1f421221 100644 --- a/test/Engine/FFITarget/DummyZeroTouchClass.cs +++ b/test/Engine/FFITarget/DummyZeroTouchClass.cs @@ -19,7 +19,7 @@ public int FunctionWithoutDescription(int a) return 0; } - public static Dictionary DecodeToByteDictionary() + public static Dictionary PreviewByteDictionary() { // Example base64 encoded string string encodedString = "SGVsbG8gV29ybGQh"; @@ -31,7 +31,7 @@ public static Dictionary DecodeToByteDictionary() return result; } - public static Dictionary DecodeToUint32Dictionary() + public static Dictionary PreviewUint32Dictionary() { var uintArray = new uint[] { 1, 2, 3, 4, 5 }; var result = new Dictionary(); @@ -40,7 +40,7 @@ public static Dictionary DecodeToUint32Dictionary() return result; } - public static Dictionary DecodeToUint64Dictionary() + public static Dictionary PreviewUint64Dictionary() { var uintArray = new ulong[] { 1, 2, 3, 4, 5 }; var result = new Dictionary(); @@ -49,7 +49,7 @@ public static Dictionary DecodeToUint64Dictionary() return result; } - public static Dictionary DecodeToJSONDictionary() + public static Dictionary PreviewJSONDictionary() { var json = new JObject(); json.Add("key1", "value1"); diff --git a/test/core/watch/WatchDictionaryByteValuesDisplaysCorrectly.dyn b/test/core/watch/WatchDictionaryByteValuesDisplaysCorrectly.dyn index dd10becf48f..107211068dd 100644 --- a/test/core/watch/WatchDictionaryByteValuesDisplaysCorrectly.dyn +++ b/test/core/watch/WatchDictionaryByteValuesDisplaysCorrectly.dyn @@ -42,12 +42,12 @@ }, { "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", - "Id": "1590b6b5eec749978ede96d3e3f794e6", + "Id": "95889388fba84e11bc8905dcf80c10ea", "NodeType": "FunctionNode", "Inputs": [], "Outputs": [ { - "Id": "661d3132a5df4bbaae2dc74ccdbd562f", + "Id": "19ff13f87d5d4ac28736af66e0a80e0b", "Name": "var[]..[]", "Description": "var[]..[]", "UsingDefaultValue": false, @@ -56,16 +56,16 @@ "KeepListStructure": false } ], - "FunctionSignature": "FFITarget.DummyZeroTouchClass.DecodeToByteDictionary", + "FunctionSignature": "FFITarget.DummyZeroTouchClass.PreviewByteDictionary", "Replication": "Auto", - "Description": "DummyZeroTouchClass.DecodeToByteDictionary ( ): var[]..[]" + "Description": "DummyZeroTouchClass.PreviewByteDictionary ( ): var[]..[]" } ], "Connectors": [ { - "Start": "661d3132a5df4bbaae2dc74ccdbd562f", + "Start": "19ff13f87d5d4ac28736af66e0a80e0b", "End": "3f76a802ad484a90b7a466783baad45a", - "Id": "0a3e7eb777b243b3819acbdb41346e7b", + "Id": "35653deefde54d4297e35836f25c4282", "IsHidden": "False" } ], @@ -75,7 +75,7 @@ "Name": "FFITarget.dll", "ReferenceType": "ZeroTouch", "Nodes": [ - "1590b6b5eec749978ede96d3e3f794e6" + "95889388fba84e11bc8905dcf80c10ea" ] } ], @@ -132,14 +132,14 @@ "Y": 134.0 }, { - "Id": "1590b6b5eec749978ede96d3e3f794e6", - "Name": "DummyZeroTouchClass.DecodeToByteDictionary", + "Id": "95889388fba84e11bc8905dcf80c10ea", + "Name": "DummyZeroTouchClass.PreviewByteDictionary", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, - "X": 70.40000000000003, - "Y": 416.00000000000006 + "X": 78.00000000000006, + "Y": 363.2 } ], "Annotations": [], diff --git a/test/core/watch/WatchDictionaryJSONValuesDisplaysCorrectly.dyn b/test/core/watch/WatchDictionaryJSONValuesDisplaysCorrectly.dyn index 17e53dc3a00..971382e7455 100644 --- a/test/core/watch/WatchDictionaryJSONValuesDisplaysCorrectly.dyn +++ b/test/core/watch/WatchDictionaryJSONValuesDisplaysCorrectly.dyn @@ -9,15 +9,35 @@ "Inputs": [], "Outputs": [], "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "Id": "8246737ac9fe4734bec2dc1e03edf5b3", + "NodeType": "FunctionNode", + "Inputs": [], + "Outputs": [ + { + "Id": "466559bf56254b1dbd8eabbb0e268a3b", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "FunctionSignature": "FFITarget.DummyZeroTouchClass.PreviewJSONDictionary", + "Replication": "Auto", + "Description": "DummyZeroTouchClass.PreviewJSONDictionary ( ): var[]..[]" + }, { "ConcreteType": "CoreNodeModels.Watch, CoreNodeModels", "WatchWidth": 200.0, "WatchHeight": 200.0, - "Id": "7e16a76e05f140f2b3c9f105a402eba5", + "Id": "4b9d2903cc064ae3a06f7acc38be558e", "NodeType": "ExtensionNode", "Inputs": [ { - "Id": "5edfedb097ba41f4b91a3e7d9c200403", + "Id": "5000cb01edf64754a616d5df4daea236", "Name": "", "Description": "Node to show output from", "UsingDefaultValue": false, @@ -28,7 +48,7 @@ ], "Outputs": [ { - "Id": "b03dcd8f66234e4a8c9b4f0a425c1215", + "Id": "3270aefb6c6a4b85b4d478681db49a9b", "Name": "", "Description": "Node output", "UsingDefaultValue": false, @@ -39,33 +59,13 @@ ], "Replication": "Disabled", "Description": "Visualizes a node's output" - }, - { - "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", - "Id": "4f6e6a98bbce4e299b5a464f7d6f4a0d", - "NodeType": "FunctionNode", - "Inputs": [], - "Outputs": [ - { - "Id": "081f421cf35c446d8286198718fdec57", - "Name": "var[]..[]", - "Description": "var[]..[]", - "UsingDefaultValue": false, - "Level": 2, - "UseLevels": false, - "KeepListStructure": false - } - ], - "FunctionSignature": "FFITarget.DummyZeroTouchClass.DecodeToJSONDictionary", - "Replication": "Auto", - "Description": "DummyZeroTouchClass.DecodeToJSONDictionary ( ): var[]..[]" } ], "Connectors": [ { - "Start": "081f421cf35c446d8286198718fdec57", - "End": "5edfedb097ba41f4b91a3e7d9c200403", - "Id": "61c671a95e28452684392e434b501af8", + "Start": "466559bf56254b1dbd8eabbb0e268a3b", + "End": "5000cb01edf64754a616d5df4daea236", + "Id": "5dbe3adc97154ee0a5118b5bc835bd01", "IsHidden": "False" } ], @@ -75,7 +75,7 @@ "Name": "FFITarget.dll", "ReferenceType": "ZeroTouch", "Nodes": [ - "4f6e6a98bbce4e299b5a464f7d6f4a0d" + "8246737ac9fe4734bec2dc1e03edf5b3" ] } ], @@ -122,24 +122,24 @@ "ConnectorPins": [], "NodeViews": [ { - "Id": "7e16a76e05f140f2b3c9f105a402eba5", - "Name": "Watch", + "Id": "8246737ac9fe4734bec2dc1e03edf5b3", + "Name": "DummyZeroTouchClass.PreviewJSONDictionary", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, - "X": 558.0000000000003, - "Y": 134.0 + "X": 49.200000000000045, + "Y": 378.40000000000003 }, { - "Id": "4f6e6a98bbce4e299b5a464f7d6f4a0d", - "Name": "DummyZeroTouchClass.DecodeToJSONDictionary", + "Id": "4b9d2903cc064ae3a06f7acc38be558e", + "Name": "Watch", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, - "X": 46.39999999999998, - "Y": 149.2 + "X": 596.4000000000001, + "Y": 298.40000000000003 } ], "Annotations": [], diff --git a/test/core/watch/WatchDictionaryUintValuesDisplaysCorrectly.dyn b/test/core/watch/WatchDictionaryUintValuesDisplaysCorrectly.dyn index 0547eaa37fb..9b02ec0eaff 100644 --- a/test/core/watch/WatchDictionaryUintValuesDisplaysCorrectly.dyn +++ b/test/core/watch/WatchDictionaryUintValuesDisplaysCorrectly.dyn @@ -11,12 +11,12 @@ "Nodes": [ { "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", - "Id": "323e1fa982d44e28994147ca1d3ab92a", + "Id": "8d612f62bebf419589a97630e5e73b3a", "NodeType": "FunctionNode", "Inputs": [], "Outputs": [ { - "Id": "652af580d4e54c67ab6b77e33a615c89", + "Id": "7913bacafb0f40ee98667b04201f9df6", "Name": "var[]..[]", "Description": "var[]..[]", "UsingDefaultValue": false, @@ -25,19 +25,39 @@ "KeepListStructure": false } ], - "FunctionSignature": "FFITarget.DummyZeroTouchClass.DecodeToUint32Dictionary", + "FunctionSignature": "FFITarget.DummyZeroTouchClass.PreviewUint32Dictionary", "Replication": "Auto", - "Description": "DummyZeroTouchClass.DecodeToUint32Dictionary ( ): var[]..[]" + "Description": "DummyZeroTouchClass.PreviewUint32Dictionary ( ): var[]..[]" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "Id": "17acde4c2c694eb89899762b354f43c1", + "NodeType": "FunctionNode", + "Inputs": [], + "Outputs": [ + { + "Id": "d9441f516a66418cb13ea4821e5507a2", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "FunctionSignature": "FFITarget.DummyZeroTouchClass.PreviewUint64Dictionary", + "Replication": "Auto", + "Description": "DummyZeroTouchClass.PreviewUint64Dictionary ( ): var[]..[]" }, { "ConcreteType": "CoreNodeModels.Watch, CoreNodeModels", "WatchWidth": 200.0, "WatchHeight": 200.0, - "Id": "9b8b6b2f0d7043389c77e60936da1153", + "Id": "a1bfb653f17646f29a61a04800c4f676", "NodeType": "ExtensionNode", "Inputs": [ { - "Id": "a28f58656c4e48e395d218f370d104ec", + "Id": "b094c0d545624c62b4672a37fcd67b5b", "Name": "", "Description": "Node to show output from", "UsingDefaultValue": false, @@ -48,7 +68,7 @@ ], "Outputs": [ { - "Id": "a4d6f3613d34421ca298fe5ebca40062", + "Id": "5e41ed049fb9415b951ce368b74f38de", "Name": "", "Description": "Node output", "UsingDefaultValue": false, @@ -59,33 +79,13 @@ ], "Replication": "Disabled", "Description": "Visualizes a node's output" - }, - { - "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", - "Id": "1c54f75b46ed441d8e2cb39d68e6ba06", - "NodeType": "FunctionNode", - "Inputs": [], - "Outputs": [ - { - "Id": "c1cb61dc2b4e48e99f6ee50e710ea411", - "Name": "var[]..[]", - "Description": "var[]..[]", - "UsingDefaultValue": false, - "Level": 2, - "UseLevels": false, - "KeepListStructure": false - } - ], - "FunctionSignature": "FFITarget.DummyZeroTouchClass.DecodeToUint64Dictionary", - "Replication": "Auto", - "Description": "DummyZeroTouchClass.DecodeToUint64Dictionary ( ): var[]..[]" } ], "Connectors": [ { - "Start": "652af580d4e54c67ab6b77e33a615c89", - "End": "a28f58656c4e48e395d218f370d104ec", - "Id": "029069936ad54e278817548aa765b156", + "Start": "7913bacafb0f40ee98667b04201f9df6", + "End": "b094c0d545624c62b4672a37fcd67b5b", + "Id": "73ac3909d5884216b2acae31d21fbcc2", "IsHidden": "False" } ], @@ -95,8 +95,8 @@ "Name": "FFITarget.dll", "ReferenceType": "ZeroTouch", "Nodes": [ - "323e1fa982d44e28994147ca1d3ab92a", - "1c54f75b46ed441d8e2cb39d68e6ba06" + "8d612f62bebf419589a97630e5e73b3a", + "17acde4c2c694eb89899762b354f43c1" ] } ], @@ -143,34 +143,34 @@ "ConnectorPins": [], "NodeViews": [ { - "Id": "323e1fa982d44e28994147ca1d3ab92a", - "Name": "DummyZeroTouchClass.DecodeToUint32Dictionary", + "Id": "8d612f62bebf419589a97630e5e73b3a", + "Name": "DummyZeroTouchClass.PreviewUint32Dictionary", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, - "X": 38.799999999999955, - "Y": 73.60000000000007 + "X": 29.199999999999875, + "Y": 187.20000000000005 }, { - "Id": "9b8b6b2f0d7043389c77e60936da1153", - "Name": "Watch", + "Id": "17acde4c2c694eb89899762b354f43c1", + "Name": "DummyZeroTouchClass.PreviewUint64Dictionary", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, - "X": 657.6000000000001, - "Y": 39.20000000000003 + "X": 92.40000000000003, + "Y": 579.6 }, { - "Id": "1c54f75b46ed441d8e2cb39d68e6ba06", - "Name": "DummyZeroTouchClass.DecodeToUint64Dictionary", + "Id": "a1bfb653f17646f29a61a04800c4f676", + "Name": "Watch", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, - "X": 49.19999999999982, - "Y": 352.80000000000007 + "X": 560.4, + "Y": 185.20000000000005 } ], "Annotations": [], From 28b4f3d2915504fb1d9c2893303ab47f53dd3137 Mon Sep 17 00:00:00 2001 From: Aparajit Pratap Date: Tue, 14 Jan 2025 10:25:45 -0500 Subject: [PATCH 9/9] review comments --- src/DynamoCoreWpf/Interfaces/IWatchHandler.cs | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs b/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs index 824348a2d47..8c0b6af20dc 100644 --- a/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs +++ b/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs @@ -12,6 +12,7 @@ using ProtoCore.DSASM; using ProtoCore.Mirror; using ProtoCore.Utils; +using Newtonsoft.Json; namespace Dynamo.Interfaces { @@ -137,26 +138,21 @@ private WatchViewModel ProcessThing(object value, ProtoCore.RuntimeCore runtimeC private static Dictionary ConvertJObjectToDictionary(JObject jObject) { - var dictionary = new Dictionary(); - - foreach (var property in jObject.Properties()) + var settings = new JsonSerializerSettings { - if (property.Value is JObject nestedObject) - { - dictionary[property.Name] = ConvertJObjectToDictionary(nestedObject); - } - else if (property.Value is JArray nestedArray) - { - dictionary[property.Name] = nestedArray.ToObject>(); - } - else - { - dictionary[property.Name] = property.Value.ToObject(); - } - } + // Add any specific settings you need here + NullValueHandling = NullValueHandling.Ignore, + MissingMemberHandling = MissingMemberHandling.Ignore, + TypeNameHandling = TypeNameHandling.None + }; + + var json = jObject.ToString(); + var dictionary = JsonConvert.DeserializeObject>(json, settings); + return dictionary; } + private WatchViewModel ProcessThing(double value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback) { return new WatchViewModel(value, tag, RequestSelectGeometry);