fix(208): dotnet dependency injection issue#209
fix(208): dotnet dependency injection issue#209tomflenner wants to merge 2 commits intoopen-feature:mainfrom
Conversation
Signed-off-by: backtrack5r3 <flennertom@gmail.com>
Signed-off-by: backtrack5r3 <flennertom@gmail.com>
Summary of ChangesHello @tomflenner, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a dependency injection problem within the generated .NET SDK, specifically addressing the inability to resolve Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
6400da3 to
af0907a
Compare
There was a problem hiding this comment.
Code Review
This pull request effectively resolves the dependency injection issue in the generated .NET code by explicitly registering IFeatureClient with its concrete implementation FeatureClient. The changes in the csharp.tmpl correctly propagate to the generated files, and the integration test Program.cs has been updated to use the new AddOpenFeature() extension method, which is a good practice. The fix aligns with .NET best practices for DI and improves the robustness of the generated code.
kriscoleman
left a comment
There was a problem hiding this comment.
lgtm, thanks for finding this and fixing it!
|
Please, don't use
OpenFeature CLI reality,
|
|
Thanks for the reminder @erka. It looks like I can't edit the PR title myself, if someone can change the scope from |

This PR
Fixes the dependency injection issue in the generated .NET code where
IFeatureClientcould not be resolved from the DI container.FeatureClientwith its interface typeIFeatureClient.AddSingleton(provider => ...)to.AddSingleton<IFeatureClient, FeatureClient>(provider => ...)GeneratedClientrequestsIFeatureClientin its constructorRelated Issues
Fixes #208
Notes
The fix is minimal and only affects the generated DI registration code. The change follows .NET best practices by registering services against their interface types rather than concrete implementations, which allows the DI container to properly resolve
IFeatureClientwhen constructingGeneratedClient.How to test
AddOpenFeatureextension method includes the interface type in the registration:System.InvalidOperationExceptionGeneratedClientcan be resolved and injected successfully