GrowthBook.OpenFeature 0.0.1

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

GrowthBook OpenFeature Provider for .NET

.NET CI

This is the official GrowthBook provider for the OpenFeature .NET SDK. It allows you to leverage GrowthBook as your feature flag system through the standardized OpenFeature API.

Quick Start

  1. Install the package
  2. Create a GrowthBook provider
  3. Register with OpenFeature
  4. Start evaluating feature flags

Requirements

  • .NET 8+
  • .NET Standard 2.0+ (.NET Framework 4.6.1+, .NET Core 2.0+)

Installation

dotnet add package GrowthBook.OpenFeature

Basic Usage

using GrowthBook.OpenFeature;
using OpenFeature;
using OpenFeature.Model;

// Initialize the GrowthBook provider
var provider = new GrowthBookProvider(
    clientKey: "sdk-abc123",
    apiHostUrl: "https://cdn.growthbook.io"
);

// Register the provider with OpenFeature
Api.Instance.SetProvider(provider);

// Create an evaluation context with targeting information
var context = new EvaluationContext(
    targetingKey: "user-123",
    new Dictionary<string, Value>
    {
        { "email", new Value("user@example.com") },
        { "country", new Value("USA") },
        { "premium", new Value(true) }
    }
);

// Get the client
var client = Api.Instance.GetClient();

// Evaluate a feature flag
bool isEnabled = await client.GetBooleanValue("new-dashboard", false, context);

// Use the feature flag in your application logic
if (isEnabled)
{
    // Show the new dashboard
}
else
{
    // Show the old dashboard
}

Available Flag Types

This provider supports all OpenFeature evaluation types:

// Boolean flags
bool enabled = await client.GetBooleanValue("feature-enabled", false, context);

// String flags
string variant = await client.GetStringValue("button-color", "blue", context);

// Integer flags
int limit = await client.GetIntegerValue("api-request-limit", 100, context);

// Double flags
double price = await client.GetDoubleValue("subscription-price", 9.99, context);

// Object flags
Value config = await client.GetObjectValue("feature-config", new Value(new Dictionary<string, Value>()), context);

Advanced Usage

Using an Existing GrowthBook Instance

If you already have a GrowthBook instance configured:

// Create GrowthBook context
var gbContext = new GrowthBook.Context
{
    ApiHost = "https://cdn.growthbook.io",
    ClientKey = "sdk-abc123",
    Enabled = true,
    // Add additional configuration as needed
};

// Create and configure a GrowthBook instance
var growthBook = new GrowthBook.GrowthBook(gbContext);

// Initialize the GrowthBook provider with the existing instance
var provider = new GrowthBookProvider(growthBook);

// Register the provider with OpenFeature
Api.Instance.SetProvider(provider);

Handling Context Changes

You can update the evaluation context at any time:

// Create new context when user logs in
var userContext = new EvaluationContext(
    targetingKey: "user-456", 
    new Dictionary<string, Value>
    {
        { "email", new Value("new-user@example.com") },
        { "subscriptionTier", new Value("premium") }
    }
);

// Update the client with the new context
client.SetEvaluationContext(userContext);

// All subsequent evaluations will use the new context
var result = await client.GetBooleanValue("premium-feature", false);

Project Structure

The solution consists of:

  • GrowthBook.OpenFeature: The main library implementing the OpenFeature provider
  • GrowthBook.OpenFeature.Tests: Unit tests for the provider

Troubleshooting

Common Issues

  1. Feature flag not found: Ensure your clientKey is correct and that the flag exists in your GrowthBook project
  2. Incorrect targeting: Check that your evaluation context contains the expected targeting attributes
  3. No connection to GrowthBook: Verify your apiHostUrl is correct and network connectivity is available

Debugging

Enable verbose logging to see detailed evaluation information:

OpenFeature.Api.Instance.SetLoggerFactory(new ConsoleLoggerFactory(LogLevel.Debug));

Contributing

Contributions are welcome! See CONTRIBUTING.md for details.

License

MIT

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 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. 
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
0.0.1 169 4/22/2025