Skip to content

Commit

Permalink
Ignore any explicit enable/disable 'EnabledByDependencyOnly' features (
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek committed Sep 3, 2022
1 parent 2b77d1c commit 4b7f286
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ public class ShellDescriptorFeaturesManager : IShellDescriptorFeaturesManager
var featureEventHandlers = ShellScope.Services.GetServices<IFeatureEventHandler>();

var enabledFeatures = _extensionManager.GetFeatures()
.Where(f => shellDescriptor.Features.Any(sf => sf.Id == f.Id))
.Where(feature => shellDescriptor.Features.Any(shellFeature => shellFeature.Id == feature.Id))
.ToArray();

var enabledFeatureIds = enabledFeatures
.Select(f => f.Id)
.Select(feature => feature.Id)
.ToHashSet();

var installedFeatureIds = enabledFeatureIds
.Concat(shellDescriptor.Installed.Select(sf => sf.Id))
.Concat(shellDescriptor.Installed.Select(shellFeature => shellFeature.Id))
.ToHashSet();

var alwaysEnabledIds = _alwaysEnabledFeatures.Select(sf => sf.Id).ToArray();
var alwaysEnabledIds = _alwaysEnabledFeatures.Select(shellFeature => shellFeature.Id).ToArray();

var byDependencyOnlyFeaturesToDisable = enabledFeatures
.Where(f => f.EnabledByDependencyOnly);
.Where(feature => feature.EnabledByDependencyOnly);

var allFeaturesToDisable = featuresToDisable
.Where(f => !alwaysEnabledIds.Contains(f.Id))
.Where(feature => !feature.EnabledByDependencyOnly && !alwaysEnabledIds.Contains(feature.Id))
.SelectMany(feature => GetFeaturesToDisable(feature, enabledFeatureIds, force))
// Always attempt to disable 'EnabledByDependencyOnly' features
// to ensure we auto disable any feature that is no longer needed.
Expand All @@ -76,6 +76,7 @@ public class ShellDescriptorFeaturesManager : IShellDescriptorFeaturesManager
}

var allFeaturesToEnable = featuresToEnable
.Where(feature => !feature.EnabledByDependencyOnly)
.SelectMany(feature => GetFeaturesToEnable(feature, enabledFeatureIds, force))
.Distinct()
.ToList();
Expand Down

0 comments on commit 4b7f286

Please sign in to comment.