microsoft/FeatureManagement-Dotnet

builder.Services.AddFeatureManagement() with configuration section does not work since v3.0.0

Closed this issue · 7 comments

I know that there was a breaking change in v3.0.0 created by #261, but I feel like that should not affect the use case of targeting the configuration section to use in the appsettings.json file.

For example, with this configuration file:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "FeatureFlags": {
    "PushFeatureEnabled": true,
    "PutFeatureEnabled": true
  }
}

and this program.cs line:

builder.Services.AddFeatureManagement(builder.Configuration.GetSection("FeatureFlags"));

var app = builder.Build();

the feature manager does not load our feature flags like it did in 2.6.0. If we're not allowed to set our own configuration section, it should no be a possible parameter or at least raise a deprecated warning

@FredericVaugeoisFlo I think this should be an oversight. Thanks for calling it out.
The override method AddFeatureManagement(configuration) should support your scenario. Otherwise, I think this method will be kind of useless.
My thought is that we can add an option for ConfigurationFeatureDefinitionProvider to read from the root of the configuration if no "FeatureManagement" section is found (the behavior in 2.6.0). This option should be false by default. But if it is registered by AddFeatureManagement(configuration), the option will be set to true.

Agree, we should preserve the behavior for this override. Thanks for raising the issue.

Great thank you!

Will this feature be patched to work for .NET 8 again? It would be relevant to name the configuration-section to a custom name instead of relying on only "FeatureManagement".

Will this feature be patched to work for .NET 8 again?

I don't expect any specific issue for .NET 8. All versions of .NET should behave the same.

It would be relevant to name the configuration-section to a custom name instead of relying on only "FeatureManagement".

Is this a request for that capability? That should be doable once we address the issue using the pattern in the initial issue description. services.AddFeatureManagement(configuration.GetSection("MyCustomFlagsSection"));

Fixed in release 3.1.0