Skip to content

Conversation

@kylejuliandev
Copy link
Contributor

This PR

  • This adds a new OpenFeatureBuilder extension method to add global or not domain-bound hooks to the OpenFeature Api.

Related Issues

Fixes #456

Notes

We inject any provided Hooks as Singletons in the DI container. We use keyed singletons and use the class name as the key. Maybe we'd want to use a different name to avoid conflicts?

I've done some manual testing with a sample weatherforecast ASP.NET Core web application

Follow-up Tasks

How to test

Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
@kylejuliandev kylejuliandev requested a review from a team as a code owner April 29, 2025 19:30
@codecov
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.72%. Comparing base (8e3ae54) to head (e054faa).
Report is 1 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@ ## main #459 +/- ## ========================================== + Coverage 86.47% 86.72% +0.25%  ========================================== Files 42 42 Lines 1671 1703 +32 Branches 177 179 +2 ========================================== + Hits 1445 1477 +32  Misses 187 187 Partials 39 39 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
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.

Looks good to me. Please look into the suggestions!

* This will allow consumers to easily add Hooks without forcing them to write a function everytime they do Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
@askpt
Copy link
Member

askpt commented May 1, 2025

I forgot to add it. Can you please update the Readme as part of this PR?

Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
* Add unit tests to cover off new AddHook extension method Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
@askpt askpt added this pull request to the merge queue May 6, 2025
Merged via the queue into open-feature:main with commit 9b04485 May 6, 2025
18 of 19 checks passed
@kylejuliandev kylejuliandev deleted the feat/add-hook-via-dependencyinjection branch May 6, 2025 17:21
WeihanLi pushed a commit to WeihanLi/openfeature-dotnet-sdk that referenced this pull request May 14, 2025
…tion (open-feature#459) <!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR <!-- add the description of the PR here --> - This adds a new OpenFeatureBuilder extension method to add global or not domain-bound hooks to the OpenFeature Api. ### Related Issues <!-- add here the GitHub issue that this PR resolves if applicable --> Fixes open-feature#456 ### Notes <!-- any additional notes for this PR --> We inject any provided Hooks as Singletons in the DI container. We use keyed singletons and use the class name as the key. Maybe we'd want to use a different name to avoid conflicts? I've done some manual testing with a sample weatherforecast ASP.NET Core web application ### Follow-up Tasks <!-- anything that is related to this PR but not done here should be noted under this section --> <!-- if there is a need for a new issue, please link it here --> ### How to test <!-- if applicable, add testing instructions under this section --> --------- Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com> Co-authored-by: André Silva <2493377+askpt@users.noreply.github.com> Signed-off-by: Weihan Li <weihanli@outlook.com>
github-merge-queue bot pushed a commit that referenced this pull request May 23, 2025
🤖 I have created a release *beep* *boop* --- ## [2.6.0](v2.5.0...v2.6.0) (2025-05-23) ### ✨ New Features * add AddHandler extension method to Dependency Injection package ([#462](#462)) ([ff414b8](ff414b8)) * Add Extension Method for adding global Hook via DependencyInjection ([#459](#459)) ([9b04485](9b04485)) * Add OTEL compatible telemetry object builder ([#397](#397)) ([6c44db9](6c44db9)) ### 🧹 Chore * Cleanup .props file ([#476](#476)) ([6d7a535](6d7a535)) * **deps:** update actions/attest-build-provenance action to v2.3.0 ([#464](#464)) ([0a5ab0c](0a5ab0c)) * **deps:** update codecov/codecov-action action to v5.4.3 ([#475](#475)) ([fbcf3a4](fbcf3a4)) * **deps:** update github/codeql-action digest to 60168ef ([#463](#463)) ([ea76351](ea76351)) * **deps:** update github/codeql-action digest to ff0a06e ([#473](#473)) ([af1b20f](af1b20f)) * **deps:** update spec digest to edf0deb ([#474](#474)) ([fc3bdfe](fc3bdfe)) ### 📚 Documentation * Add AspNetCore sample app ([#477](#477)) ([9742a0d](9742a0d)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com> Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com> Co-authored-by: André Silva <2493377+askpt@users.noreply.github.com>
This was referenced Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants