RepletoryLib.FeatureFlags 1.0.0

dotnet add package RepletoryLib.FeatureFlags --version 1.0.0
                    
NuGet\Install-Package RepletoryLib.FeatureFlags -Version 1.0.0
                    
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="RepletoryLib.FeatureFlags" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RepletoryLib.FeatureFlags" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="RepletoryLib.FeatureFlags" />
                    
Project file
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 RepletoryLib.FeatureFlags --version 1.0.0
                    
#r "nuget: RepletoryLib.FeatureFlags, 1.0.0"
                    
#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 RepletoryLib.FeatureFlags@1.0.0
                    
#: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=RepletoryLib.FeatureFlags&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=RepletoryLib.FeatureFlags&version=1.0.0
                    
Install as a Cake Tool

RepletoryLib.FeatureFlags

Feature flag management with global, user, tenant, and percentage-based targeting.

Part of the RepletoryLib ecosystem -- standalone, reusable .NET 10 libraries with zero business logic.

NuGet .NET 10 License: MIT


Overview

RepletoryLib.FeatureFlags provides a lightweight feature toggle service for controlling feature rollouts. Flags can be targeted globally, per user, per tenant, or as a percentage-based rollout. Flags are configured in appsettings.json and support runtime reloading via IOptionsMonitor.

Key Features

  • Global toggles -- Enable/disable features application-wide
  • User targeting -- Enable for specific user IDs
  • Tenant targeting -- Enable for specific tenant IDs
  • Percentage rollout -- Gradually roll out to a percentage of users (consistent hashing)
  • [FeatureGate] attribute -- Guard controller actions with feature flags
  • Runtime reload -- Flag changes take effect without restart

Installation

dotnet add package RepletoryLib.FeatureFlags

Dependencies

Package Type
RepletoryLib.Common RepletoryLib

Quick Start

using RepletoryLib.FeatureFlags;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRepletoryFeatureFlags(builder.Configuration);
{
  "FeatureFlags": {
    "Flags": {
      "NewDashboard": {
        "Name": "NewDashboard",
        "IsEnabled": true,
        "EnabledForUserIds": [],
        "EnabledForTenantIds": ["00000000-0000-0000-0000-000000000001"],
        "RolloutPercentage": 0
      },
      "BetaCheckout": {
        "Name": "BetaCheckout",
        "IsEnabled": false,
        "EnabledForUserIds": ["user-001", "user-002"],
        "EnabledForTenantIds": [],
        "RolloutPercentage": 25
      }
    }
  }
}

Usage Examples

Checking Flags in Code

using RepletoryLib.FeatureFlags.Interfaces;

public class DashboardService
{
    private readonly IFeatureFlagService _flags;

    public DashboardService(IFeatureFlagService flags) => _flags = flags;

    public async Task<DashboardModel> GetDashboardAsync(string userId, Guid tenantId)
    {
        // Global check
        if (await _flags.IsEnabledAsync("NewDashboard"))
            return await BuildNewDashboardAsync();

        // User-specific check
        if (await _flags.IsEnabledForUserAsync("BetaCheckout", userId))
            return await BuildBetaDashboardAsync();

        // Tenant-specific check
        if (await _flags.IsEnabledForTenantAsync("NewDashboard", tenantId))
            return await BuildNewDashboardAsync();

        // Percentage rollout (consistent per user)
        if (_flags.IsEnabledForPercentage("BetaCheckout", userId, 25))
            return await BuildBetaDashboardAsync();

        return await BuildClassicDashboardAsync();
    }
}

FeatureGate Attribute on Controllers

using RepletoryLib.FeatureFlags.Attributes;

[ApiController]
[Route("api/[controller]")]
public class CheckoutController : ControllerBase
{
    [HttpPost]
    [FeatureGate("BetaCheckout")]
    public IActionResult ProcessCheckout(CheckoutRequest request)
    {
        // Only accessible if "BetaCheckout" is enabled
        return Ok();
    }
}

If the flag is disabled, the filter returns 404 Not Found.

Percentage Rollout

Percentage rollout uses consistent hashing so the same user always gets the same result:

// Enable for 25% of users -- user "abc" always gets the same answer
bool enabled = _flags.IsEnabledForPercentage("BetaFeature", "user-abc", 25);

API Reference

IFeatureFlagService

Method Returns Description
IsEnabledAsync(feature) Task<bool> Global flag check
IsEnabledForUserAsync(feature, userId) Task<bool> User-targeted check
IsEnabledForTenantAsync(feature, tenantId) Task<bool> Tenant-targeted check
IsEnabledForPercentage(feature, userId, percentage) bool Percentage rollout with consistent hashing

Integration with Other RepletoryLib Packages

Package Relationship
RepletoryLib.Common Direct dependency
RepletoryLib.Auth.Jwt Combine with user/tenant context for targeted flags
RepletoryLib.Configuration Flags managed through the same configuration system

License

This project is licensed under the MIT License.

Copyright (c) 2024-2026 Repletory.


For complete documentation, infrastructure setup, and configuration reference, see the RepletoryLib main repository.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.0 143 3/2/2026