From 7cbe479f53de73d0e9ce0d42090681593be6947e Mon Sep 17 00:00:00 2001 From: Martin Misol Monzo Date: Tue, 7 Apr 2020 14:26:18 -0400 Subject: [PATCH] Avoid duplication in package assembly list --- src/DynamoPackages/PackageLoader.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/DynamoPackages/PackageLoader.cs b/src/DynamoPackages/PackageLoader.cs index 3efea98297b..3048a09aaba 100644 --- a/src/DynamoPackages/PackageLoader.cs +++ b/src/DynamoPackages/PackageLoader.cs @@ -294,7 +294,7 @@ public void LoadAll(LoadPackageParams loadPackageParams) /// public void LoadPackages(IEnumerable packages) { - var enumerable = packages.ToList(); + var packageList = packages.ToList(); // This fix is in reference to the crash reported in task: https://jira.autodesk.com/browse/DYN-2101 // TODO: https://jira.autodesk.com/browse/DYN-2120. we will be re-evaluating this workflow, to find the best clean solution. @@ -308,7 +308,7 @@ public void LoadPackages(IEnumerable packages) // Disabling the run here since new packages are being loaded. EngineController.DisableRun = true; - foreach (var pkg in enumerable) + foreach (var pkg in packageList) { // If the pkg is null, then don't load that package into the Library. if (pkg != null) @@ -320,9 +320,11 @@ public void LoadPackages(IEnumerable packages) // Setting back the DisableRun property back to false, as the package loading is completed. EngineController.DisableRun = false; - var assemblies = - enumerable.SelectMany(x => x.EnumerateAssembliesInBinDirectory().Where(y => y.IsNodeLibrary)); - OnPackagesLoaded(assemblies.Select(x => x.Assembly)); + var assemblies = packageList + .SelectMany(p => p.LoadedAssemblies.Where(y => y.IsNodeLibrary)) + .Select(a => a.Assembly) + .ToList(); + OnPackagesLoaded(assemblies); } public void LoadCustomNodesAndPackages(LoadPackageParams loadPackageParams, CustomNodeManager customNodeManager)