Skip to main content

OpenFeature Provider for .NET SDK

Integrate your .NET applications with Harness FME using the .NET OpenFeature ProviderAn OpenFeature Provider wraps the Harness FME SDK, acting as a bridge between the OpenFeature SDK and the FME SDK. It translates OpenFeature function calls into operations handled by the FME SDK, which communicates with Harness services to evaluate flags and retrieve configuration updates., a standardized, vendor-agnostic feature flagging API. This provider implements the OpenFeature specification and bridges the OpenFeature SDK with the Harness FME .NET SDK.

This page walks you through installing, configuring, and using the .NET OpenFeature provider to evaluate feature flagsA feature flag is a conditional toggle in Harness FME that enables or disables specific functionality without deploying new code. It allows for controlled feature rollouts, A/B testing, and quick rollbacks if issues arise. in your .NET applications.

Prerequisites

Before you begin, ensure you have the following:

  • A valid Harness FME SDK key for your project
  • A .NET 6.0+ environment
  • Access to your project file to install NuGet dependencies

Version compatibility

ComponentMinimum Version
.NET Runtime6.0+
@splitsoftware/split-openfeature-provider-dotnet≥ 1.0.0
OpenFeature .NET SDK≥ 1.0.0

Install the provider and dependencies

Install the Harness FME OpenFeature provider from NuGet:

dotnet add package Splitio.OpenFeature.Provider

Initialize the provider

You can register the provider with OpenFeature by initializing using an SDK key directly or providing a pre-configured Split client.

If you are using an SDK API key:

using OpenFeature;
using Splitio.OpenFeature.Provider;

Api api = OpenFeature.Api.Instance;
api.setProviderAsync(new Provider("<YOUR_SDK_API_KEY>"));

Construct an evaluation context

Provide an evaluation contextThe Evaluation Context holds contextual information used during flag evaluation. It can include static data (like application or host identifiers) and dynamic data (such as a client IP address), which can be passed explicitly or propagated automatically. Static and dynamic values can be merged for richer, more targeted evaluations. with a targeting keyA unique identifier used to target specific users or entities when evaluating feature flags. It helps determine which variation of a flag should be served based on predefined rules and conditions. to evaluate flags. The evaluation context passes targeting information such as user IDs, email addresses, or plan types for flag targeting.

For example:

var context = EvaluationContext.Builder()
.Set("targetingKey", "randomKey")
.Build();

var result = await client.GetBooleanValueAsync("boolFlag", false, context);

If the same targeting key is reused across evaluations, set the context at the client level:

client.SetContext(context)

Or at the API level:

api.setEvaluationContext(context)

Once the context is set at the client or API level, you don't need to provide it for each evaluation.

For more information, go to the Harness FME .NET OpenFeature Provider GitHub repository.