Skip to content

Commit

Permalink
remove assembly name instances
Browse files Browse the repository at this point in the history
  • Loading branch information
dimven-adsk committed Jan 16, 2025
1 parent 0b11829 commit 3c66daf
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
17 changes: 10 additions & 7 deletions src/DynamoCore/Graph/Nodes/NodeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,18 +1223,21 @@ protected NodeModel(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPo
RaisesModificationEvents = true;
}


internal string cachedAsmName = null;

/// <summary>
/// The method returns the assembly name from which the node originated.
/// </summary>
/// <returns>Assembly Name</returns>
internal virtual AssemblyName GetNameOfAssemblyReferencedByNode()
internal virtual string GetNameOfAssemblyReferencedByNode()
{
AssemblyName assemblyName = null;

var assembly = this.GetType().Assembly;
assemblyName = AssemblyName.GetAssemblyName(assembly.Location);
return assemblyName;
if (string.IsNullOrEmpty(cachedAsmName))
{
cachedAsmName = GetType().Assembly.FullName;
}

return cachedAsmName;
}

/// <summary>
Expand Down
15 changes: 8 additions & 7 deletions src/DynamoCore/Graph/Nodes/ZeroTouch/DSFunctionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,18 @@ public override IdentifierNode GetAstIdentifierForOutputIndex(int outputIndex)
/// Only if the node was added from a package
/// </summary>
/// <returns>Assembly Name</returns>
internal override AssemblyName GetNameOfAssemblyReferencedByNode()
internal override string GetNameOfAssemblyReferencedByNode()
{
AssemblyName assemblyName = null;

var descriptor = this.Controller.Definition;
if (descriptor.IsPackageMember)
if (string.IsNullOrEmpty(cachedAsmName))
{
assemblyName = AssemblyName.GetAssemblyName(descriptor.Assembly);
var descriptor = this.Controller.Definition;
if (descriptor.IsPackageMember)
{
cachedAsmName = AssemblyName.GetAssemblyName(descriptor.Assembly).FullName;
}
}

return assemblyName;
return cachedAsmName;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCore/Graph/Workspaces/WorkspaceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ protected virtual void OnSaving(XmlDocument obj)
/// Event that is fired when the workspace is collecting node package dependencies.
/// This event should only be subscribed to by the package manager.
/// </summary>
internal event Func<AssemblyName, PackageInfo> CollectingNodePackageDependencies;
internal event Func<string, PackageInfo> CollectingNodePackageDependencies;

/// <summary>
/// This handler handles the workspaceModel's request to populate a JSON with view data.
Expand Down
7 changes: 4 additions & 3 deletions src/DynamoPackages/PackageManagerExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,13 @@ private void OnCurrentWorkspaceChanged(IWorkspaceModel ws)
}
}

private PackageInfo GetNodePackageFromAssemblyName(AssemblyName assemblyName)
private PackageInfo GetNodePackageFromAssemblyName(string assemblyName)
{
if (NodePackageDictionary != null && NodePackageDictionary.ContainsKey(assemblyName.FullName))
if (NodePackageDictionary?.TryGetValue(assemblyName, out var packages) == true)
{
return NodePackageDictionary[assemblyName.FullName].Last();
return packages.Last();
}

return null;
}

Expand Down
15 changes: 8 additions & 7 deletions src/Libraries/PythonNodeModels/PythonNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,18 @@ public string EngineName
/// The method returns the assembly name from which the node originated.
/// </summary>
/// <returns>Assembly Name</returns>
internal override AssemblyName GetNameOfAssemblyReferencedByNode()
internal override string GetNameOfAssemblyReferencedByNode()
{
AssemblyName assemblyName = null;

var pyEng = PythonEngineManager.Instance.AvailableEngines.Where(x => x.Name.Equals(this.EngineName)).FirstOrDefault();
if (pyEng != null)
if (string.IsNullOrEmpty(cachedAsmName))
{
assemblyName = AssemblyName.GetAssemblyName(pyEng.GetType().Assembly.Location);
var pyEng = PythonEngineManager.Instance.AvailableEngines.Where(x => x.Name.Equals(this.EngineName)).FirstOrDefault();
if (pyEng != null)
{
cachedAsmName = pyEng.GetType().Assembly.FullName;
}
}

return assemblyName;
return cachedAsmName;
}

/// <summary>
Expand Down

0 comments on commit 3c66daf

Please sign in to comment.