Conversation
| break; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
I also think that if there is no value in the session manager, then it should be written to what the feature manager returns, i.e. the default value.
FeatureManagement-Dotnet/src/Microsoft.FeatureManagement/FeatureManager.cs
Lines 275 to 278 in 57f5f93
There was a problem hiding this comment.
The current logic is that if feature definition is not null, then feature manager will do the feature evaluation and the result will be set to session manager.
Did I miss something?
There was a problem hiding this comment.
It doesn't matter whether a feature definition exists; if the feature manager returns a result and doesn't throw an exception, the same result must be set in the session manager.
Test case
- Check the boolean feature x in the feature manager.
- There is no definition for feature x.
- There is no previously saved result in the session manager.
- The default result "false" stored in the session manager
- The feature manager returns the default result "false"
Step 4 is currently missing.
There was a problem hiding this comment.
It doesn't matter whether a feature definition exists; if the feature manager returns a result and doesn't throw an exception, the same result must be set in the session manager.
I believe this is the current behavior (when feature definition is not null).
We introduced the bug in v4. The bug is when feature definition is null, the result won't be set to session manage, I explained it in this comment
There was a problem hiding this comment.
[Fact]
public async Task SetResultInSessionManagerWhenFeatureDefinitionIsNull()
{
IConfiguration config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var services = new ServiceCollection();
ISessionManager sessionManager = new TestSessionManager();
services
.AddSingleton(config)
.AddSingleton<ISessionManager>(sessionManager)
.AddFeatureManagement();
ServiceProvider serviceProvider = services.BuildServiceProvider();
IFeatureManager featureManager = serviceProvider.GetRequiredService<IFeatureManager>();
// session manager is clean here
var result = await featureManager.IsEnabledAsync("UnexistedFeature");
// session manager should store the result after evaluation
Assert.AreEqual(result, await sessionManager.GetAsync("UnexistedFeature"));
}There was a problem hiding this comment.
I see. Updated. Thanks!
Why this PR?
#580