EnumCraft.FeatureFlags.Json
0.2.1-preview
dotnet add package EnumCraft.FeatureFlags.Json --version 0.2.1-preview
NuGet\Install-Package EnumCraft.FeatureFlags.Json -Version 0.2.1-preview
<PackageReference Include="EnumCraft.FeatureFlags.Json" Version="0.2.1-preview" />
<PackageVersion Include="EnumCraft.FeatureFlags.Json" Version="0.2.1-preview" />
<PackageReference Include="EnumCraft.FeatureFlags.Json" />
paket add EnumCraft.FeatureFlags.Json --version 0.2.1-preview
#r "nuget: EnumCraft.FeatureFlags.Json, 0.2.1-preview"
#:package EnumCraft.FeatureFlags.Json@0.2.1-preview
#addin nuget:?package=EnumCraft.FeatureFlags.Json&version=0.2.1-preview&prerelease
#tool nuget:?package=EnumCraft.FeatureFlags.Json&version=0.2.1-preview&prerelease
EnumCraft.FeatureFlags.Json
JSON file provider for EnumCraft.FeatureFlags.
Overview
EnumCraft.FeatureFlags.Json is the JSON file-based data provider for the EnumCraft feature flag system. It loads feature flag configuration from a JSON file, supports per-tenant overrides, and automatically reloads when the file changes — using a FileSystemWatcher with a polling fallback for reliability.
This package is part of the EnumCraft ecosystem:
| Package | Description |
|---|---|
EnumCraft.Core |
Strongly-typed enums and flags (TypedEnum, TypedFlag) |
EnumCraft.FeatureFlags |
Feature flag abstraction and resolution engine |
EnumCraft.FeatureFlags.Json |
JSON file provider (this package) |
Status
⚠️ This package is currently in preview. API surface is not yet stable and may change before v1.0.0.
Installation
dotnet add package EnumCraft.FeatureFlags.Json
Requirements
- .NET Standard 2.0+ or .NET 8.0+
EnumCraft.FeatureFlagsEnumCraft.Core
Quick Start
using EnumCraft.FeatureFlags.Json;
var options = new JsonFeatureFlagProviderOptions
{
DirectoryPath = AppDomain.CurrentDomain.BaseDirectory,
FileName = "AppFeatureFlag.json" // name it to match your derived type
};
var provider = new JsonFeatureFlagProvider(options);
if(!AppFeatureFlag.TryConfigure(provider, out var error))
{
Console.WriteLine($"Failed to configure flags: {error}");
return;
}
Configuration Options
| Property | Default | Description |
|---|---|---|
DirectoryPath |
(required) | Directory where the JSON file is located |
FileName |
"FeatureFlags.json" |
Name of the JSON file |
EnableAutoReload |
true |
Watch for file changes and reload automatically |
DebounceMs |
350 |
Minimum ms between reloads (prevents rapid re-reads) |
PollMs |
2000 |
Polling interval ms (fallback safety net) |
MaxRetryAttempts |
10 |
Max attempts to read file (handles mid-write states) |
RetryDelayMs |
100 |
Delay ms between retry attempts |
FullPath is computed automatically from DirectoryPath + FileName.
JSON File Format
Name your JSON file to match your derived flag type (e.g., AppFeatureFlag.json).
{
"global": {
"DarkMode": true,
"NewDashboard": true,
"BetaReporting": false,
"MaintenanceMode": false
},
"tenants": {
"1001": {
"DarkMode": false,
"NewDashboard": false
},
"1002": {
"BetaReporting": true
}
}
}
Resolution Order
- Tenant override — per-tenant value, if present
- Global override — global value from JSON, if present
- Default — constructor-defined fallback (
isActiveDefault)
Auto-Reload Behavior
When EnableAutoReload is true (the default):
- A
FileSystemWatchermonitors the JSON file for changes - A polling timer runs as a fallback safety net
- On successful reload, the
Changedevent is raised - On failed reload (malformed JSON, IO error), the previous snapshot is retained — no partial reads
- The watcher is automatically recreated if it encounters a buffer overflow error
Disposal
JsonFeatureFlagProvider implements IDisposable. At application shutdown, dispose the provider to stop the watcher and polling timer cleanly:
provider.Dispose();
License
MIT — see LICENSE for details.
Author
Randel Bjorkquist
| 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 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. |
| .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
- EnumCraft.FeatureFlags (>= 0.2.1-preview)
- Microsoft.Extensions.Logging.Abstractions (>= 2.1.1)
- System.Text.Json (>= 4.7.2)
-
net8.0
- EnumCraft.FeatureFlags (>= 0.2.1-preview)
- Microsoft.Extensions.Logging.Abstractions (>= 2.1.1)
- System.Text.Json (>= 4.7.2)
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 |
|---|---|---|
| 0.2.1-preview | 0 | 3/2/2026 |
| 0.2.0-preview | 35 | 2/24/2026 |