From 62a489d117f13bea1e0b42d47142c8caeb8632b1 Mon Sep 17 00:00:00 2001 From: Craig Long Date: Sun, 22 Oct 2023 19:19:16 -0400 Subject: [PATCH] Fix post error update to remove the non-pointer message --- .../Properties/AssemblyInfo.cs | 1 + src/Libraries/CoreNodeModels/Remember.cs | 52 +++++++++++++------ src/Libraries/CoreNodes/Data.cs | 2 +- .../Properties/Resources.Designer.cs | 2 +- .../CoreNodes/Properties/Resources.en-US.resx | 2 +- .../CoreNodes/Properties/Resources.resx | 2 +- 6 files changed, 42 insertions(+), 19 deletions(-) diff --git a/src/DynamoUtilities/Properties/AssemblyInfo.cs b/src/DynamoUtilities/Properties/AssemblyInfo.cs index c3981334ac4..1bc1af79974 100644 --- a/src/DynamoUtilities/Properties/AssemblyInfo.cs +++ b/src/DynamoUtilities/Properties/AssemblyInfo.cs @@ -12,6 +12,7 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("fdd60a60-c6e4-4f11-b583-8a417061c043")] [assembly: InternalsVisibleTo("DynamoCore")] +[assembly: InternalsVisibleTo("CoreNodeModels")] [assembly: InternalsVisibleTo("DynamoCoreWpf")] [assembly: InternalsVisibleTo("DynamoCoreTests")] [assembly: InternalsVisibleTo("DynamoCoreWpfTests")] diff --git a/src/Libraries/CoreNodeModels/Remember.cs b/src/Libraries/CoreNodeModels/Remember.cs index e16bb376689..a84846e79e6 100644 --- a/src/Libraries/CoreNodeModels/Remember.cs +++ b/src/Libraries/CoreNodeModels/Remember.cs @@ -10,6 +10,7 @@ using System.Text; using System.Threading.Tasks; using VMDataBridge; +using System.Collections.Specialized; namespace CoreNodeModels { @@ -26,19 +27,19 @@ namespace CoreNodeModels [DynamoServices.RegisterForTrace] public class Remember : NodeModel { - private string _cache = ""; - private string _updatedToolTipText = ""; + private string cache = ""; + private string updatedMessage = ""; [JsonProperty("Cache")] public string Cache { - get { return _cache; } + get { return cache; } set { var valueToSet = value == null ? "" : value; - if (valueToSet != _cache) + if (valueToSet != cache) { - _cache = valueToSet; + cache = valueToSet; MarkNodeAsModified(); } } @@ -48,12 +49,14 @@ public string Cache private Remember(IEnumerable inPorts, IEnumerable outPorts) : base(inPorts, outPorts) { PropertyChanged += OnPropertyChanged; + Infos.CollectionChanged += ProcessInfos; } public Remember() { RegisterAllPorts(); PropertyChanged += OnPropertyChanged; + Infos.CollectionChanged += ProcessInfos; } private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) @@ -67,20 +70,37 @@ private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) } break; - case "ToolTipText": - if (State == ElementState.Warning && ToolTipText != _updatedToolTipText) + default: + // Nothing to handle + break; + } + } + + /// + /// Handle updating the error message to remove the non-pointer message. + /// + /// + /// + private void ProcessInfos(object sender, NotifyCollectionChangedEventArgs e) + { + if(Infos.Count == 0 || State != ElementState.Warning) return; + if(Infos.Any(x => x.State == ElementState.Warning && x.Message != updatedMessage)) + { + var infos = new List { }; + foreach (var info in Infos) + { + if (info.State == ElementState.Warning) { string[] errorMessages = - ToolTipText.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None); - _updatedToolTipText = errorMessages.Last(); - ToolTipText = _updatedToolTipText; + info.Message.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None); + updatedMessage = errorMessages.Last(); + + infos.Add(new Info(updatedMessage, ElementState.Warning)); } + } - break; - - default: - // Nothing to handle - break; + Infos.RemoveWhere(x => x.State == ElementState.Warning); + Infos.AddRange(infos); } } @@ -92,6 +112,8 @@ protected override void OnBuilt() public override void Dispose() { + PropertyChanged -= OnPropertyChanged; + Infos.CollectionChanged -= ProcessInfos; base.Dispose(); DataBridge.Instance.UnregisterCallback(GUID.ToString()); } diff --git a/src/Libraries/CoreNodes/Data.cs b/src/Libraries/CoreNodes/Data.cs index 08f0b1f4e5a..6391c3b7660 100644 --- a/src/Libraries/CoreNodes/Data.cs +++ b/src/Libraries/CoreNodes/Data.cs @@ -430,7 +430,7 @@ public static Dictionary Remember([ArbitraryDimensionArrayImport } catch(Exception ex) { - throw new NotSupportedException(Properties.Resources.Exception_Serialize_Unsupported_Type); + throw new NotSupportedException(string.Format(Properties.Resources.Exception_Serialize_Unsupported_Type, inputObject.GetType().FullName)); } return new Dictionary diff --git a/src/Libraries/CoreNodes/Properties/Resources.Designer.cs b/src/Libraries/CoreNodes/Properties/Resources.Designer.cs index d2b454c6d2c..96db1723081 100644 --- a/src/Libraries/CoreNodes/Properties/Resources.Designer.cs +++ b/src/Libraries/CoreNodes/Properties/Resources.Designer.cs @@ -142,7 +142,7 @@ internal static string Exception_Deserialize_Unsupported_Type { } /// - /// Looks up a localized string similar to Cannot store data for this input.. + /// Looks up a localized string similar to Cannot store data of type {0}.. /// internal static string Exception_Serialize_Unsupported_Type { get { diff --git a/src/Libraries/CoreNodes/Properties/Resources.en-US.resx b/src/Libraries/CoreNodes/Properties/Resources.en-US.resx index 4308c177269..dc1c3222e18 100644 --- a/src/Libraries/CoreNodes/Properties/Resources.en-US.resx +++ b/src/Libraries/CoreNodes/Properties/Resources.en-US.resx @@ -145,7 +145,7 @@ The stored data can not be rebuilt. - Cannot store data for this input. + Cannot store data of type {0}. Use Data.ExportCSV node instead diff --git a/src/Libraries/CoreNodes/Properties/Resources.resx b/src/Libraries/CoreNodes/Properties/Resources.resx index 3b53c70733e..43b8b5490c4 100644 --- a/src/Libraries/CoreNodes/Properties/Resources.resx +++ b/src/Libraries/CoreNodes/Properties/Resources.resx @@ -145,7 +145,7 @@ The stored data can not be rebuilt. - Cannot store data for this input. + Cannot store data of type {0}. Use Data.ExportCSV node instead