Skip to content

Commit

Permalink
Fix post error update to remove the non-pointer message
Browse files Browse the repository at this point in the history
  • Loading branch information
saintentropy committed Oct 22, 2023
1 parent 0dabf04 commit 62a489d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/DynamoUtilities/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
52 changes: 37 additions & 15 deletions src/Libraries/CoreNodeModels/Remember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Text;
using System.Threading.Tasks;
using VMDataBridge;
using System.Collections.Specialized;

namespace CoreNodeModels
{
Expand All @@ -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();
}
}
Expand All @@ -48,12 +49,14 @@ public string Cache
private Remember(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
{
PropertyChanged += OnPropertyChanged;
Infos.CollectionChanged += ProcessInfos;
}

public Remember()
{
RegisterAllPorts();
PropertyChanged += OnPropertyChanged;
Infos.CollectionChanged += ProcessInfos;
}

private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
Expand All @@ -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;
}
}

/// <summary>
/// Handle updating the error message to remove the non-pointer message.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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<Info> { };
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);
}
}

Expand All @@ -92,6 +112,8 @@ protected override void OnBuilt()

public override void Dispose()
{
PropertyChanged -= OnPropertyChanged;
Infos.CollectionChanged -= ProcessInfos;
base.Dispose();
DataBridge.Instance.UnregisterCallback(GUID.ToString());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/CoreNodes/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public static Dictionary<string, object> 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<string, object>
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/CoreNodes/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Libraries/CoreNodes/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
<value>The stored data can not be rebuilt.</value>
</data>
<data name="Exception_Serialize_Unsupported_Type" xml:space="preserve">
<value>Cannot store data for this input.</value>
<value>Cannot store data of type {0}.</value>
</data>
<data name="ExportToCSVObsolete" xml:space="preserve">
<value>Use Data.ExportCSV node instead</value>
Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/CoreNodes/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
<value>The stored data can not be rebuilt.</value>
</data>
<data name="Exception_Serialize_Unsupported_Type" xml:space="preserve">
<value>Cannot store data for this input.</value>
<value>Cannot store data of type {0}.</value>
</data>
<data name="ExportToCSVObsolete" xml:space="preserve">
<value>Use Data.ExportCSV node instead</value>
Expand Down

0 comments on commit 62a489d

Please sign in to comment.