-
Notifications
You must be signed in to change notification settings - Fork 638
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-2149 DummyNode unresolved node messages are confusing #10051
Changes from 2 commits
759041c
d983d58
a8c992f
d14b311
69d0cab
2de8a87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ public DummyNode() | |
LegacyNodeName = "Dynamo.Graph.Nodes.DummyNode"; | ||
LegacyFullName = LegacyNodeName; | ||
LegacyAssembly = string.Empty; | ||
FunctionName = string.Empty; | ||
NodeNature = Nature.Unresolved; | ||
Description = GetDescription(); | ||
ShouldDisplayPreviewCore = false; | ||
|
@@ -142,6 +143,52 @@ public DummyNode( | |
UpdatePorts(); | ||
} | ||
|
||
/// <summary> | ||
/// This function creates DummyNode with specified number of ports. | ||
/// </summary> | ||
/// <param name="id">Id of the original node</param> | ||
/// <param name="inputCount">Number of input ports</param> | ||
/// <param name="outputCount">Number of output ports</param> | ||
/// <param name="legacyAssembly">Assembly of the node</param> | ||
/// <param name="functionName">Function name of the node</param> | ||
/// <param name="originalElement">Original JSON description of the node</param> | ||
public DummyNode( | ||
string id, | ||
int inputCount, | ||
int outputCount, | ||
string legacyAssembly, | ||
string functionName, | ||
JObject originalElement) | ||
{ | ||
GUID = new Guid(id); | ||
|
||
InputCount = inputCount; | ||
OutputCount = outputCount; | ||
|
||
string legacyName = "Unresolved"; | ||
LegacyNodeName = legacyName; | ||
LegacyFullName = legacyName; | ||
Name = legacyName; | ||
FunctionName = functionName; | ||
|
||
OriginalNodeContent = originalElement; | ||
|
||
LegacyAssembly = legacyAssembly; | ||
NodeNature = DummyNode.Nature.Unresolved; | ||
|
||
Description = GetDescription(); | ||
ShouldDisplayPreviewCore = false; | ||
|
||
if (originalElement != null) | ||
{ | ||
var legacyFullName = originalElement["FunctionSignature"]; | ||
if (legacyFullName != null) | ||
LegacyFullName = legacyFullName.ToString(); | ||
} | ||
|
||
UpdatePorts(); | ||
} | ||
|
||
private void LoadNode(XmlNode nodeElement) | ||
{ | ||
XmlElement originalElement = OriginalXmlNodeContent; | ||
|
@@ -320,29 +367,29 @@ internal string GetDescription() | |
{ | ||
if (NodeNature == Nature.Deprecated) | ||
{ | ||
if (string.IsNullOrEmpty(LegacyAssembly)) | ||
if (string.IsNullOrEmpty(FunctionName)) | ||
{ | ||
const string format = "Node of type '{0}' is now deprecated"; | ||
return string.Format(format, LegacyNodeName); | ||
const string format = "Node from assembly '{0}' is now deprecated."; | ||
return string.Format(format, LegacyAssembly); | ||
} | ||
else | ||
{ | ||
const string format = "Node of type '{0}' ({1}) is now deprecated"; | ||
return string.Format(format, LegacyNodeName, LegacyAssembly); | ||
const string format = "Node '{0}' is now deprecated"; | ||
return string.Format(format, FunctionName); | ||
} | ||
} | ||
|
||
if (NodeNature == Nature.Unresolved) | ||
{ | ||
if (string.IsNullOrEmpty(LegacyAssembly)) | ||
if (string.IsNullOrEmpty(FunctionName)) | ||
{ | ||
const string format = "Node of type '{0}' cannot be resolved"; | ||
return string.Format(format, LegacyNodeName); | ||
const string format = "Node from assembly '{0}' cannot be resolved."; | ||
return string.Format(format, LegacyAssembly); | ||
} | ||
else | ||
{ | ||
const string format = "Node of type '{0}' ({1}) cannot be resolved"; | ||
return string.Format(format, LegacyNodeName, LegacyAssembly); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is |
||
const string format = "Node '{0}' cannot be resolved."; | ||
return string.Format(format, FunctionName); | ||
} | ||
} | ||
|
||
|
@@ -370,6 +417,11 @@ internal string GetDescription() | |
/// </summary> | ||
public string LegacyAssembly { get; private set; } | ||
|
||
/// <summary> | ||
/// Returns the node's function name | ||
/// </summary> | ||
public string FunctionName { get; private set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any reason not to overload the LegacyNodeName - maybe note that this is property is only valid for ZeroTouch dummy nodes? |
||
|
||
/// <summary> | ||
/// Returns the original node DSFunction description or UI node type | ||
/// </summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,11 +96,28 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist | |
{ | ||
NodeModel node = null; | ||
|
||
String typeName = String.Empty; | ||
String functionName = String.Empty; | ||
String assemblyName = String.Empty; | ||
|
||
var obj = JObject.Load(reader); | ||
Type type = null; | ||
|
||
try | ||
{ | ||
type = Type.GetType(obj["$type"].Value<string>()); | ||
typeName = obj["$type"].Value<string>().Split(',').FirstOrDefault(); | ||
|
||
if (typeName.Contains("ZeroTouch")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we be specific about this- it's possible anyone could make a nodeModel and name it |
||
{ | ||
// If it is a zero touch node, then get the whole function name including the namespace. | ||
functionName = obj["FunctionSignature"].Value<string>().Split('@').FirstOrDefault().Trim(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do FunctionSignatures always have the |
||
} | ||
// we get the assembly name from the type string for the node model nodes. | ||
else | ||
{ | ||
assemblyName = obj["$type"].Value<string>().Split(',').Skip(1).FirstOrDefault().Trim(); | ||
} | ||
} | ||
catch(Exception e) | ||
{ | ||
|
@@ -115,9 +132,8 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist | |
{ | ||
List<Assembly> resultList; | ||
|
||
var typeName = obj["$type"].Value<string>().Split(',').FirstOrDefault(); | ||
// This assemblyName does not usually contain version information... | ||
var assemblyName = obj["$type"].Value<string>().Split(',').Skip(1).FirstOrDefault().Trim(); | ||
assemblyName = obj["$type"].Value<string>().Split(',').Skip(1).FirstOrDefault().Trim(); | ||
if (assemblyName != null) | ||
{ | ||
if(this.loadedAssemblies.TryGetValue(assemblyName, out resultList)) | ||
|
@@ -159,7 +175,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist | |
// If type is still null at this point return a dummy node | ||
if (type == null) | ||
{ | ||
node = CreateDummyNode(obj, assemblyLocation, inPorts, outPorts); | ||
node = CreateDummyNode(obj, assemblyName, functionName, inPorts, outPorts); | ||
} | ||
// Attempt to create a valid node using the type | ||
else if (type == typeof(Function)) | ||
|
@@ -223,7 +239,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist | |
// Use the functionDescriptor to try and restore the proper node if possible | ||
if (functionDescriptor == null) | ||
{ | ||
node = CreateDummyNode(obj, assemblyLocation, inPorts, outPorts); | ||
node = CreateDummyNode(obj, assemblyName, functionName, inPorts, outPorts); | ||
} | ||
else | ||
{ | ||
|
@@ -286,7 +302,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist | |
return node; | ||
} | ||
|
||
private DummyNode CreateDummyNode(JObject obj, string assemblyLocation, PortModel[] inPorts, PortModel[] outPorts) | ||
private DummyNode CreateDummyNode(JObject obj, string legacyAssembly, string functionName, PortModel[] inPorts, PortModel[] outPorts) | ||
{ | ||
var inputcount = inPorts.Count(); | ||
var outputcount = outPorts.Count(); | ||
|
@@ -295,7 +311,8 @@ private DummyNode CreateDummyNode(JObject obj, string assemblyLocation, PortMode | |
obj["Id"].ToString(), | ||
inputcount, | ||
outputcount, | ||
assemblyLocation, | ||
legacyAssembly, | ||
functionName, | ||
obj); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mjkkirschner @aparajit-pratap I cant remember, do we localize node names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just found out that we do not localize node names, so we should be fine here