Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 2.16 KB

File metadata and controls

45 lines (29 loc) · 2.16 KB

OpenFeature .NET Console Sample

This sample demonstrates how to use the OpenFeature .NET SDK in a console application. It includes a simple .NET 10 console app that defines several feature flags using the InMemoryProvider and evaluates them across all supported flag types: bool, int, string, double, and object.

The sample can easily be extended with alternative providers, which you can find in the dotnet-sdk-contrib repository.

Prerequisites

Setup

  1. Clone the repository:

    git clone https://github.com/open-feature/dotnet-sdk.git openfeature-dotnet-sdk
  2. Navigate to the Console sample project directory:

    cd openfeature-dotnet-sdk/samples/Console
  3. Run the following command to start the application:

    dotnet run app.cs

Feature Flags

The sample defines the following flags using the InMemoryProvider:

Flag Key Type Variants Default Variant
bool-flag bool ontrue, offfalse on
numeric-flag int one1, two2 one
string-flag string greeting"Hello, World!", farewell"Goodbye, World!" greeting
float-flag double pi3.14159, euler0.577215 pi
object-flag object user1"Ralph", user2"Lewis" user2

NativeAOT

This sample is published with NativeAOT enabled (PublishAot=true), demonstrating that the OpenFeature .NET SDK is fully compatible with NativeAOT compilation. See the AOT Compatibility Guide for more details.