OpenFeature 0.1.2

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package OpenFeature --version 0.1.2                
NuGet\Install-Package OpenFeature -Version 0.1.2                
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="OpenFeature" Version="0.1.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenFeature --version 0.1.2                
#r "nuget: OpenFeature, 0.1.2"                
#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.
// Install OpenFeature as a Cake Addin
#addin nuget:?package=OpenFeature&version=0.1.2

// Install OpenFeature as a Cake Tool
#tool nuget:?package=OpenFeature&version=0.1.2                

OpenFeature SDK for .NET

a codecov nuget

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.

Getting Started

Basic Usage

using OpenFeature.SDK;

// Sets the provider used by the client
OpenFeature.Instance.SetProvider(new NoOpProvider());
// Gets a instance of the feature flag client
var client = OpenFeature.Instance.GetClient();
// Evaluation the `my-feature` feature flag
var isEnabled = await client.GetBooleanValue("my-feature", false);

Provider

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 an existing contrib repository available under the OpenFeature organization. Finally, you’ll then need to write the provider itself. In most languages, this can be accomplished by implementing the provider interface exported by the OpenFeature SDK.

Example of implementing a feature flag provider

using OpenFeature.SDK;
using OpenFeature.SDK.Model;

public class MyFeatureProvider : FeatureProvider
{
    public static string Name => "My Feature Provider";

    public Metadata GetMetadata()
    {
        return new Metadata(Name);
    }

    public Task<ResolutionDetails<bool>> ResolveBooleanValue(string flagKey, bool defaultValue,
        EvaluationContext context = null,
        FlagEvaluationOptions config = null)
    {
        // code to resolve boolean details
    }

    public Task<ResolutionDetails<string>> ResolveStringValue(string flagKey, string defaultValue,
        EvaluationContext context = null,
        FlagEvaluationOptions config = null)
    {
        // code to resolve string details
    }

    public Task<ResolutionDetails<int>> ResolveIntegerValue(string flagKey, int defaultValue,
        EvaluationContext context = null,
        FlagEvaluationOptions config = null)
    {
        // code to resolve integer details
    }

    public Task<ResolutionDetails<double>> ResolveDoubleValue(string flagKey, double defaultValue,
        EvaluationContext context = null,
        FlagEvaluationOptions config = null)
    {
        // code to resolve integer details
    }

    public Task<ResolutionDetails<T>> ResolveStructureValue<T>(string flagKey, T defaultValue,
        EvaluationContext context = null,
        FlagEvaluationOptions config = null)
    {
        // code to resolve object details
    }
}

Hook

Hooks are a mechanism that allow for the addition of arbitrary behavior at well-defined points of the flag evaluation life-cycle. Use cases include validation of the resolved flag value, modifying or adding data to the evaluation context, logging, telemetry, and tracking.

Example of adding a hook

// add a hook globally, to run on all evaluations
openFeature.AddHooks(new ExampleGlobalHook());

// add a hook on this client, to run on all evaluations made by this client
var client = OpenFeature.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()));

Example of implementing a hook

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

NuGet packages (18)

Showing the top 5 NuGet packages that depend on OpenFeature:

Package Downloads
DevCycle.SDK.Server.Common

Package Description

LaunchDarkly.OpenFeature.ServerProvider

LaunchDarkly OpenFeature Provider for the Server-Side SDK for .NET

CloudBees.OpenFeature.Provider

An OpenFeature provider for CloudBees Feature Management

Octopus.OpenFeature

The OctopusDeploy dotnet OpenFeature provide

OpenFeature.Contrib.Hooks.Otel

Open Telemetry Hook for .NET

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 50,075 8/21/2024
1.6.0 79,135 7/29/2024
1.5.2 201 7/26/2024
1.5.1 102,861 4/9/2024
1.5.0 49,657 3/12/2024
1.4.1 61,413 1/23/2024
1.4.0 6,279 1/23/2024
1.3.1 660,666 9/19/2023
1.3.0 25,333 7/14/2023
1.2.0 103,202 2/14/2023
1.1.0 2,605 1/18/2023
1.0.1 11,010 10/28/2022
1.0.0 5,279 10/26/2022
0.5.0 5,968 10/16/2022
0.4.0 808 10/12/2022
0.3.0 1,289 9/29/2022
0.2.3 480 9/22/2022
0.1.5 562 9/19/2022
0.1.4 442 9/8/2022
0.1.3 436 8/25/2022
0.1.2 439 8/10/2022
0.1.1 457 7/18/2022
0.1.0 552 7/14/2022