Skip to content

3.1.0

Compare
Choose a tag to compare
@zhiyuanliang-ms zhiyuanliang-ms released this 23 Nov 06:56
· 241 commits to main since this release
74c6f88

Microsoft.FeatureManagement Updates

The packages associated with this release are

Enhancements

  • FeatureManager and ConfigurationFeatureDefinitionProvider are now public.

    • Enables usage of external dependency injection containers.
    • Allows usage of FeatureManager without requiring dependency injection.
  • Added support for server-side Blazor apps, where the following API can be used in place of the existing AddFeatureManagement() API. The new API registers the feature manager and feature filters as scoped services, while the existing API registers them as singletons. (#258)

    public static IFeatureManagementBuilder AddScopedFeatureManagement(this IServiceCollection services)

The FeatureManager and ConfigurationFeatureDefinitionProvider classes are the core services of the feature management system. In the past, both of them were internal and could only be registered via the AddFeatureManagement() method, which relies on Microsoft.Extensions.DependencyInjection. This limitation prevented third-party DI container systems from registering these classes, making them incompatible with the entire feature management system. After exposing FeatureManager and ConfigurationFeatureDefinitionProvider to public, all Feature Management services have been made accessible to other DI containers. (Related issues: #126 #258)

Additionally, the recommended way for accessing HttpContext in Blazor is through a scoped context provider service. The singleton HttpContextAccessor pattern, while working well in regular ASP.NET Core web app, becomes unreliable in Blazor components. As a result, to use Targeting in Blazor, the targeting filter and targeting context accessor should be registered as scoped. (Related issue: #15 #258)

We have introduced an alternative way AddScopedFeatureManagement() to register the feature management system, where the feature manager and all feature filters will be registered as scoped. It ensures that the integration aligns with Blazor's best practices for handling HttpContext and enhances the overall ease of use.

Bug Fixes

  • Fixed a bug introduced in the previous release where feature flags cannot be loaded from a custom section of configuration. #308
  • Fixed a bug introduced in the previous release where evaluation of a feature flag that references a contextual feature filter may throw an exception if there is no appropriate context provided during evaluation. #313