-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PTAL] [WIP] DYN-1662: As a dynamo dev, I want to serialize what pack…
…ages are needed in a graph (#9723) * Add Extensions block to json * Serialize package manager data to new Extensions block * Added IPackage interface * Added IPackage interface * Added PackageDependencies property to workspace model * Added comments * Unsubscribe from workspace on dispose * Simplify CollectingAssembliesUsed * assemblyPackageDict uses AssemblyName objects instead of strings. Rename CollectingPackageDependencies -> CollectingLocalPackages. * NodeLibraries should be internal, not private * assemblyPackageDict uses AssemblyName.FullName * Use set for packageDependencies to avoid duplicates * Add some comments to assembly collection * AssemblyNames summary * Adds PackageDependency serialization support for custom nodes from packages * Rename GetCustomNodesPackagesFromGuids * Rename GetCustomNodesPackagesFromGuids * Add new PackageInfo class to replace IPackage for serialization * Remove IPackage * Move assembly name matching logic to PackageManager in order to remove AssemblyNames property from PackageInfo * Remove unnecessary * Fix AssemblyNames error * Null check for PackageInfo converter * Add obsolete attribute to events that should only be used by package manager * Use InternalsVisibleTo to ensure only PM extension can subscribe to package dependency events * Serialize IDs of nodes that are dependent on each package * Update package manager dictionary logic for package load and remove events * Fix Guid serialization * Add comment to InternalsVisibleTo * Name changes to make referencedAssembly use more clear * Add comments to Assembly collection and make more efficient * Comment added * Remove unnecessary ref * Removed Unecessary ref * Comment fixes * Rename PackageInfo -> PackageDependencyInfo * Use Version type for PackageDependencyInfo Version property * Rename Dependents -> Nodes * Move GetAssembliesReferencedByNodes * Added PackageDependency deserialization * Simplify if statement * Improve PackageDependencies update * PackageDependency deserialization null check * one line code improvements * IsNodeLibrary check * Remove unnecessary Any check * Add unsuccessful PackageDependencyInfo serialization log * Log message when node libraries or custom nodes are loaded by multiple packages * Improved RemovedNodes handling * Simplify descriptor lookup * Update comments * Store list of packages per assembly * Store list of packages per custom node id * Unsubscribe CurrentWorkspaceChanged * lock packageDependencies * Add NodePackageDictionary and CustomNodePackageDictionary null check * Move assembly collection to WorkspaceModel because LibraryServices no longer required * Remove white space * Add "PackageDependencies" item to test .dyn * Remove PackageDependencyInfo FullName property * Throw exception for illegal subscribers to PackageDependency events
- Loading branch information
1 parent
b2e585a
commit f6f43e2
Showing
8 changed files
with
544 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/DynamoCore/Graph/Workspaces/PackageDependencyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Dynamo.Graph.Workspaces | ||
{ | ||
/// <summary> | ||
/// Class containing info about a Dynamo package. | ||
/// Used for serialization. | ||
/// </summary> | ||
internal class PackageDependencyInfo | ||
{ | ||
/// <summary> | ||
/// Name of the package | ||
/// </summary> | ||
internal string Name { get; set; } | ||
|
||
/// <summary> | ||
/// Version of the package | ||
/// </summary> | ||
internal Version Version { get; set; } | ||
|
||
/// <summary> | ||
/// Guids of nodes in the workspace that are dependent on this package | ||
/// </summary> | ||
internal HashSet<Guid> Nodes | ||
{ | ||
get { return nodes; } | ||
} | ||
private HashSet<Guid> nodes; | ||
|
||
/// <summary> | ||
/// Create a package info object from the package name and version | ||
/// </summary> | ||
/// <param name="name"></param> | ||
/// <param name="version"></param> | ||
internal PackageDependencyInfo(string name, Version version) | ||
{ | ||
Name = name; | ||
Version = version; | ||
nodes = new HashSet<Guid>(); | ||
} | ||
|
||
/// <summary> | ||
/// Add the Guid of a dependent node | ||
/// </summary> | ||
/// <param name="guid"></param> | ||
internal void AddDependent(Guid guid) | ||
{ | ||
Nodes.Add(guid); | ||
} | ||
|
||
/// <summary> | ||
/// Add the Guids of a dependent nodes | ||
/// </summary> | ||
/// <param name="guids"></param> | ||
internal void AddDependents(IEnumerable<Guid> guids) | ||
{ | ||
foreach(var guid in guids) | ||
{ | ||
Nodes.Add(guid); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Remove a dependent node | ||
/// </summary> | ||
/// <param name="guid"></param> | ||
internal void RemoveDependent(Guid guid) | ||
{ | ||
Nodes.Remove(guid); | ||
} | ||
|
||
/// <summary> | ||
/// Checks whether two PackageDependencyInfos are equal | ||
/// They are equal if their Name and Versions are equal | ||
/// </summary> | ||
/// <param name="obj"></param> | ||
/// <returns></returns> | ||
public override bool Equals(object obj) | ||
{ | ||
if (obj == null) | ||
{ | ||
return false; | ||
} | ||
if (!(obj is PackageDependencyInfo)) | ||
{ | ||
return false; | ||
} | ||
|
||
var other = obj as PackageDependencyInfo; | ||
if (other.Name == this.Name && other.Version == this.Version) | ||
{ | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.