Skip to content

Conversation

@askpt
Copy link
Member

@askpt askpt commented Nov 1, 2025

Signed-off-by: André Silva [email protected]

This PR

This pull request introduces dependency injection (DI) support for the MultiProvider in the OpenFeature .NET SDK, making it easier to configure and compose multiple feature flag providers using DI patterns. The main changes add new extension methods and builder classes to facilitate this integration, update sample usage, and provide comprehensive unit tests for the new functionality.

Dependency Injection Support for MultiProvider:

  • Added a new FeatureBuilderExtensions class with AddMultiProvider extension methods, enabling the registration and configuration of MultiProvider via DI in OpenFeatureBuilder. This allows for flexible, code-based configuration of multiple providers and evaluation strategies.
  • Introduced the MultiProviderBuilder class, which provides a fluent API for adding providers (by instance, factory, or type) and setting evaluation strategies, all with DI support.

Sample and Usage Updates:

  • Updated the ASP.NET Core sample (Program.cs) to demonstrate the new DI-based MultiProvider configuration, including adding multiple providers, setting an evaluation strategy, and exposing an endpoint to test flag evaluation. [1] [2] [3]

Testing and Project References:

  • Added comprehensive unit tests for MultiProviderBuilder, covering method chaining, provider addition, strategy configuration, and validation scenarios.
  • Updated project references to include OpenFeature.Hosting where necessary to support the new DI functionality. [1] [2]

Related Issues

Fixes #549

@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.25%. Comparing base (94fcdc1) to head (2656177).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #621      +/-   ##
==========================================
+ Coverage   89.89%   90.25%   +0.35%     
==========================================
  Files          77       79       +2     
  Lines        3168     3284     +116     
  Branches      364      384      +20     
==========================================
+ Hits         2848     2964     +116     
  Misses        251      251              
  Partials       69       69              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

askpt added 3 commits November 1, 2025 19:10
…penFeature.DependencyInjection

Signed-off-by: André Silva <[email protected]>
- Document AddMultiProvider extension methods
- Explain MultiProviderBuilder usage patterns
- Show examples for adding providers via factory, instance, and DI
- Document evaluation strategy configuration
- Add domain-scoped provider configuration examples
- Position DI setup as recommended approach

Signed-off-by: André Silva <[email protected]>
@askpt askpt marked this pull request as ready for review November 9, 2025 14:32
@askpt askpt requested a review from a team as a code owner November 9, 2025 14:32
@askpt askpt requested a review from Copilot November 9, 2025 14:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds dependency injection (DI) support for the MultiProvider in the OpenFeature .NET SDK, enabling streamlined configuration of multiple feature flag providers through a fluent builder API.

Key Changes:

  • Introduced MultiProviderBuilder class with fluent API for adding providers (by instance, factory, or type) and configuring evaluation strategies
  • Added FeatureBuilderExtensions class with AddMultiProvider extension methods for registering MultiProvider via DI in OpenFeatureBuilder
  • Updated ASP.NET Core sample to demonstrate DI-based MultiProvider configuration with multiple providers and evaluation strategy

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/OpenFeature.Providers.MultiProvider/DependencyInjection/FeatureBuilderExtensions.cs Adds extension methods for configuring MultiProvider with OpenFeatureBuilder, supporting both default and domain-scoped registration
src/OpenFeature.Providers.MultiProvider/DependencyInjection/MultiProviderBuilder.cs Implements fluent builder API for adding providers and configuring evaluation strategies with full DI support
test/OpenFeature.Providers.MultiProvider.Tests/DependencyInjection/MultiProviderDependencyInjectionTests.cs Provides comprehensive unit tests for DI integration including null validation, provider registration, and domain support
test/OpenFeature.Providers.MultiProvider.Tests/DependencyInjection/MultiProviderBuilderTests.cs Tests MultiProviderBuilder functionality including method chaining, provider addition, and strategy configuration
src/OpenFeature.Providers.MultiProvider/README.md Documents DI-based setup with examples for adding providers, configuring strategies, and using named domains
samples/AspNetCore/Program.cs Demonstrates DI-based MultiProvider configuration with multiple providers and FirstMatchStrategy
src/OpenFeature.Providers.MultiProvider/OpenFeature.Providers.MultiProvider.csproj Adds project reference to OpenFeature.Hosting for DI support
test/OpenFeature.AotCompatibility/OpenFeature.AotCompatibility.csproj Updates project reference from OpenFeature.DependencyInjection to OpenFeature.Hosting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@askpt askpt added this pull request to the merge queue Nov 11, 2025
Merged via the queue into main with commit ee862f0 Nov 11, 2025
23 checks passed
@askpt askpt deleted the askpt/issue549 branch November 11, 2025 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add Dependency Injection support to multi-provider

4 participants