Conversation
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…Api class Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #740 +/- ##
==========================================
+ Coverage 93.46% 93.51% +0.05%
==========================================
Files 68 68
Lines 2952 2975 +23
Branches 350 354 +4
==========================================
+ Hits 2759 2782 +23
Misses 135 135
Partials 58 58 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request implements isolated API instances, enabling the creation of independent OpenFeature API instances that maintain their own providers, hooks, and evaluation contexts. The implementation includes a thread-safe mechanism to prevent a single provider from being registered with multiple API instances concurrently. Documentation, usage samples, and extensive unit and AOT compatibility tests have been added. Feedback highlights a potential NullReferenceException in the provider ownership validation if a null provider is passed to the registration methods.
…olated API tests Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva 2493377+askpt@users.noreply.github.com
This PR
This pull request introduces support for isolated API instances in the OpenFeature .NET SDK, enabling the creation of independent API objects that do not share state with the global singleton. This is particularly useful for testing, multi-tenant applications, and dependency injection scenarios. The changes also enforce provider ownership rules to prevent a provider from being registered with more than one API instance at a time, and update documentation and tests to demonstrate and verify this new functionality.
Isolated API Instance Support:
Api.CreateIsolated()that creates a fully independentApiinstance, with its own providers, context, hooks, and event handlers. These instances do not share state with the global singleton or with each other._boundApiInstancefield toFeatureProviderand validating that a provider is not registered with more than one API instance at a time. Attempts to do so will throw anInvalidOperationException. Ownership is cleared when a provider is shut down. [1] [2] [3] [4] [5] [6]Documentation and Sample Updates:
samples/Console/README.mdandsamples/Console/app.csto demonstrate the creation and use of isolated API instances, including example flag definitions and evaluation. [1] [2]Testing Enhancements:
TestIsolatedApiAsync()intest/OpenFeature.AotCompatibility/Program.csto verify the creation, independence, and shutdown of isolated API instances. [1] [2]Related Issues
Fixes #734