Skip to content

Conversation

@kriscoleman
Copy link
Collaborator

@kriscoleman kriscoleman commented Apr 6, 2025

This PR

  • Adds a C# generator to the OpenFeature CLI that generates type-safe clients compatible with the OpenFeature .NET SDK
  • Includes Docker-based integration testing to validate C# code compilation

Related Issues

Contributes to #32

Notes

The C# generator follows the same pattern as the existing generators (Go, Node.js, React) and produces code compatible withnOpenFeature .NET SDK 2.0.0. The generator:

  • Maps flag types correctly to C# types (int, double, bool, string)
  • Handles nullable reference types with C# 8+ syntax
  • Includes proper XML documentation for IntelliSense support
  • Uses the correct Async method signatures expected by the .NET SDK

Follow-up Tasks

  • Consider adding support for enums and structured types (object flags) when needed
  • Update documentation to include C# generator usage examples
  • Consider adding more integration tests for the other languages we support, to validate the generated code is usable by those languages.

How to test

  1. Build the CLI:
    go build

  2. Generate a C# client using a sample manifest:
    ./cli generate csharp --manifest=sample/sample_manifest.json --namespace=MyApp.OpenFeature

  3. Run the integration test to verify compilation:
    make test-csharp (also, this is captured in a new github action workflow which should pass on this PR)

@kriscoleman kriscoleman force-pushed the feat/csharp-gen branch 4 times, most recently from e4c3479 to 3f5dab2 Compare April 6, 2025 18:03
@beeme1mr beeme1mr requested review from askpt, beeme1mr and weyert April 7, 2025 08:59
Copy link
Member

@askpt askpt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I added a few small comments. Mostly nitpicks and potential improvements! Great contribution! 👍

@kriscoleman
Copy link
Collaborator Author

Thanks for all the feedback @beeme1mr and @askpt!

I'll work in some changes very soon and update when completed

kriscoleman and others added 7 commits April 14, 2025 11:42
Adds a new generator for C# to create typesafe clients.
This allows users to generate C# code based on feature flag
definitions, streamlining integration with .NET applications.
Includes necessary command-line flags, templates, and tests.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
Adds a C# code generator integration test to ensure the generated C# code compiles correctly.

This includes:
- A new C# generator based on templates
- Updates to the build process and documentation to support C# generation and testing
- An integration test using Docker to compile the generated C# code
- Fixes and adjustments to data type mappings for C# compatibility

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
Co-authored-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: Kris Coleman <kris.blacksuitmedia@gmail.com>
Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
Co-authored-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: Kris Coleman <kris.blacksuitmedia@gmail.com>
Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
Co-authored-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: Kris Coleman <kris.blacksuitmedia@gmail.com>
Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
…parate job

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
@kriscoleman
Copy link
Collaborator Author

I just rebased, addressed conflicts, and worked on the enhancements from feedback.

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
- updated openfeature to 2.3.2
- introduced IServiceCollection and DI patterns
- updated tests and expectations

Signed-off-by: Kris Coleman <kriscodeman@gmail.com>
kriscoleman and others added 2 commits April 14, 2025 13:39
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Signed-off-by: Kris Coleman <kris.blacksuitmedia@gmail.com>
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Signed-off-by: Kris Coleman <kris.blacksuitmedia@gmail.com>
@kriscoleman kriscoleman added this pull request to the merge queue Apr 14, 2025
Merged via the queue into open-feature:main with commit ae64581 Apr 14, 2025
6 checks passed
@beeme1mr beeme1mr mentioned this pull request Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants