Skip to content

Commit

Permalink
Avoid duplication in package assembly list
Browse files Browse the repository at this point in the history
  • Loading branch information
mmisol committed Apr 7, 2020
1 parent 533c3f7 commit 7cbe479
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/DynamoPackages/PackageLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public void LoadAll(LoadPackageParams loadPackageParams)
/// <param name="packages"></param>
public void LoadPackages(IEnumerable<Package> 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.
Expand All @@ -308,7 +308,7 @@ public void LoadPackages(IEnumerable<Package> 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)
Expand All @@ -320,9 +320,11 @@ public void LoadPackages(IEnumerable<Package> 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)
Expand Down

0 comments on commit 7cbe479

Please sign in to comment.