FeatureFlags.Lite.Core
1.1.0
dotnet add package FeatureFlags.Lite.Core --version 1.1.0
NuGet\Install-Package FeatureFlags.Lite.Core -Version 1.1.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="FeatureFlags.Lite.Core" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FeatureFlags.Lite.Core" Version="1.1.0" />
<PackageReference Include="FeatureFlags.Lite.Core" />
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 FeatureFlags.Lite.Core --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FeatureFlags.Lite.Core, 1.1.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 FeatureFlags.Lite.Core@1.1.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=FeatureFlags.Lite.Core&version=1.1.0
#tool nuget:?package=FeatureFlags.Lite.Core&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FeatureFlags.Lite
Overview
FeatureFlags.Lite is a lightweight, easy-to-use feature flag library for .NET applications. It supports in-memory and configuration-based feature flags, with optional ASP.NET Core middleware for attribute-based endpoint gating.
Key Features
- Toggle features on/off via configuration or in-memory provider.
- Rollout support for percentage-based feature flags.
- Environment-specific overrides.
- Role-based access control via
AllowedRoles. - ASP.NET Core middleware for
[FeatureGate("FeatureName")]attributes.
Installation
git clone https://github.com/FarukA1/FeatureFlags.Lite.git
Quick Start
Add services
using FeatureFlags.Lite.Core.Extensions;
using FeatureFlags.Lite.AspNet.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddFeatureFlags();
// Optional: add configuration provider
builder.Services.AddSingleton<ConfigurationFeatureFlagProvider>(sp =>
new ConfigurationFeatureFlagProvider(builder.Configuration)
);
builder.Services.AddSingleton<IFeatureFlagProvider>(sp =>
sp.GetRequiredService<ConfigurationFeatureFlagProvider>()
);
var app = builder.Build();
Use middleware in ASP.NET Core
app.UseFeatureFlags();
Protect endpoints with [FeatureGate]
using FeatureFlags.Lite.AspNet.Attributes;
using Microsoft.AspNetCore.Mvc;
[ApiController]
[Route("[controller]")]
public class DemoController : ControllerBase
{
[HttpGet("feature-a")]
[FeatureGate("FeatureA")]
public IActionResult FeatureA() => Ok("FeatureA is enabled!");
[HttpGet("public")]
public IActionResult Public() => Ok("Always accessible.");
}
Configure feature flags via appsettings.json
"FeatureFlags": {
"FeatureA": {
"Enabled": true
},
"FeatureB": {
"Enabled": false
},
"FeatureC": {
"Enabled": true,
"RolloutPercentage": 50
},
"FeatureD": {
"Enabled": true,
"AllowedRoles": [ "Admin", "Manager" ]
},
"FeatureE": {
"Enabled": true,
"EnvironmentOverrides": {
"Development": true,
"Production": false
}
}
}
}
Using in-memory feature flags (optional)
var inMemoryProvider = new InMemoryFeatureFlagProvider(new[]
{
new FeatureFlag { Name = "FeatureA", Enabled = true },
new FeatureFlag { Name = "FeatureB", Enabled = false }
});
var service = new FeatureFlagService(inMemoryProvider, new DefaultFeatureEvaluator());
service.IsEnabled("FeatureA");
Contribution
Contributions is welcomed. If you find a bug or have an enhancement in mind, feel free to open an issue or submit a pull request.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.Configuration (>= 10.0.1)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.1)
- Microsoft.Extensions.DependencyInjection (>= 10.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FeatureFlags.Lite.Core:
| Package | Downloads |
|---|---|
|
FeatureFlags.Lite.AspNet
ASP.NET Core middleware and [FeatureGate] attribute for FeatureFlags.Lite. |
GitHub repositories
This package is not used by any popular GitHub repositories.