-
Notifications
You must be signed in to change notification settings - Fork 117
Description
In experimenting with transitioning to the MS feat mgmt schema, I added configuration for it under feature_management
(alongside existing configuration under FeatureManagement
).
In doing so, I noticed that GetFeatureNamesAsync
returned the name of that feature multiple times. That actually broke this code we had in one of our apps which surfaces all the flags in one go to an old UI:
var featureNamesEnumerable = _featureManager.GetFeatureNamesAsync();
await featureNamesEnumerable.ForEachAwaitAsync(async featureName =>
{
var isEnabled = await _featureManager.IsEnabledAsync(featureName);
featureFlags.Add(featureName, isEnabled);
});
(note, needs System.Linq.Async nuget package).
Given that IsEnabledAsync
digs into the provider and checks for MS Feature Mgmt schema config first, before falling back to the .NET Feature Mgmt schema config after, i.e. it doesn't matter that there's dupe config, it supports this, it feels a bit unexpected to see the feature name appear twice. Easy fix is:
var featureNamesEnumerable = _featureManager.GetFeatureNamesAsync().Distinct();
// ...
But wondering if it's worth doing that in the GetFeatureNamesAsync
implementation? Happy to submit a PR if that's approved, as I also need to submit my other PR for the MVC tag helper and can knock both PRs out in one go.