Skip to content

fix: Change registration to use the Isolated API instead of global singleton#760

Merged
askpt merged 3 commits into
mainfrom
askpt/issue759
May 22, 2026
Merged

fix: Change registration to use the Isolated API instead of global singleton#760
askpt merged 3 commits into
mainfrom
askpt/issue759

Conversation

@askpt

@askpt askpt commented May 21, 2026

Copy link
Copy Markdown
Member

This PR

This pull request updates how the OpenFeature API instance is registered within the dependency injection container. Instead of registering the global Api.Instance, it now registers an isolated API instance using OpenFeatureFactory.CreateIsolated(). This ensures that all components in the application share the same isolated instance, allowing for better lifecycle management and isolation from global state.

Dependency injection and API registration:

  • Replaced registration of the global Api.Instance singleton with an isolated API instance created by OpenFeatureFactory.CreateIsolated() in AddOpenFeature to ensure application-wide isolation and improved lifecycle management.
  • Added using OpenFeature.Isolated; to support the creation of isolated API instances.

Related Issues

Fixes #759

askpt added 2 commits May 21, 2026 20:39
…ce collection

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…ce to clarify lifecycle management

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
@codecov

codecov Bot commented May 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.52%. Comparing base (5623a0f) to head (f7cac98).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #760   +/-   ##
=======================================
  Coverage   93.52%   93.52%           
=======================================
  Files          69       69           
  Lines        2981     2981           
  Branches      355      355           
=======================================
  Hits         2788     2788           
  Misses        135      135           
  Partials       58       58           

☔ 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the OpenFeature service registration to use an isolated API instance instead of the global singleton. Feedback suggests using a factory delegate for the singleton registration to avoid unnecessary object allocation and recommends shortening the verbose warning suppression comment for better readability.

Comment thread src/OpenFeature.Hosting/OpenFeatureServiceCollectionExtensions.cs
…ambda expression

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
@askpt
askpt marked this pull request as ready for review May 21, 2026 20:25
@askpt
askpt requested a review from a team as a code owner May 21, 2026 20:25
@askpt
askpt added this pull request to the merge queue May 22, 2026
Merged via the queue into main with commit f875bc3 May 22, 2026
24 checks passed
@askpt
askpt deleted the askpt/issue759 branch May 22, 2026 07:52
@gkinsman

Copy link
Copy Markdown

Thanks for fixing this!

@im-aIex

im-aIex commented Jun 2, 2026

Copy link
Copy Markdown

any estimate on when this fix will be published?

@askpt

askpt commented Jun 2, 2026

Copy link
Copy Markdown
Member Author

any estimate on when this fix will be published?

@im-aIex hey! I'm waiting on this PR #755. As soon as it gets merged, I will release a new version.

This was referenced Jul 16, 2026
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.

[BUG] DI Regression with deprecation of OpenFeature.DependencyInjection

5 participants