Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-6394: Add legacy trace warning when opening workspace #14628

Merged
merged 41 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
64b4706
remove coreclr-ncalc references
aparajit-pratap Aug 23, 2023
4a82ae7
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Aug 25, 2023
dbc3e12
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Aug 30, 2023
81ace20
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Aug 31, 2023
a7cafdc
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Sep 6, 2023
55c654d
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Sep 6, 2023
7ede2a4
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Sep 7, 2023
c43a02d
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Sep 8, 2023
1951d1a
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Sep 20, 2023
cd100b1
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Sep 21, 2023
c04c193
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Sep 25, 2023
35edbdb
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Oct 16, 2023
5c6a4a3
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Oct 18, 2023
1641149
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Oct 19, 2023
eff8d9b
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Oct 20, 2023
8415e17
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Oct 23, 2023
8a3368b
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Oct 30, 2023
3350614
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Nov 6, 2023
be0a127
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Nov 10, 2023
a3d62e9
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Nov 15, 2023
a3c806e
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Nov 17, 2023
e93499d
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap Nov 20, 2023
37d470c
show legacy trace warning
aparajit-pratap Nov 20, 2023
9c09ab3
cleanup
aparajit-pratap Nov 20, 2023
946e529
get workspace version correctly
aparajit-pratap Nov 20, 2023
5a9d878
update warning
aparajit-pratap Nov 20, 2023
1dd5c3c
add warning for xml DYNs
aparajit-pratap Nov 20, 2023
e26d682
add unit test
aparajit-pratap Nov 20, 2023
1b38c4d
cleanup
aparajit-pratap Nov 20, 2023
a2a6256
review comments
aparajit-pratap Nov 21, 2023
a39ae7f
Merge branch 'master' of github.com:DynamoDS/Dynamo into dyn-6394
aparajit-pratap Nov 22, 2023
77cc25d
update tests
aparajit-pratap Nov 22, 2023
16d50d4
revert test fixture change
aparajit-pratap Nov 22, 2023
2d96ffd
Merge branch 'master' of github.com:DynamoDS/Dynamo into dyn-6394
aparajit-pratap Nov 22, 2023
97d5987
refactor, add test
aparajit-pratap Nov 22, 2023
3e0cbd5
cleanup
aparajit-pratap Nov 22, 2023
d8e2dc2
rename
aparajit-pratap Nov 22, 2023
71eb83c
review comments
aparajit-pratap Nov 22, 2023
e5a56ed
update tests
aparajit-pratap Nov 27, 2023
456c20e
update tests
aparajit-pratap Nov 27, 2023
0c03faf
revert unchanged test file
aparajit-pratap Nov 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/DynamoCore/Engine/EngineController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using Dynamo.Engine.CodeCompletion;
using Dynamo.Engine.CodeGeneration;
using Dynamo.Engine.NodeToCode;
Expand All @@ -10,6 +9,7 @@
using Dynamo.Graph.Workspaces;
using Dynamo.Logging;
using Dynamo.Scheduler;
using Dynamo.Utilities;
using ProtoCore.AST.AssociativeAST;
using ProtoCore.DSASM.Mirror;
using ProtoCore.Mirror;
Expand Down Expand Up @@ -44,6 +44,11 @@ public class EngineController : LogSourceBase, IAstNodeContainer, IDisposable
/// </summary>
internal static event Action VMLibrariesReset;

/// <summary>
/// Dynamo version in which the current workspace was last created or modified.
/// </summary>
internal Version CurrentWorkspaceVersion { get; set; }

/// <summary>
/// This event is fired when <see cref="UpdateGraphAsyncTask"/> is completed.
/// </summary>
Expand Down Expand Up @@ -153,6 +158,8 @@ public EngineController(LibraryServices libraryServices, string geometryFactoryF
syncDataManager = new SyncDataManager();

VerboseLogging = verboseLogging;

CurrentWorkspaceVersion = AssemblyHelper.GetDynamoVersion();
}

/// <summary>
Expand Down
16 changes: 8 additions & 8 deletions src/DynamoCore/Graph/Nodes/NodeCategories.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -7,7 +7,6 @@
using System.Xml;
using Dynamo.Configuration;
using Dynamo.Engine;
using Dynamo.Graph.Nodes.CustomNodes;
using Dynamo.Library;
using ProtoCore;

Expand Down Expand Up @@ -282,7 +281,7 @@ internal static string GetDocumentXmlPath(XmlDocument document)
/// <returns>Returns a dictionary of deserialized node-data-list pairs
/// loaded from the given XmlDocument.</returns>
internal static IEnumerable<KeyValuePair<Guid, List<CallSite.RawTraceData>>>
LoadTraceDataFromXmlDocument(XmlDocument document)
LoadTraceDataFromXmlDocument(XmlDocument document, out bool containsLegacyTraceData)
{
if (document == null)
throw new ArgumentNullException("document");
Expand All @@ -301,7 +300,10 @@ where childNode.Name.Equals(sessionXmlTagName)

var loadedData = new Dictionary<Guid, List<CallSite.RawTraceData>>();
if (!query.Any()) // There's no data, return empty dictionary.
{
containsLegacyTraceData = false;
return loadedData;
}

XmlElement sessionElement = query.ElementAt(0);
foreach (XmlElement nodeElement in sessionElement.ChildNodes)
Expand All @@ -313,14 +315,12 @@ where childNode.Name.Equals(sessionXmlTagName)
var callsiteId = string.Empty;
if (child.HasAttribute(Configurations.CallSiteID))
{
callsiteId = child.GetAttribute(Configurations.CallSiteID);
containsLegacyTraceData = true;
return loadedData;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so now, we just return an empty list no matter what, but we make a note that there was at least 1 node with trace data?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed the variable from containsTraceData to containsLegacyTraceData to make it clearer. This flag is only used to trigger the toast notification when opening an old workspace.

var traceData = child.InnerText;
callsiteTraceData.Add(new CallSite.RawTraceData(callsiteId, traceData));
}
loadedData.Add(guid, callsiteTraceData);
}

containsLegacyTraceData = false;
return loadedData;
}

Expand Down
19 changes: 0 additions & 19 deletions src/DynamoCore/Graph/Workspaces/CustomNodeWorkspaceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Xml;
using Dynamo.Engine;
using Dynamo.Graph.Annotations;
using Dynamo.Graph.Nodes;
Expand Down Expand Up @@ -315,23 +314,5 @@ public override void Save(string newPath, bool isBackup = false, EngineControlle

base.Save(newPath, isBackup, engine);
}

[Obsolete("Method will be deprecated in Dynamo 3.0.")]
protected override bool PopulateXmlDocument(XmlDocument document)
{
if (!base.PopulateXmlDocument(document))
return false;

var root = document.DocumentElement;
if (root == null)
return false;

var guid = CustomNodeDefinition != null ? CustomNodeDefinition.FunctionId : Guid.NewGuid();
root.SetAttribute("ID", guid.ToString());
root.SetAttribute("Description", Description);
root.SetAttribute("Category", Category);

return true;
}
}
}
22 changes: 1 addition & 21 deletions src/DynamoCore/Graph/Workspaces/HomeWorkspaceModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.Xml;
using Dynamo.Core;
using Dynamo.Engine;
using Dynamo.Events;
Expand Down Expand Up @@ -664,24 +661,7 @@ internal void StopPeriodicEvaluation()
}

#endregion

[Obsolete("Method will be deprecated in Dynamo 3.0.")]
protected override bool PopulateXmlDocument(XmlDocument document)
{
if (!base.PopulateXmlDocument(document))
return false;

var root = document.DocumentElement;
if (root == null)
return false;

root.SetAttribute("RunType", RunSettings.RunType.ToString());
root.SetAttribute("RunPeriod", RunSettings.RunPeriod.ToString(CultureInfo.InvariantCulture));
root.SetAttribute("HasRunWithoutCrash", HasRunWithoutCrash.ToString(CultureInfo.InvariantCulture));

return true;
}


private void PulseMakerRunStarted()
{
var nodesToUpdate = Nodes.Where(n => n.CanUpdatePeriodically);
Expand Down
44 changes: 29 additions & 15 deletions src/DynamoCore/Graph/Workspaces/SerializationConverters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,27 +679,38 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
#region Restore trace data
// Trace Data
Dictionary<Guid, List<CallSite.RawTraceData>> loadedTraceData = new Dictionary<Guid, List<CallSite.RawTraceData>>();
bool containsLegacyTraceData = false;
// Restore trace data if bindings are present in json
if (obj["Bindings"] != null && obj["Bindings"].Children().Count() > 0)
{
JEnumerable<JToken> bindings = obj["Bindings"].Children();
var wrc = serializer.Converters.First(c => c is WorkspaceReadConverter) as WorkspaceReadConverter;

// Iterate through bindings to extract nodeID's and bindingData (callsiteId & traceData)
foreach (JToken entity in bindings)
if (wrc.engine.CurrentWorkspaceVersion < new Version(3, 0, 0))
{
Guid nodeId = Guid.Parse(entity["NodeId"].ToString());
string bindingString = entity["Binding"].ToString();

// Key(callsiteId) : Value(traceData)
Dictionary<string, string> bindingData = JsonConvert.DeserializeObject<Dictionary<string, string>>(bindingString);
List<CallSite.RawTraceData> callsiteTraceData = new List<CallSite.RawTraceData>();
containsLegacyTraceData = true;
}
else
{
JEnumerable<JToken> bindings = obj["Bindings"].Children();

foreach (KeyValuePair<string, string> pair in bindingData)
// Iterate through bindings to extract nodeID's and bindingData (callsiteId & traceData)
foreach (JToken entity in bindings)
{
callsiteTraceData.Add(new CallSite.RawTraceData(pair.Key, pair.Value));
}
Guid nodeId = Guid.Parse(entity["NodeId"].ToString());
string bindingString = entity["Binding"].ToString();

// Key(callsiteId) : Value(traceData)
Dictionary<string, string> bindingData =
JsonConvert.DeserializeObject<Dictionary<string, string>>(bindingString);
List<CallSite.RawTraceData> callsiteTraceData = new List<CallSite.RawTraceData>();

loadedTraceData.Add(nodeId, callsiteTraceData);
foreach (KeyValuePair<string, string> pair in bindingData)
{
callsiteTraceData.Add(new CallSite.RawTraceData(pair.Key, pair.Value));
}

loadedTraceData.Add(nodeId, callsiteTraceData);
}
}
}
#endregion
Expand All @@ -725,7 +736,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
if (obj.TryGetValue(nameof(HomeWorkspaceModel.Thumbnail), StringComparison.OrdinalIgnoreCase, out JToken thumbnail))
homeWorkspace.Thumbnail = thumbnail.ToString();

// GraphDocumentaionLink
// GraphDocumentationLink
if (obj.TryGetValue(nameof(HomeWorkspaceModel.GraphDocumentationURL), StringComparison.OrdinalIgnoreCase, out JToken helpLink))
{
if (Uri.TryCreate(helpLink.ToString(), UriKind.Absolute, out Uri uri))
Expand All @@ -738,6 +749,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
// If there is a active linter serialized in the graph we set it to the active linter else set the default None.
SetActiveLinter(obj);


ws = homeWorkspace;
}

Expand All @@ -746,7 +758,9 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
ws.ExternalFiles = externalFiles;
if (obj.TryGetValue(nameof(WorkspaceModel.Author), StringComparison.OrdinalIgnoreCase, out JToken author))
ws.Author = author.ToString();


ws.ContainsLegacyTraceData = containsLegacyTraceData;

return ws;
}

Expand Down
98 changes: 5 additions & 93 deletions src/DynamoCore/Graph/Workspaces/WorkspaceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Reflection;
using System.Threading;
using System.Xml;
using Dynamo.Configuration;
using Dynamo.Core;
using Dynamo.Engine;
using Dynamo.Engine.CodeGeneration;
Expand Down Expand Up @@ -233,6 +232,11 @@ internal int CurrentPasteOffset
}
}

/// <summary>
/// This is true only if the workspace contains legacy SOAP formatted binding data.
/// </summary>
internal bool ContainsLegacyTraceData { get; set; }
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved

internal bool ScaleFactorChanged = false;

/// <summary>
Expand Down Expand Up @@ -1280,9 +1284,6 @@ public Rect2D Rect
get { return new Rect2D(x, y, width, height); }
}

//TODO(Steve): This probably isn't needed inside of WorkspaceModel -- MAGN-5714
internal Version WorkspaceVersion { get; set; }

/// <summary>
/// Implements <see cref="ILocatable.CenterX"/> property.
/// </summary>
Expand Down Expand Up @@ -1372,7 +1373,6 @@ protected WorkspaceModel(
IsReadOnly = DynamoUtilities.PathHelper.IsReadOnlyPath(fileName);
LastSaved = DateTime.Now;

WorkspaceVersion = AssemblyHelper.GetDynamoVersion();
undoRecorder = new UndoRedoRecorder(this);

NodeFactory = factory;
Expand Down Expand Up @@ -2062,94 +2062,6 @@ private void SerializeElementResolver(XmlDocument xmlDoc)
root.AppendChild(mapElement);
}

[Obsolete("Method will be deprecated in Dynamo 3.0.")]
protected virtual bool PopulateXmlDocument(XmlDocument xmlDoc)
{
try
{
var root = xmlDoc.DocumentElement;
root.SetAttribute("Version", WorkspaceVersion.ToString());
root.SetAttribute("X", X.ToString(CultureInfo.InvariantCulture));
root.SetAttribute("Y", Y.ToString(CultureInfo.InvariantCulture));
root.SetAttribute("ScaleFactor", ScaleFactor.ToString(CultureInfo.InvariantCulture));
root.SetAttribute("Name", Name);
root.SetAttribute("Description", Description);

SerializeElementResolver(xmlDoc);

var elementList = xmlDoc.CreateElement("Elements");
//write the root element
root.AppendChild(elementList);

foreach (var dynEl in Nodes.Select(el => el.Serialize(xmlDoc, SaveContext.Save)))
elementList.AppendChild(dynEl);

//write only the output connectors
var connectorList = xmlDoc.CreateElement("Connectors");
//write the root element
root.AppendChild(connectorList);

foreach (var el in Nodes)
{
foreach (var port in el.OutPorts)
{
foreach (
var c in
port.Connectors.Where(c => c.Start != null && c.End != null))
{
var connector = xmlDoc.CreateElement(c.GetType().ToString());
connectorList.AppendChild(connector);
connector.SetAttribute("start", c.Start.Owner.GUID.ToString());
connector.SetAttribute("start_index", c.Start.Index.ToString());
connector.SetAttribute("end", c.End.Owner.GUID.ToString());
connector.SetAttribute("end_index", c.End.Index.ToString());
connector.SetAttribute(nameof(ConnectorModel.IsHidden), c.IsHidden.ToString());

if (c.End.PortType == PortType.Input)
connector.SetAttribute("portType", "0");
}
}
}

//save the notes
var noteList = xmlDoc.CreateElement("Notes"); //write the root element
root.AppendChild(noteList);
foreach (var n in Notes)
{
var note = n.Serialize(xmlDoc, SaveContext.Save);
noteList.AppendChild(note);
}

//save the annotation
var annotationList = xmlDoc.CreateElement("Annotations");
root.AppendChild(annotationList);
foreach (var n in annotations)
{
var annotation = n.Serialize(xmlDoc, SaveContext.Save);
annotationList.AppendChild(annotation);
}

//save the presets into the dyn file as a seperate element on the root
var presetsElement = xmlDoc.CreateElement("Presets");
root.AppendChild(presetsElement);
foreach (var preset in Presets)
{
var presetState = preset.Serialize(xmlDoc, SaveContext.Save);
presetsElement.AppendChild(presetState);
}

OnSaving(xmlDoc);

return true;
}
catch (Exception ex)
{
Log(ex.Message);
Log(ex.StackTrace);
return false;
}
}

internal void SendModelEvent(Guid modelGuid, string eventName, int value)
{
var retrievedModel = GetModelInternal(modelGuid);
Expand Down
18 changes: 0 additions & 18 deletions src/DynamoCore/Migration/Migration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,24 +517,6 @@ internal static Version VersionFromString(string version)
return new Version(ver.Major, ver.Minor, ver.Build, 0);
}

/// <summary>
/// Call this method to obtain the version of current WorkspaceModel.
/// Note that the revision number is dropped as both "0.7.0.1234"
/// should be treated as the same version as "0.7.0.5678", and no file
/// migration should take place.
/// </summary>
/// <param name="workspace">The WorkspaceModel to get the Version from.
/// </param>
/// <returns>Returns the Version object representing the workspace
/// version with the revision set to 0.</returns>
///
internal static Version VersionFromWorkspace(WorkspaceModel workspace)
{
// Ignore revision number.
var ver = workspace.WorkspaceVersion;
return new Version(ver.Major, ver.Minor, ver.Build, 0);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used


/// <summary>
/// Call this method to determine if migration should take place
/// for the input DYN/DYF file based on the given version numbers.
Expand Down
Loading
Loading