Propel.FeatureFlags.Attributes
2.2.1
dotnet add package Propel.FeatureFlags.Attributes --version 2.2.1
NuGet\Install-Package Propel.FeatureFlags.Attributes -Version 2.2.1
<PackageReference Include="Propel.FeatureFlags.Attributes" Version="2.2.1" />
<PackageVersion Include="Propel.FeatureFlags.Attributes" Version="2.2.1" />
<PackageReference Include="Propel.FeatureFlags.Attributes" />
paket add Propel.FeatureFlags.Attributes --version 2.2.1
#r "nuget: Propel.FeatureFlags.Attributes, 2.2.1"
#:package Propel.FeatureFlags.Attributes@2.2.1
#addin nuget:?package=Propel.FeatureFlags.Attributes&version=2.2.1
#tool nuget:?package=Propel.FeatureFlags.Attributes&version=2.2.1
Propel.FeatureFlags.Attributes
A lightweight attribute-based library for implementing feature flag gating on methods using AOP (Aspect-Oriented Programming) with dynamic proxy interception.
For detailed documentation and examples, visit the repository readme.
Overview
Propel.FeatureFlags.Attributes enables you to control method execution based on feature flag state using a simple declarative attribute. When a feature is disabled, the system can automatically fall back to an alternative implementation.
Key Features
- Declarative Feature Gating: Use [FeatureFlagged] attribute to gate method execution
- Automatic Fallback: Specify a fallback method when feature is disabled
- Dynamic Proxy Interception: Built on Castle.DynamicProxy for runtime behavior modification
- Multiple Contexts: Supports both HTTP-based and non-HTTP scenarios (console apps, workers)
- Type-Safe: Works with strongly-typed feature flag definitions
Installation
dotnet add package Propel.FeatureFlags.Attributes
Usage
- Define a Feature Flag
public class NewEmailServiceFeatureFlag : FeatureFlagBase
{
public NewEmailServiceFeatureFlag()
: base(
key: "new-email-service",
name: "New Email Service",
description: "Controls whether to use the new email service implementation",
onOfMode: EvaluationMode.Off)
{
}
}
- Annotate Your Methods
public interface INotificationService
{
Task<string> SendEmailAsync(string userId, string subject, string body);
Task<string> SendEmailLegacyAsync(string userId, string subject, string body);
}
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 - executes when feature flag is ENABLED
return "Email sent using new service.";
}
public virtual async Task<string> SendEmailLegacyAsync(string userId, string subject, string body)
{
// Legacy implementation - executes when feature flag is DISABLED
return "Email sent using legacy service.";
}
}
- Register Services with Interception For Web APIs (ASP.NET Core)
builder.Services
.ConfigureFeatureFlags(config =>
{
config.Interception.EnableHttpIntercepter = true;
});
// Register with interception
builder.Services.RegisterWithFeatureFlagInterception<INotificationService, NotificationService>();
For Console Apps / Workers
builder.Services
.ConfigureFeatureFlags(config =>
{
config.Interception.EnableIntercepter = true;
});
// Register with interception
builder.Services.RegisterWithFeatureFlagInterception<INotificationService, NotificationService>();
- Use Your Service
public class NotificationsEndpoints
{
public static void MapNotificationsEndpoints(this WebApplication app)
{
app.MapGet("/send-email", async (INotificationService svc) =>
{
// Automatically routed to new or legacy implementation based on feature flag
var result = await svc.SendEmailAsync("user123", "Subject", "Body");
return Results.Ok(result);
});
}
}
How It Works
- Proxy Generation: When you register a service with RegisterWithFeatureFlagInterception, a dynamic proxy is created for the interface
- Interception: The FeatureFlagInterceptor intercepts calls to methods decorated with [FeatureFlagged]
- Evaluation: The feature flag is evaluated in real-time using IFeatureFlagEvaluator
- Routing: If enabled, the decorated method executes; if disabled, the fallback method is invoked
Important Notes
- Methods decorated with [FeatureFlagged] must be virtual to enable interception
- The fallback method must have the same signature as the decorated method
- Both the interface and implementation must be registered with the DI container
- Use EnableHttpIntercepter for web applications, EnableIntercepter for console/worker applications
Extension Methods
| Method | Description |
|---|---|
| AddHttpAttributeInterceptors() | Adds HTTP-based interceptor infrastructure |
| AddAttributeInterceptors() | Adds basic interceptor infrastructure (non-HTTP) |
| RegisterWithFeatureFlagInterception<TInterface, TImplementation>() | Registers a service with feature flag interception enabled |
Dependencies
- Propel.FeatureFlags
- Castle.Core (DynamicProxy)
- Microsoft.Extensions.DependencyInjection
| 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. |
-
.NETStandard 2.0
- Castle.Core (>= 5.2.1)
- Propel.FeatureFlags (>= 2.2.1)
- Propel.FeatureFlags.AspNetCore (>= 2.2.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Propel.FeatureFlags.Attributes:
| Package | Downloads |
|---|---|
|
Propel.FeatureFlags.PostgreSql
PostgreSQL storage provider for Propel Feature Flags using Npgsql. Handles database operations and schema migraions for feature flag data with automatic schema creation and JSON storage for targeting rules and configurations. |
|
|
Propel.FeatureFlags.SqlServer
SqlServer storage provider for Propel Feature Flags using SqlClient. Handles database operations and schema migrations for feature flag data with automatic schema creation and JSON storage for targeting rules and configurations. |
|
|
Propel.FeatureFlags.DependencyInjection.Extensions
Core feature flag models and evaluation engine for .NET applications |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.2.1 | 233 | 10/20/2025 |
| 2.2.1-beta.1.2 | 122 | 10/19/2025 |
| 2.1.1-beta.1.2 | 48 | 10/18/2025 |
| 2.1.0-beta.1.2 | 123 | 10/16/2025 |
| 2.0.0-beta.1.2 | 128 | 10/14/2025 |
| 1.0.1-beta.1 | 123 | 10/7/2025 |
| 1.0.0-beta.1 | 125 | 10/7/2025 |