![]() |
VOOZH | about |
dotnet add package OpenFeature --version 1.5.2
NuGet\Install-Package OpenFeature -Version 1.5.2
<PackageReference Include="OpenFeature" Version="1.5.2" />
<PackageVersion Include="OpenFeature" Version="1.5.2" />Directory.Packages.props
<PackageReference Include="OpenFeature" />Project file
paket add OpenFeature --version 1.5.2
#r "nuget: OpenFeature, 1.5.2"
#:package OpenFeature@1.5.2
#addin nuget:?package=OpenFeature&version=1.5.2Install as a Cake Addin
#tool nuget:?package=OpenFeature&version=1.5.2Install as a Cake Tool
OpenFeature is an open specification that provides a vendor-agnostic, community-driven API for feature flagging that works with your favorite feature flag management tool or in-house solution.
Note that the packages will aim to support all current .NET versions. Refer to the currently supported versions .NET and .NET Framework excluding .NET Framework 3.5
Use the following to initialize your project:
dotnet new console
and install OpenFeature:
dotnet add package OpenFeature
public async Task Example()
{
// Register your feature flag provider
await Api.Instance.SetProvider(new InMemoryProvider());
// Create a new client
FeatureClient client = Api.Instance.GetClient();
// Evaluate your feature flag
bool v2Enabled = await client.GetBooleanValue("v2_enabled", false);
if ( v2Enabled )
{
//Do some work
}
}
| Status | Features | Description |
|---|---|---|
| ✅ | Providers | Integrate with a commercial, open source, or in-house feature management tool. |
| ✅ | Targeting | Contextually-aware flag evaluation using evaluation context. |
| ✅ | Hooks | Add functionality to various stages of the flag evaluation life-cycle. |
| ✅ | Logging | Integrate with popular logging packages. |
| ✅ | Named clients | Utilize multiple providers in a single application. |
| ✅ | Eventing | React to state changes in the provider or flag management system. |
| ✅ | Shutdown | Gracefully clean up a provider during application shutdown. |
| ✅ | Extending | Extend OpenFeature with custom providers and hooks. |
Implemented: ✅ | In-progress: ⚠️ | Not implemented yet: ❌
Providers are an abstraction between a flag management system and the OpenFeature SDK. Here is a complete list of available providers.
If the provider you're looking for hasn't been created yet, see the develop a provider section to learn how to build it yourself.
Once you've added a provider as a dependency, it can be registered with OpenFeature like this:
await Api.Instance.SetProvider(new MyProvider());
In some situations, it may be beneficial to register multiple providers in the same application. This is possible using named clients, which is covered in more detail below.
Sometimes, the value of a flag must consider some dynamic criteria about the application or user such as the user's location, IP, email address, or the server's location. In OpenFeature, we refer to this as targeting. If the flag management system you're using supports targeting, you can provide the input data using the evaluation context.
// set a value to the global context
EvaluationContextBuilder builder = EvaluationContext.Builder();
builder.Set("region", "us-east-1");
EvaluationContext apiCtx = builder.Build();
Api.Instance.SetContext(apiCtx);
// set a value to the client context
builder = EvaluationContext.Builder();
builder.Set("region", "us-east-1");
EvaluationContext clientCtx = builder.Build();
var client = Api.Instance.GetClient();
client.SetContext(clientCtx);
// set a value to the invocation context
builder = EvaluationContext.Builder();
builder.Set("region", "us-east-1");
EvaluationContext reqCtx = builder.Build();
bool flagValue = await client.GetBooleanValue("some-flag", false, reqCtx);
Hooks allow for custom logic to be added at well-defined points of the flag evaluation life-cycle. Look here for a complete list of available hooks. If the hook you're looking for hasn't been created yet, see the develop a hook section to learn how to build it yourself.
Once you've added a hook as a dependency, it can be registered at the global, client, or flag invocation level.
// add a hook globally, to run on all evaluations
Api.Instance.AddHooks(new ExampleGlobalHook());
// add a hook on this client, to run on all evaluations made by this client
var client = Api.Instance.GetClient();
client.AddHooks(new ExampleClientHook());
// add a hook for this evaluation only
var value = await client.GetBooleanValue("boolFlag", false, context, new FlagEvaluationOptions(new ExampleInvocationHook()));
The .NET SDK uses Microsoft.Extensions.Logging. See the manual for complete documentation.
Clients can be given a name. A name is a logical identifier that can be used to associate clients with a particular provider. If a name has no associated provider, the global provider is used.
// registering the default provider
await Api.Instance.SetProvider(new LocalProvider());
// registering a named provider
await Api.Instance.SetProvider("clientForCache", new CachedProvider());
// a client backed by default provider
FeatureClient clientDefault = Api.Instance.GetClient();
// a client backed by CachedProvider
FeatureClient clientNamed = Api.Instance.GetClient("clientForCache");
Events allow you to react to state changes in the provider or underlying flag management system, such as flag definition changes,
provider readiness, or error conditions.
Initialization events (PROVIDER_READY on success, PROVIDER_ERROR on failure) are dispatched for every provider.
Some providers support additional events, such as PROVIDER_CONFIGURATION_CHANGED.
Please refer to the documentation of the provider you're using to see what events are supported.
Example usage of an Event handler:
public static void EventHandler(ProviderEventPayload eventDetails)
{
Console.WriteLine(eventDetails.Type);
}
EventHandlerDelegate callback = EventHandler;
// add an implementation of the EventHandlerDelegate for the PROVIDER_READY event
Api.Instance.AddHandler(ProviderEventTypes.ProviderReady, callback);
It is also possible to register an event handler for a specific client, as in the following example:
EventHandlerDelegate callback = EventHandler;
var myClient = Api.Instance.GetClient("my-client");
var provider = new ExampleProvider();
await Api.Instance.SetProvider(myClient.GetMetadata().Name, provider);
myClient.AddHandler(ProviderEventTypes.ProviderReady, callback);
The OpenFeature API provides a close function to perform a cleanup of all registered providers. This should only be called when your application is in the process of shutting down.
// Shut down all providers
await Api.Instance.Shutdown();
To develop a provider, you need to create a new project and include the OpenFeature SDK as a dependency.
This can be a new repository or included in the existing contrib repository available under the OpenFeature organization.
You’ll then need to write the provider by implementing the FeatureProvider interface exported by the OpenFeature SDK.
public class MyProvider : FeatureProvider
{
public override Metadata GetMetadata()
{
return new Metadata("My Provider");
}
public override Task<ResolutionDetails<bool>> ResolveBooleanValue(string flagKey, bool defaultValue, EvaluationContext context = null)
{
// resolve a boolean flag value
}
public override Task<ResolutionDetails<double>> ResolveDoubleValue(string flagKey, double defaultValue, EvaluationContext context = null)
{
// resolve a double flag value
}
public override Task<ResolutionDetails<int>> ResolveIntegerValue(string flagKey, int defaultValue, EvaluationContext context = null)
{
// resolve an int flag value
}
public override Task<ResolutionDetails<string>> ResolveStringValue(string flagKey, string defaultValue, EvaluationContext context = null)
{
// resolve a string flag value
}
public override Task<ResolutionDetails<Value>> ResolveStructureValue(string flagKey, Value defaultValue, EvaluationContext context = null)
{
// resolve an object flag value
}
}
To develop a hook, you need to create a new project and include the OpenFeature SDK as a dependency.
This can be a new repository or included in the existing contrib repository available under the OpenFeature organization.
Implement your own hook by conforming to the Hook interface.
To satisfy the interface, all methods (Before/After/Finally/Error) need to be defined.
public class MyHook : Hook
{
public Task<EvaluationContext> Before<T>(HookContext<T> context,
IReadOnlyDictionary<string, object> hints = null)
{
// code to run before flag evaluation
}
public virtual Task After<T>(HookContext<T> context, FlagEvaluationDetails<T> details,
IReadOnlyDictionary<string, object> hints = null)
{
// code to run after successful flag evaluation
}
public virtual Task Error<T>(HookContext<T> context, Exception error,
IReadOnlyDictionary<string, object> hints = null)
{
// code to run if there's an error during before hooks or during flag evaluation
}
public virtual Task Finally<T>(HookContext<T> context, IReadOnlyDictionary<string, object> hints = null)
{
// code to run after all other stages, regardless of success/failure
}
}
Built a new hook? Let us know so we can add it to the docs!
Interested in contributing? Great, we'd love your help! To get started, take a look at the guide.
Made with contrib.rocks.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 is compatible. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on OpenFeature:
| Package | Downloads |
|---|---|
|
LaunchDarkly.OpenFeature.ServerProvider
LaunchDarkly OpenFeature Provider for the Server-Side SDK for .NET |
|
|
OpenFeature.Hosting
OpenFeature is an open standard for feature flag management, created to support a robust feature flag ecosystem using cloud native technologies. OpenFeature will provide a unified API and SDK, and a developer-first, cloud-native implementation, with extensibility for open source and commercial offerings. |
|
|
DevCycle.SDK.Server.Common
Package Description |
|
|
OpenFeature.Contrib.Hooks.Otel
Open Telemetry Hook for .NET |
|
|
FeatBit.OpenFeature.ServerProvider
An OpenFeature provider for the FeatBit .NET Server SDK |
Showing the top 1 popular GitHub repositories that depend on OpenFeature:
| Repository | Stars |
|---|---|
|
DataDog/dd-trace-dotnet
.NET Client Library for Datadog APM
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.14.0 | 7,956 | 6/22/2026 |
| 2.13.0 | 195,121 | 4/30/2026 |
| 2.12.0 | 131,838 | 4/6/2026 |
| 2.11.1 | 766,928 | 1/8/2026 |
| 2.11.0 | 145,520 | 12/18/2025 |
| 2.10.0 | 257,643 | 12/1/2025 |
| 2.9.0 | 331,422 | 10/16/2025 |
| 2.8.1 | 853,668 | 7/31/2025 |
| 2.8.0 | 112,125 | 7/30/2025 |
| 2.7.0 | 278,586 | 7/3/2025 |
| 2.6.0 | 356,204 | 5/23/2025 |
| 2.5.0 | 346,353 | 4/28/2025 |
| 2.4.0 | 189,466 | 4/14/2025 |
| 2.3.2 | 165,125 | 3/27/2025 |
| 2.3.1 | 215,016 | 2/4/2025 |
| 2.3.0 | 199,854 | 1/31/2025 |
| 2.2.0 | 959,887 | 12/12/2024 |
| 2.1.0 | 268,730 | 11/18/2024 |
| 2.0.0 | 1,101,268 | 8/21/2024 |
| 1.5.2 | 91,425 | 7/26/2024 |