Propel.FeatureFlags.DependencyInjection.Extensions
2.2.1
dotnet add package Propel.FeatureFlags.DependencyInjection.Extensions --version 2.2.1
NuGet\Install-Package Propel.FeatureFlags.DependencyInjection.Extensions -Version 2.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Propel.FeatureFlags.DependencyInjection.Extensions" Version="2.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Propel.FeatureFlags.DependencyInjection.Extensions" Version="2.2.1" />
<PackageReference Include="Propel.FeatureFlags.DependencyInjection.Extensions" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Propel.FeatureFlags.DependencyInjection.Extensions --version 2.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Propel.FeatureFlags.DependencyInjection.Extensions, 2.2.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Propel.FeatureFlags.DependencyInjection.Extensions@2.2.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Propel.FeatureFlags.DependencyInjection.Extensions&version=2.2.1
#tool nuget:?package=Propel.FeatureFlags.DependencyInjection.Extensions&version=2.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Propel.FeatureFlags.DependencyInjection.Extensions
Extension methods for configuring and integrating Propel.FeatureFlags with .NET applications using dependency injection.
For detailed documentation and examples, visit the repository readme.
Features
IServiceCollectionExtensions - Configure feature flags both in ASP.NET Core and console applications- Automatic Flag Registration - Automatically discovers and registers feature flags from assemblies
- Auto-Deployment - Automatically creates flags in the database on application startup
- Type-Safe Flag Factory - Provides
IFeatureFlagFactoryfor compile-time safe flag access - Local Caching - Built-in memory cache configuration for better performance
- Attribute-Based Interception - Support for
[FeatureFlagged]attribute on methods - HTTP Context Integration - Integration with ASP.NET Core middleware pipeline
Installation
dotnet add package Propel.FeatureFlags.DependencyInjection.Extensions
Quick Start
ASP.NET Core Web API
var builder = WebApplication.CreateBuilder(args);
// Configure Propel FeatureFlags
builder.Services
.ConfigureFeatureFlags(config =>
{
config.RegisterFlagsWithContainer = true; // Auto-register flags with DI
config.EnableFlagFactory = true; // Enable type-safe flag access
// Enable attribute-based interception for HTTP controllers
config.Interception.EnableHttpIntercepter = true;
// Optional: Configure local caching
config.LocalCacheConfiguration = new LocalCacheConfiguration
{
LocalCacheEnabled = true,
CacheDurationInMinutes = 60,
CacheSizeLimit = 1000
};
})
.AddPostgreSqlFeatureFlags(builder.Configuration.GetConnectionString("DefaultConnection")!);
var app = builder.Build();
// Initialize database (development only)
if (app.Environment.IsDevelopment())
{
await app.InitializeFeatureFlagsDatabase();
}
// Auto-deploy flags to database
await app.AutoDeployFlags();
app.Run();
Console Application / Worker Service
var builder = Host.CreateApplicationBuilder(args);
builder.Services
.ConfigureFeatureFlags(config =>
{
config.RegisterFlagsWithContainer = true;
config.EnableFlagFactory = true;
// For console apps, use EnableIntercepter (not EnableHttpIntercepter)
config.Interception.EnableIntercepter = true;
config.LocalCacheConfiguration = new LocalCacheConfiguration
{
LocalCacheEnabled = true,
CacheDurationInMinutes = 10,
CacheSizeLimit = 1000
};
})
.AddSqlServerFeatureFlags(builder.Configuration.GetConnectionString("DefaultConnection")!);
// Register services with attribute interception
builder.Services.RegisterWithFeatureFlagInterception<INotificationService, NotificationService>();
var app = builder.Build();
// Auto-deploy flags
await app.AutoDeployFlags();
await app.RunAsync();
Configuration Options
PropelConfiguration
| Property | Description | Default |
|---|---|---|
| RegisterFlagsWithContainer | Automatically register all flags in assembly with DI | true |
| EnableFlagFactory | Enable IFeatureFlagFactory for type-safe access | true |
| AutoDeployFlags | Automatically deploy flags on startup | false |
| LocalCacheConfiguration | Configure local memory cache settings | See below |
| Interception.EnableIntercepter | Enable attribute interception for console apps | false |
| Interception.EnableHttpIntercepter | Enable attribute interception for ASP.NET Core | false |
LocalCacheConfiguration
| Property | Description | Default |
|---|---|---|
| LocalCacheEnabled | Enable local in-memory caching | false |
| CacheDurationInMinutes | Cache expiration time (minutes) | 60 |
| CacheSizeLimit | Maximum number of cached flags | 1000 |
Extension Methods
| Method | Description | Example |
|---|---|---|
| ConfigureFeatureFlags(Action<PropelConfiguration>) | Configures core feature flag services with the DI container. | See below |
| AutoDeployFlags() | Automatically creates feature flags in the database if they don't exist. Recommended to call on application startup. | See below |
| InitializeFeatureFlagsDatabase() | Creates the database schema for feature flags. Typically used in development environments. | See below |
| RegisterWithFeatureFlagInterception<TInterface, TImplementation>() | Registers a service with support for [FeatureFlagged] attribute interception. | See below |
// Deploy feature flags database schema
if (app.Environment.IsDevelopment())
{
await app.InitializeFeatureFlagsDatabase();
}
// Register a service with attribute-based feature flag interception
builder.Services.RegisterWithFeatureFlagInterception<INotificationService, NotificationService>();
Attribute-Based Feature Flagging
Define a service with feature-flagged methods:
public class NotificationService : INotificationService
{
[FeatureFlagged(type: typeof(NewEmailServiceFeatureFlag), fallbackMethod: nameof(SendEmailLegacyAsync))]
public virtual async Task<string> SendEmailAsync(string userId, string subject, string body)
{
// New implementation
return "Email sent using NEW service";
}
public virtual async Task<string> SendEmailLegacyAsync(string userId, string subject, string body)
{
// Legacy fallback
return "Email sent using LEGACY service";
}
}
Register the service:
// Console apps
builder.Services.RegisterWithFeatureFlagInterception<INotificationService, NotificationService>();
// ASP.NET Core - automatically works with EnableHttpIntercepter = true
builder.Services.AddScoped<INotificationService, NotificationService>();
Storage Providers
This library works with various storage providers:
// SQL Server
.AddSqlServerFeatureFlags(connectionString)
// PostgreSQL
.AddPostgreSqlFeatureFlags(connectionString)
// Add Redis caching layer (optional)
.AddRedisCache(redisConnectionString, options => { ... })
;
Complete Example
See the demo projects for complete working examples:
- DemoWebApi - ASP.NET Core Web API with middleware, controllers, and minimal APIs
- DemoWorker - .NET Core Console application / Background Worker service
- DemoLegacyApi - .NET Framework 4.8.1 compatibility
Best Practices
- Always call
AutoDeployFlags()on startup to ensure flags exist in the database - Enable caching in production for better performance and reduced database load
- Use
InitializeFeatureFlagsDatabase()only in development environments - Register flags with DI container (
RegisterFlagsWithContainer = true) for easier testing - Enable
IFeatureFlagFactoryfor type-safe flag access throughout your application
Requirements
- .NET Standard 2.0+ (core library)
- .NET 6.0+ (for ASP.NET Core integration)
- Compatible with .NET Framework 4.8.1+
Related Packages
- Propel.FeatureFlags - Core feature flag library
- Propel.FeatureFlags.SqlServer - SQL Server repository
- Propel.FeatureFlags.PostgreSql - PostgreSQL repository
- Propel.FeatureFlags.Redis - Redis caching provider
- Propel.FeatureFlags.AspNetCore - ASP.NET Core middleware
- Propel.FeatureFlags.Attributes - Attribute-based feature flagging
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Propel.FeatureFlags (>= 2.2.1)
- Propel.FeatureFlags.AspNetCore (>= 2.2.1)
- Propel.FeatureFlags.Attributes (>= 2.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.2.1 | 207 | 10/20/2025 |
| 2.2.1-beta.1.2 | 139 | 10/19/2025 |
| 2.1.1-beta.1.2 | 72 | 10/18/2025 |
| 2.1.0-beta.1.2 | 141 | 10/16/2025 |
| 2.0.0-beta.1.2 | 150 | 10/14/2025 |