open-feature / open-feature/cli

Add integration for C# using a custom .NET Source Generator for flag calls

Open
#171 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
63
Forks
22
Avg merge
1h 27m
Merged PRs (30d)
19

Description

Summary

Propose adding a new integration for C# to the CLI that leverages a custom .NET Source Generator. This generator will automatically create code for feature flag calls, streamlining flag management and usage in C# projects. We would keep the current csharp generation in the CLI but adding a new one for the source generators.

Motivation

  • Enable seamless integration of OpenFeature in C# projects by automating the generation of flag call code.
  • Reduce boilerplate and potential errors in flag usage.
  • Improve developer productivity and code maintainability.

Approach

  • Design and implement a custom .NET Source Generator that can parse feature flag definitions and generate corresponding C# code for flag calls.
  • Integrate this workflow into the OpenFeature CLI so C# developers can easily set up and use this functionality.
  • Provide documentation and usage examples for the new integration.

Tasks

  • Research .NET Source Generators and their integration points with OpenFeature.
  • Define the input format and configuration for flag definitions. I suggest using Attributes.
  • Implement the source generator logic.
  • Update the CLI to support C# integration using the generator.
  • Write documentation and sample usage code.

Additional Context

This enhancement would provide first-class support for C# developers using OpenFeature, leveraging modern .NET tooling to make flag usage safer and more efficient.

Example of generated code by CLI

using OpenFeature.Extensions.SourceGenerator;

[FeatureFlag]
private bool IsEnabled;

By leveraging source generators for the C# implementation, it would give more flexibility because anyone could potentially make use of it, even without using the CLI.

Notes

More info: https://devblogs.microsoft.com/dotnet/introducing-c-source-generators/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the CLI's existing C# generation and the linked .NET Source Generators material. Define the attribute-based flag input and integration points before implementing the generator and CLI support. Done includes working generated C# calls, documentation, and sample usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.