-
Notifications
You must be signed in to change notification settings - Fork 22
feat: Add DI for multi provider #621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…n support Signed-off-by: André Silva <[email protected]>
…valuation endpoints Signed-off-by: André Silva <[email protected]>
…meters Signed-off-by: André Silva <[email protected]>
…encyInjection Signed-off-by: André Silva <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
…penFeature.DependencyInjection Signed-off-by: André Silva <[email protected]>
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]>
There was a problem hiding this 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
MultiProviderBuilderclass with fluent API for adding providers (by instance, factory, or type) and configuring evaluation strategies - Added
FeatureBuilderExtensionsclass withAddMultiProviderextension methods for registering MultiProvider via DI inOpenFeatureBuilder - 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.
src/OpenFeature.Providers.MultiProvider/DependencyInjection/FeatureBuilderExtensions.cs
Show resolved
Hide resolved
src/OpenFeature.Providers.MultiProvider/DependencyInjection/FeatureBuilderExtensions.cs
Show resolved
Hide resolved
src/OpenFeature.Providers.MultiProvider/DependencyInjection/FeatureBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/OpenFeature.Providers.MultiProvider/DependencyInjection/MultiProviderBuilder.cs
Outdated
Show resolved
Hide resolved
src/OpenFeature.Providers.MultiProvider/DependencyInjection/MultiProviderBuilder.cs
Outdated
Show resolved
Hide resolved
src/OpenFeature.Providers.MultiProvider/DependencyInjection/MultiProviderBuilder.cs
Outdated
Show resolved
Hide resolved
src/OpenFeature.Providers.MultiProvider/DependencyInjection/MultiProviderBuilder.cs
Outdated
Show resolved
Hide resolved
src/OpenFeature.Providers.MultiProvider/DependencyInjection/MultiProviderBuilder.cs
Outdated
Show resolved
Hide resolved
src/OpenFeature.Providers.MultiProvider/DependencyInjection/MultiProviderBuilder.cs
Outdated
Show resolved
Hide resolved
src/OpenFeature.Providers.MultiProvider/DependencyInjection/MultiProviderBuilder.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Kyle <[email protected]> Signed-off-by: André Silva <[email protected]>
Co-authored-by: Kyle <[email protected]> Signed-off-by: André Silva <[email protected]>
…uration Signed-off-by: GitHub <[email protected]>
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:
FeatureBuilderExtensionsclass withAddMultiProviderextension methods, enabling the registration and configuration of MultiProvider via DI inOpenFeatureBuilder. This allows for flexible, code-based configuration of multiple providers and evaluation strategies.MultiProviderBuilderclass, 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:
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:
MultiProviderBuilder, covering method chaining, provider addition, strategy configuration, and validation scenarios.OpenFeature.Hostingwhere necessary to support the new DI functionality. [1] [2]Related Issues
Fixes #549