### Install Flipt Provider using Package Manager Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flipt/README.md Use the NuGet Package Manager to install the Flipt provider. ```shell NuGet\Install-Package OpenFeature.Contrib.Providers.Flipt ``` -------------------------------- ### Start flagd Server Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Start the flagd server with a sample flag configuration file. Ensure the flagd service is running before using the provider. ```shell flagd start --uri https://raw.githubusercontent.com/open-feature/flagd/main/config/flags/example_flags.json ``` -------------------------------- ### Install OpenFeature.Providers.Ofrep using .NET CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Ofrep/README.md Use the .NET CLI to add the OpenFeature.Providers.Ofrep package to your project. ```shell dotnet add package OpenFeature.Providers.Ofrep ``` -------------------------------- ### Install Flipt Provider using Package Reference Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flipt/README.md Add the Flipt provider as a package reference in your project file. ```xml ``` -------------------------------- ### Install Environment Variable Provider Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.EnvVar/README.md Install the Environment Variable provider package using the .NET CLI. ```shell dotnet add package OpenFeature.Contrib.Providers.EnvVar ``` -------------------------------- ### Install Statsig Provider via Package Manager Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Statsig/README.md Use the NuGet Package Manager to install the Statsig provider. ```shell NuGet\Install-Package OpenFeature.Contrib.Providers.Statsig ``` -------------------------------- ### Install Unleash Provider via Paket CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Unleash/README.md Use the Paket CLI to add the Unleash provider package. ```shell paket add OpenFeature.Providers.Unleash ``` -------------------------------- ### Install Flipt Provider using Packet CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flipt/README.md Use the Packet CLI to add the Flipt provider dependency. ```shell packet add OpenFeature.Contrib.Providers.Flipt ``` -------------------------------- ### Install flagd .NET Provider via Package Manager Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Use the NuGet Package Manager console to install the flagd provider. ```powershell NuGet\Install-Package OpenFeature.Providers.Flagd ``` -------------------------------- ### Install Flipt Provider using .NET CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flipt/README.md Use the .NET CLI to add the Flipt provider package to your project. ```shell dotnet add package OpenFeature.Contrib.Providers.Flipt ``` -------------------------------- ### Install Unleash Provider via Package Reference Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Unleash/README.md Include the Unleash provider as a package reference in your project file. ```xml ``` -------------------------------- ### Add GOFeatureFlag Provider using .NET CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.GOFeatureFlag/README.md Install the OpenFeature.Providers.GOFeatureFlag package using the .NET CLI. ```shell dotnet add package OpenFeature.Providers.GOFeatureFlag ``` -------------------------------- ### Install Statsig Provider via Paket CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Statsig/README.md Use the Paket CLI to add the Statsig provider to your project. ```shell paket add OpenFeature.Contrib.Providers.Statsig ``` -------------------------------- ### Install ConfigCat Provider as Cake Addin Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.ConfigCat/README.md Install the ConfigCat Feature Flag provider as a Cake Addin. ```csharp // Install OpenFeature.Contrib.Providers.ConfigCat as a Cake Addin #addin nuget?package=OpenFeature.Contrib.Providers.ConfigCat ``` -------------------------------- ### Install ConfigCat Provider as Cake Tool Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.ConfigCat/README.md Install the ConfigCat Feature Flag provider as a Cake Tool. ```csharp // Install OpenFeature.Contrib.Providers.ConfigCat as a Cake Tool #tool nuget?package=OpenFeature.Contrib.Providers.ConfigCat ``` -------------------------------- ### Install FeatureManagement Provider via Paket CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.FeatureManagement/README.md Use the Paket CLI to add the FeatureManagement provider package. ```shell paket add OpenFeature.Contrib.Provider.FeatureManagement --version 0.1.2 ``` -------------------------------- ### Install Unleash Provider via .NET CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Unleash/README.md Use the .NET CLI to add the Unleash provider package to your project. ```shell dotnet add package OpenFeature.Providers.Unleash ``` -------------------------------- ### Install Statsig Provider via Package Reference Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Statsig/README.md Add the Statsig provider as a PackageReference in your .csproj file. ```xml ``` -------------------------------- ### Install Flagsmith Provider via Package Manager Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flagsmith/README.md Use the NuGet Package Manager console to install the Flagsmith provider. ```shell NuGet\Install-Package OpenFeature.Contrib.Providers.Flagsmith ``` -------------------------------- ### Configure and Use In-Process Flagd Provider Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Example demonstrating how to configure the flagd provider for in-process mode, connect to a flagd service, and evaluate a boolean flag. ```csharp using OpenFeature.Providers.Flagd; namespace OpenFeatureTestApp { class Hello { static void Main(string[] args) { var flagdConfig = new FlagdConfigBuilder() // set the host and port for flagd-proxy .WithHost("localhost") .WithPort("8015") // set the resolver type to 'IN_PROCESS' .WithResolverType(ResolverType.IN_PROCESS) // provide the flag source selector, e.g. the name of a Flags custom resource which is watched by the flagd-proxy .WithSourceSelector("core.openfeature.dev/flags/sample-flags") .Build(); var flagdProvider = new FlagdProvider(flagdConfig); // Set the flagdProvider as the provider for the OpenFeature SDK OpenFeature.Api.Instance.SetProvider(flagdProvider); var client = OpenFeature.Api.Instance.GetClient("my-app"); var val = client.GetBooleanValueAsync("myBoolFlag", false, null); // Print the value of the 'myBoolFlag' feature flag System.Console.WriteLine(val.Result.ToString()); } } } ``` -------------------------------- ### Install flagd .NET Provider via Packet CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Use the Packet CLI to add the flagd provider dependency. ```shell paket add OpenFeature.Providers.Flagd ``` -------------------------------- ### Install FeatureManagement Provider as Cake Addin/Tool Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.FeatureManagement/README.md Install the FeatureManagement provider as a Cake Addin or Tool using the #addin or #tool directive. ```csharp // Install OpenFeature.Contrib.Provider.FeatureManagement as a Cake Addin #addin nuget:?package=OpenFeature.Contrib.Provider.FeatureManagement&version=0.1.2&prerelease // Install OpenFeature.Contrib.Provider.FeatureManagement as a Cake Tool #tool nuget:?package=OpenFeature.Contrib.Provider.FeatureManagement&version=0.1.2&prerelease ``` -------------------------------- ### Install Statsig Provider via .NET CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Statsig/README.md Use the .NET CLI to add the Statsig provider package to your project. ```shell dotnet add package OpenFeature.Contrib.Providers.Statsig ``` -------------------------------- ### Configure Logger for In-Process Provider Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Example showing how to configure a logger for the in-process flagd provider using Microsoft.Extensions.Logging abstractions. ```csharp var logger = loggerFactory.CreateLogger(); var flagdConfig = new FlagdConfigBuilder() .WithLogger(logger) .Build(); ``` -------------------------------- ### Add GOFeatureFlag Provider using Package Manager Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.GOFeatureFlag/README.md Install the OpenFeature.Providers.GOFeatureFlag package using the NuGet Package Manager. ```shell NuGet\Install-Package OpenFeature.Providers.GOFeatureFlag ``` -------------------------------- ### Install flagd .NET Provider via .NET CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Use the .NET CLI to add the flagd provider package to your project. ```shell dotnet add package OpenFeature.Providers.Flagd ``` -------------------------------- ### Install Unleash Provider via Package Manager Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Unleash/README.md Use the NuGet Package Manager console to add the Unleash provider package. ```powershell NuGet\Install-Package OpenFeature.Providers.Unleash ``` -------------------------------- ### Install Flagsmith Provider via Package Reference Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flagsmith/README.md Include the Flagsmith provider as a PackageReference in your project file. ```xml ``` -------------------------------- ### Add ConfigCat Provider via Paket CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.ConfigCat/README.md Install the ConfigCat Feature Flag provider using the Paket CLI. ```shell paket add OpenFeature.Contrib.Providers.ConfigCat ``` -------------------------------- ### Add ConfigCat Provider via .NET CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.ConfigCat/README.md Install the ConfigCat Feature Flag provider using the .NET CLI. ```shell dotnet add package OpenFeature.Contrib.Providers.ConfigCat ``` -------------------------------- ### Install flagd .NET Provider via Package Reference Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Add the flagd provider to your project's Package Reference in the .csproj file. ```xml ``` -------------------------------- ### Install Flipt Provider as Cake Addin/Tool Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flipt/README.md Configure the Flipt provider as an Addin or Tool within a Cake build script. ```csharp // Install OpenFeature.Contrib.Providers.Flipt as a Cake Addin #addin nuget:?package=OpenFeature.Contrib.Providers.Flipt // Install OpenFeature.Contrib.Providers.Flipt as a Cake Tool #tool nuget:?package=OpenFeature.Contrib.Providers.Flipt ``` -------------------------------- ### Install Flagsmith Provider via Packet CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flagsmith/README.md Use the Packet CLI to add the Flagsmith provider dependency. ```shell packet add OpenFeature.Contrib.Providers.Flagsmith ``` -------------------------------- ### Example Feature Flag Configuration Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.FeatureManagement/README.md A sample JSON configuration for a boolean feature flag named 'myBoolFlag' using the FeatureManagement system, including variants and enablement conditions. ```json { "FeatureManagement": { "myBoolFlag": { "Allocation": { "DefaultWhenEnabled": "FlagEnabled", "DefaultWhenDisabled": "FlagDisabled" }, "Variants": [ { "Name": "FlagEnabled", "ConfigurationValue": true }, { "Name": "FlagDisabled", "ConfigurationValue": false } ], "EnabledFor": [ { "Name": "AlwaysOn" } ] } } } ``` -------------------------------- ### Install FeatureManagement Provider via .NET CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.FeatureManagement/README.md Use the .NET CLI to add the FeatureManagement provider package to your project. ```shell dotnet add package OpenFeature.Contrib.Provider.FeatureManagement --version 0.1.2 ``` -------------------------------- ### Customize Statsig Provider with Server Options Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Statsig/README.md Shows how to customize the Statsig provider by passing a StatsigServerOptions object during initialization, for example, to enable local mode. ```csharp var statsigProvider = new StatsigProvider("#YOUR-SDK-KEY#", new StatsigServerOptions() { LocalMode = true }); ``` -------------------------------- ### OFREP Headers Environment Variable Examples Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Ofrep/README.md Demonstrates various formats for setting HTTP headers via the OFREP_HEADERS environment variable, including simple key-value pairs, values with equals signs, and URL-encoded values. ```bash # Simple headers export OFREP_HEADERS="Authorization=Bearer token123,Content-Type=application/json" ``` ```bash # Header value containing equals sign (e.g., base64) - no encoding needed for additional = in value export OFREP_HEADERS="Authorization=Bearer abc123==" ``` ```bash # URL-encoded equals sign in the value (decoded to =, then treated as part of the value) export OFREP_HEADERS="X-Data=key%3Dvalue" ``` ```bash # Multiple headers export OFREP_HEADERS="Authorization=Bearer token,X-Api-Key=abc123" ``` -------------------------------- ### Install Flagsmith Provider via .NET CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flagsmith/README.md Use the .NET CLI to add the Flagsmith provider package to your project. ```shell dotnet add package OpenFeature.Contrib.Providers.Flagsmith ``` -------------------------------- ### Install Statsig Provider as Cake Addin/Tool Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Statsig/README.md Configure Cake build scripts to use the Statsig provider as an addin or tool. ```csharp // Install OpenFeature.Contrib.Providers.Statsig as a Cake Addin #addin nuget:?package= OpenFeature.Contrib.Providers.Statsig // Install OpenFeature.Contrib.Providers.Statsig as a Cake Tool #tool nuget:?package= OpenFeature.Contrib.Providers.Statsig ``` -------------------------------- ### Install FeatureManagement Provider via Package Manager Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.FeatureManagement/README.md Use the NuGet Package Manager to add the FeatureManagement provider package. ```shell NuGet\Install-Package OpenFeature.Contrib.Provider.FeatureManagement -Version 0.1.2 ``` -------------------------------- ### Install Flagsmith Provider as Cake Addin/Tool Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flagsmith/README.md Configure the Flagsmith provider as an Addin or Tool within a Cake build script. ```csharp // Install OpenFeature.Contrib.Providers.Flagsmith as a Cake Addin #addin nuget:?package=OpenFeature.Contrib.Providers.Flagsmith // Install OpenFeature.Contrib.Providers.Flagsmith as a Cake Tool #tool nuget:?package=OpenFeature.Contrib.Providers.Flagsmith ``` -------------------------------- ### Add ConfigCat Provider via Package Manager Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.ConfigCat/README.md Install the ConfigCat Feature Flag provider using the NuGet Package Manager. ```shell NuGet\Install-Package OpenFeature.Contrib.Providers.ConfigCat ``` -------------------------------- ### Install FeatureManagement Provider via Package Reference Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.FeatureManagement/README.md Add the FeatureManagement provider package to your project using a Package Reference in the .csproj file. ```xml ``` -------------------------------- ### Add flagd Provider with Dependency Injection Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Demonstrates how to add the flagd Provider to the OpenFeature SDK using dependency injection with default configurations. Ensure the OpenFeature.Hosting NuGet package is installed. ```csharp using OpenFeature; using OpenFeature.DependencyInjection.Providers.Flagd; namespace OpenFeatureTestApp { class Hello { static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); builder.Services.AddOpenFeature(config => { config.AddHostedFeatureLifecycle() .AddFlagdProvider(); }); var app = builder.Build(); // ... ommitted for brevity } } } ``` -------------------------------- ### Initialize and Use flagd Provider in C# Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Initialize the flagd provider with the flagd service URI and set it as the OpenFeature SDK provider. Then, get a client and evaluate a boolean feature flag. ```csharp using OpenFeature.Providers.Flagd; namespace OpenFeatureTestApp { class Hello { static void Main(string[] args) { var flagdProvider = new FlagdProvider(new Uri("http://localhost:8013")); // Set the flagdProvider as the provider for the OpenFeature SDK OpenFeature.Api.Instance.SetProvider(flagdProvider); var client = OpenFeature.Api.Instance.GetClient("my-app"); var val = client.GetBooleanValueAsync("myBoolFlag", false, null); // Print the value of the 'myBoolFlag' feature flag System.Console.WriteLine(val.Result.ToString()); } } } ``` -------------------------------- ### Install flagd .NET Provider via Cake Script Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Include the flagd provider as a Cake Addin or Tool in your build script. ```csharp // Install OpenFeature.Providers.Flagd as a Cake Addin #addin nuget:?package=OpenFeature.Providers.Flagd // Install OpenFeature.Providers.Flagd as a Cake Tool #tool nuget:?package=OpenFeature.Providers.Flagd ``` -------------------------------- ### Install Unleash Provider via Cake Script Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Unleash/README.md Add the Unleash provider as a Cake Addin or Tool within your Cake build script. ```csharp // Install OpenFeature.Providers.Unleash as a Cake Addin #addin nuget:?package=OpenFeature.Providers.Unleash // Install OpenFeature.Providers.Unleash as a Cake Tool #tool nuget:?package=OpenFeature.Providers.Unleash ``` -------------------------------- ### Sample .csproj File Configuration Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/CONTRIBUTING.md This XML snippet shows essential properties for a library's .csproj file, including package ID, versioning, and metadata. The 'x-release-please-version' tag is a marker for automated version management. ```xml OpenFeature.MyComponent 0.0.1 $(VersionNumber) $(VersionNumber) $(VersionNumber) A very valuable OpenFeature contribution! Me! ``` -------------------------------- ### Create New Library Project Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/CONTRIBUTING.md Use this command to create a new C# class library project. Ensure it's placed under the 'src/' directory. ```bash dotnet new classlib -o src/OpenFeature.MyComponent ``` -------------------------------- ### Create New Test Project Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/CONTRIBUTING.md Use this command to create a new xUnit test project. Place it under the 'test/' directory. ```bash dotnet new xunit -o test/OpenFeature.MyComponent.Test ``` -------------------------------- ### Initialize and Use Statsig Provider with OpenFeature SDK Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Statsig/README.md Demonstrates initializing the Statsig provider with an SDK key and setting it as the default for the OpenFeature SDK. It then retrieves a boolean feature flag. ```csharp using OpenFeature; using OpenFeature.Contrib.Providers.Statsig; using System; StatsigProvider statsigProvider = new StatsigProvider("#YOUR-SDK-KEY#"); // Set the statsigProvider as the provider for the OpenFeature SDK await Api.Instance.SetProviderAsync(statsigProvider); var eb = EvaluationContext.Builder(); eb.SetTargetingKey("john@doe.acme"); IFeatureClient client = Api.Instance.GetClient(context: eb.Build()); bool isMyAwesomeFeatureEnabled = await client.GetBooleanValueAsync("isMyAwesomeFeatureEnabled", false); if (isMyAwesomeFeatureEnabled) { Console.WriteLine("New Feature enabled!"); } ``` -------------------------------- ### Initialize and Use Flipt Provider with OpenFeature SDK Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flipt/README.md Configure the Flipt provider with connection details and set it as the OpenFeature SDK provider. Then, evaluate a boolean feature flag. ```csharp using OpenFeature.Contrib.Providers.Flipt; using OpenFeature.Model; // namespace and clientToken is optional var featureProvider = new FliptProvider("http://localhost:8080", "default-namespace", "client-token"); // Set the featureProvider as the provider for the OpenFeature SDK await OpenFeature.Api.Instance.SetProviderAsync(featureProvider); // Get an OpenFeature client var client = OpenFeature.Api.Instance.GetClient(); // Optional: set EntityId and updated context var context = EvaluationContext.Builder() .SetTargetingKey("flipt EntityId") .Set("extra-data-1", "extra-data-1-value") .Build(); // Evaluate a flag var val = await client.GetBooleanValueAsync("myBoolFlag", false, context); // Print the value of the 'myBoolFlag' feature flag Console.WriteLine(val); ``` -------------------------------- ### Basic Usage of OpenFeature.Providers.Ofrep Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Ofrep/README.md Demonstrates how to configure and register the OFREP provider, and then use it to evaluate various flag types (boolean, string, integer, double). ```csharp using OpenFeature; using OpenFeature.Providers.Ofrep; using OpenFeature.Providers.Ofrep.Configuration; // Configure the provider var config = new OfrepOptions("https://zconfig.company.com/"); // Create and register the provider var provider = new OfrepProvider(config); await Api.Instance.SetProviderAsync(provider); // Use feature flags var client = Api.Instance.GetClient(); // Boolean flag var boolFlag = await client.GetBooleanValueAsync("my-flag", false); // String flag var stringFlag = await client.GetStringValueAsync("greeting", "Hello"); // Integer flag var intFlag = await client.GetIntegerValueAsync("max-retries", 3); // Double flag var doubleFlag = await client.GetDoubleValueAsync("sample-rate", 0.1); ``` -------------------------------- ### Add Test Project to Solution Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/CONTRIBUTING.md Integrates a newly created test project into the existing solution file. ```bash dotnet sln DotnetSdkContrib.slnx add test/OpenFeature.MyComponent.Test/OpenFeature.MyComponent.Test.csproj ``` -------------------------------- ### Initialize and Use Flagsmith Provider with OpenFeature SDK Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flagsmith/README.md Demonstrates setting up the Flagsmith provider with custom configurations and evaluating a boolean feature flag using a targeting key and traits. ```csharp using Flagsmith; using OpenFeature.Contrib.Providers.Flagsmith; using OpenFeature.Model; // Additional configs for provider var providerConfig = new FlagsmithProviderConfiguration(); // Flagsmith client configuration var flagsmithConfig = new FlagsmithConfiguration { ApiUri = new Uri("https://edge.api.flagsmith.com/api/v1/"), EnvironmentKey = "", EnableLocalEvaluation = false, EnvironmentRefreshInterval = TimeSpan.FromSeconds(60), EnableAnalytics = false, Retries = 1, }; var flagsmithProvider = new FlagsmithProvider(providerConfig, flagsmithConfig); // Set the flagsmithProvider as the provider for the OpenFeature SDK await OpenFeature.Api.Instance.SetProviderAsync(flagsmithProvider); // Get an OpenFeature client var client = OpenFeature.Api.Instance.GetClient("my-app"); // Optional: set a targeting key and traits to use segment and/or identity overrides var context = EvaluationContext.Builder() .SetTargetingKey("my-flagsmith-identity-ID") .Set("my-trait-key", "my-trait-value") .Build(); // Evaluate a flag var val = await client.GetBooleanValueAsync("myBoolFlag", false, context); // Print the value of the 'myBoolFlag' feature flag Console.WriteLine(val); ``` -------------------------------- ### Add Library Project to Solution Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/CONTRIBUTING.md Integrates a newly created library project into the existing solution file. ```bash dotnet sln DotnetSdkContrib.slnx add src/OpenFeature.MyComponent/OpenFeature.MyComponent.csproj ``` -------------------------------- ### Initialize and Use FeatureManagement Provider Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.FeatureManagement/README.md Demonstrates how to initialize the FeatureManagement Provider with .NET Configuration and use it with the OpenFeature SDK to evaluate a boolean flag. ```csharp namespace OpenFeatureTestApp { class Program { static void Main(string[] args) { var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddJsonFile("featureFlags.json"); IConfiguration configuration = configurationBuilder.Build(); var featureManagementProvider = new FeatureManagementProvider(configuration); OpenFeature.Api.Instance.SetProvider(featureManagementProvider); var client = OpenFeature.Api.Instance.GetClient(); var val = await client.GetBooleanValueAsync("myBoolFlag", false, null); System.Console.WriteLine(val.ToString()); } } } ``` -------------------------------- ### Initialize flagd Provider with Default Configuration Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Initializes the flagd Provider using its default configuration, relying on environment variables for settings like host, port, and TLS. This is suitable when environment variables are pre-configured. ```csharp var flagdProvider = new FlagdProvider(); ``` -------------------------------- ### Configure Local NuGet Source for GitHub Packages Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/CONTRIBUTING.md Add a new NuGet package source named 'github-open-feature' using your GitHub email and authentication token. This command stores the password in clear text, so ensure your environment is secure. ```console $ dotnet nuget update source github-open-feature --username $(gh api user --jq .email) --password $(gh auth token) --store-password-in-clear-text Package source "github-open-feature" was successfully updated. ``` -------------------------------- ### Authenticate with GitHub CLI for Packages Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/CONTRIBUTING.md Use this command to log in to GitHub CLI with the necessary scope for reading packages. Follow the interactive prompts to complete the authentication process. ```console $ gh auth login --scopes read:packages ? What account do you want to log into? GitHub.com ? What is your preferred protocol for Git operations? HTTPS ? How would you like to authenticate GitHub CLI? Login with a web browser ! First copy your one-time code: ****-**** Press Enter to open github.com in your browser... ✓ Authentication complete. - gh config set -h github.com git_protocol https ✓ Configured git protocol ✓ Logged in as ******** ``` -------------------------------- ### Using a Custom TimeProvider with OpenFeature.Providers.Ofrep Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Ofrep/README.md Illustrates how to provide a custom TimeProvider for scenarios like testing or controlling time-related behaviors with the OFREP provider. ```csharp // Using a custom TimeProvider for testing var customTimeProvider = new FakeTimeProvider(); // From Microsoft.Extensions.TimeProvider.Testing var provider = new OfrepProvider(config, customTimeProvider); ``` -------------------------------- ### Create OFREP Provider Using Environment Variables Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Ofrep/README.md Instantiate the OFREP provider without explicit configuration. It automatically reads settings from environment variables. ```csharp using OpenFeature; using OpenFeature.Providers.Ofrep; // Create provider using environment variables (no explicit configuration needed) var provider = new OfrepProvider(); await Api.Instance.SetProviderAsync(provider); ``` -------------------------------- ### Basic ConfigCat Provider Usage Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.ConfigCat/README.md Initialize the ConfigCat provider with your SDK key and set it as the default provider for the OpenFeature SDK. Then, retrieve a boolean flag value. ```csharp using System; using ConfigCat.Client; using OpenFeature.Contrib.ConfigCat; var configCatProvider = new ConfigCatProvider("#YOUR-SDK-KEY#"); // Set the configCatProvider as the provider for the OpenFeature SDK await OpenFeature.Api.Instance.SetProviderAsync(configCatProvider); var client = OpenFeature.Api.Instance.GetClient(); var isAwesomeFeatureEnabled = await client.GetBooleanValueAsync("isAwesomeFeatureEnabled", false); if (isAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); } ``` -------------------------------- ### Initialize Flagsmith Provider with HttpClient Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flagsmith/README.md Create a Flagsmith provider instance by passing a pre-configured HttpClient. ```csharp using var httpClient = new HttpClient(); var flagsmithProvider = new FlagsmithProvider(providerConfig, config, httpClient); ``` -------------------------------- ### Add GOFeatureFlag Provider using Paket CLI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.GOFeatureFlag/README.md Add the OpenFeature.Providers.GOFeatureFlag package using the Paket CLI. ```shell paket add OpenFeature.Providers.GOFeatureFlag ``` -------------------------------- ### Configure and Use Unleash Provider with OpenFeature SDK Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Unleash/README.md Initialize the Unleash provider with settings and set it as the default provider for the OpenFeature SDK. Demonstrates boolean and variant payload evaluations. ```csharp using OpenFeature; using OpenFeature.Providers.Unleash; using Unleash; var settings = new UnleashSettings { AppName = "my-app", UnleashApi = new Uri("http://localhost:4242/api/"), CustomHttpHeaders = new Dictionary { { "Authorization", "*:development.your-api-token" } } }; var provider = new UnleashProvider(settings); // Set the provider for the OpenFeature SDK await Api.Instance.SetProviderAsync(provider); // Get an OpenFeature client var client = Api.Instance.GetClient(); // Boolean evaluation (uses IsEnabled) var enabled = await client.GetBooleanValueAsync("my-feature", false); // String evaluation (uses variant payload) var value = await client.GetStringValueAsync("my-variant-flag", "default"); // Integer evaluation (parses variant payload) var count = await client.GetIntegerValueAsync("my-int-flag", 0); // Double evaluation (parses variant payload) var rate = await client.GetDoubleValueAsync("my-double-flag", 0.0); ``` -------------------------------- ### Configure OFREP Provider with Dependency Injection Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Ofrep/README.md Integrate the OFREP provider into a .NET application using dependency injection. Configuration can be automatically loaded from IConfiguration, which includes environment variables. ```csharp // In Program.cs or Startup.cs builder.Configuration.AddEnvironmentVariables(); builder.Services.AddOpenFeature(featureBuilder => { featureBuilder.AddOfrepProvider(options => { // Options will fall back to OFREP_ENDPOINT, OFREP_HEADERS, OFREP_TIMEOUT_MS // from IConfiguration (which includes environment variables) }); }); ``` -------------------------------- ### Explicitly Load OFREP Options from Environment Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Ofrep/README.md Manually create OFREP options by reading directly from environment variables. This allows for explicit control over configuration loading. ```csharp using OpenFeature.Providers.Ofrep.Configuration; // Explicitly create options from environment variables var options = OfrepOptions.FromEnvironment(); var provider = new OfrepProvider(options); ``` -------------------------------- ### Initialize Flagsmith Provider with FlagsmithClient Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flagsmith/README.md Create a Flagsmith provider instance using an existing FlagsmithClient object. ```csharp using var flagsmithClient = new FlagsmithClient(flagsmithOptions); var flagsmithProvider = new FlagsmithProvider(providerConfig, flagsmithClient); ``` -------------------------------- ### Initialize flagd Provider with Unix Socket URI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Initializes the flagd Provider to communicate via a Unix domain socket. This is an alternative to HTTP communication, useful in specific deployment scenarios. ```csharp // ... or use the unix:// prefix if the provider should communicate via a unix socket var unixFlagdProvider = new FlagdProvider(new Uri("unix://socket.tmp")); ``` -------------------------------- ### Advanced Configuration for OpenFeature.Providers.Ofrep Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Ofrep/README.md Shows how to configure advanced options for the OFREP provider, including custom timeouts and headers. ```csharp // Advanced configuration var config = new OfrepOptions("https://feature-flags.example.com") { Timeout = TimeSpan.FromSeconds(10), Headers = new Dictionary { ["Custom-Header"] = "value", ["Api-Version"] = "v1" } }; // Create and register the provider var provider = new OfrepProvider(config); await Api.Instance.SetProviderAsync(provider); ``` -------------------------------- ### Configure flagd Provider Options with Dependency Injection Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Shows how to override default configuration options for the flagd Provider when using dependency injection. This allows specifying host, port, and other settings via configuration. ```csharp using OpenFeature; using OpenFeature.DependencyInjection.Providers.Flagd; namespace OpenFeatureTestApp { class Hello { static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); builder.Services.AddOpenFeature(config => { config.AddHostedFeatureLifecycle() .AddFlagdProvider(o => { o.Host = builder.Configuration["FlagdProviderOptions:Host"]; o.Port = int.Parse(builder.Configuration["FlagdProviderOptions:Port"] ?? "8013"); // other configurations can be set here }); }); var app = builder.Build(); // ... ommitted for brevity } } } ``` -------------------------------- ### Initialize GOFeatureFlag Provider and Evaluate Flag Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.GOFeatureFlag/README.md Initialize the GOFeatureFlag provider with the relay proxy endpoint and perform a boolean flag evaluation. Ensure the targeting key is set in the evaluation context. ```csharp using OpenFeature.Providers.GOFeatureFlag; var options = new GoFeatureFlagProviderOptions { Endpoint = "https://gofeatureflag.example.com" }; var provider = new GoFeatureFlagProvider(options); // Associate the provider with the OpenFeature API await Api.Instance.SetProviderAsync("client_test", provider); // Create a client to perform feature flag evaluations var client = Api.Instance.GetClient("client_test"); // targetingKey is mandatory for each evaluation var evaluationContext = EvaluationContext.Builder() .SetTargetingKey("d45e303a-38c2-11ed-a261-0242ac120002") .Set("email", "john.doe@gofeatureflag.org") .Build(); // Example of a boolean flag evaluation var myFeatureFlag = await client.GetBooleanDetailsAsync("my-feature-flag", false, evaluationContext); ``` -------------------------------- ### Generate Flipt REST Client using NSwag Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flipt/README.md Generate a C# REST client for the Flipt API using NSwag, specifying various generation options. ```shell nswag openapi2csclient /className:FliptRestClient /namespace:Flipt.Rest /input:"openapi.yaml" /output:"./Flipt.Rest.Client.cs" /GenerateExceptionClasses:true /OperationGenerationMode:SingleClientFromPathSegments /JsonLibrary:SystemTextJson /GenerateOptionalParameters:true /GenerateDefaultValues:true /GenerateResponseClasses:true /GenerateClientInterfaces:true /GenerateClientClasses:true /GenerateDtoTypes:true /ExceptionClass:FliptRestException /GenerateNativeRecords:true /UseBaseUrl:false /GenerateBaseUrlProperty:false ``` -------------------------------- ### Add GOFeatureFlag Provider using Package Reference Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.GOFeatureFlag/README.md Reference the OpenFeature.Providers.GOFeatureFlag package in your project file. ```xml ``` -------------------------------- ### Download OpenAPI Specification for Flipt Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.Flipt/README.md Use curl to download the latest openapi.yaml file from the Flipt GitHub repository. ```shell curl https://raw.githubusercontent.com/flipt-io/flipt/refs/heads/main/openapi.yaml -o openapi.yaml ``` -------------------------------- ### Initialize flagd Provider with HTTP URI Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.Flagd/README.md Initializes the flagd Provider by directly specifying the URI for HTTP communication with the flagd server. This provides explicit control over the connection endpoint. ```csharp // either communicate with Flagd over HTTP ... var flagdProvider = new FlagdProvider(new Uri("http://localhost:8013")); ``` -------------------------------- ### Use Environment Variable Provider with OpenFeature SDK Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.EnvVar/README.md Configure the OpenFeature SDK to use the Environment Variable provider and evaluate a boolean flag. An optional prefix can be provided to the provider's constructor. ```csharp using System; using OpenFeature; using OpenFeature.Contrib.EnvVar; // If you want to use a prefix for your environment variables, you can supply it in the constructor below. // For example, if you all your feature flag environment variables will be prefixed with feature-flag- then // you would use: // var envVarProvider = new EnvVarProvider("feature-flag-"); var envVarProvider = new EnvVarProvider(); // Set the Environment Variable provider as the provider for the OpenFeature SDK await OpenFeature.Api.Instance.SetProviderAsync(envVarProvider); var client = OpenFeature.Api.Instance.GetClient(); var isAwesomeFeatureEnabled = await client.GetBooleanValueAsync("isAwesomeFeatureEnabled", false); if (isAwesomeFeatureEnabled) { doTheNewThing(); } else { doTheOldThing(); } ``` -------------------------------- ### Add GOFeatureFlag Provider as Cake Addin or Tool Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.GOFeatureFlag/README.md Include the OpenFeature.Providers.GOFeatureFlag package as a Cake Addin or Tool. ```csharp // Install OpenFeature.Providers.GOFeatureFlag as a Cake Addin #addin nuget:?package=OpenFeature.Providers.GOFeatureFlag // Install OpenFeature.Providers.GOFeatureFlag as a Cake Tool #tool nuget:?package=OpenFeature.Providers.GOFeatureFlag ``` -------------------------------- ### Add ConfigCat Provider via Package Reference Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.ConfigCat/README.md Add the ConfigCat Feature Flag provider to your project using a Package Reference. ```xml ``` -------------------------------- ### Update to OpenFeature SDK v2.7.0+ Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Hooks.Otel/README.md Update your project to use OpenFeature SDK version 2.7.0 or later. ```xml ``` -------------------------------- ### Customize ConfigCat Provider Options Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.ConfigCat/README.md Customize the ConfigCat provider by providing a callback to configure `ConfigCatClientOptions`, such as setting polling mode and logger. ```csharp Action configureConfigCatOptions = (options) => { options.PollingMode = PollingModes.LazyLoad(cacheTimeToLive: TimeSpan.FromSeconds(10)); options.Logger = new ConsoleLogger(LogLevel.Info); // ... }; var configCatProvider = new ConfigCatProvider("#YOUR-SDK-KEY#", configureConfigCatOptions); ``` -------------------------------- ### Enable E2E Tests in appsettings.json Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/CONTRIBUTING.md To enable End-to-End integration tests, ensure this setting is present and set to true in your appsettings.json file. Alternatively, you can set the E2E environment variable to true. ```json { "E2E": "true" } ``` -------------------------------- ### Remove Deprecated Package Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Hooks.Otel/README.md Remove the OpenFeature.Contrib.Hooks.Otel package reference from your .csproj file. ```xml ``` -------------------------------- ### Check GitHub CLI Authentication Status Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/CONTRIBUTING.md Verify your current authentication status with GitHub CLI, including logged-in user, Git protocol configuration, and token scopes. ```console $ gh auth status github.com ✓ Logged in to github.com as ******** (~/.config/gh/hosts.yml) ✓ Git operations for github.com configured to use https protocol. ✓ Token: gho_************************************ ✓ Token scopes: gist, read:org, read:packages, repo, workflow ``` -------------------------------- ### Evaluate Different Feature Flag Types Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.GOFeatureFlag/README.md Demonstrates how to retrieve feature flag values of various types (Boolean, String, Integer, Double, Object) using the OpenFeature client. Ensure the correct accessor method is used for each flag type. ```csharp // Boolean client.GetBooleanValueAsync("my-flag", false, evaluationContext); // String client.GetStringValueAsync("my-flag", "default", evaluationContext); // Integer client.GetIntegerValueAsync("my-flag", 1, evaluationContext); // Double client.GetDoubleValueAsync("my-flag", 1.1, evaluationContext); // Object client.GetObjectValueAsync("my-flag", new Value("any value you want"), evaluationContext); ``` -------------------------------- ### Migrate OpenTelemetry Hooks in Code Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Hooks.Otel/README.md Update your code to use the new hook names and namespaces after migrating to OpenFeature SDK v2.7.0+. ```csharp using OpenFeature.Contrib.Hooks.Otel; // Add hooks OpenFeature.Api.Instance.AddHooks(new TracingHook()); OpenFeature.Api.Instance.AddHooks(new MetricsHook()); ``` ```csharp using OpenFeature.Hooks; // Add hooks with updated names OpenFeature.Api.Instance.AddHooks(new TraceEnricherHook()); OpenFeature.Api.Instance.AddHooks(new MetricsHook()); ``` -------------------------------- ### Shutdown OpenFeature Provider Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Contrib.Providers.ConfigCat/README.md Clean up the OpenFeature provider and the underlying ConfigCat client on application shutdown. ```csharp await OpenFeature.Api.Instance.ShutdownAsync(); ``` -------------------------------- ### Evaluate a Boolean Feature Flag Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/src/OpenFeature.Providers.GOFeatureFlag/README.md Use the OpenFeature client to retrieve a boolean value for a given flag key. Requires obtaining a client instance and providing a default value and evaluation context. ```csharp var client = Api.Instance.GetClient("client_test"); var myFeatureFlag = await client.GetBooleanValueAsync("my-feature-flag", false, evaluationContext); ``` -------------------------------- ### Disable E2E Tests in appsettings.json Source: https://github.com/open-feature/dotnet-sdk-contrib/blob/main/CONTRIBUTING.md To disable End-to-End integration tests, set this value to false in your appsettings.json file or remove the setting entirely. ```json { "E2E": "false" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.