From 22d142afe54c6a2c2799e80815d30a1a1784d3f0 Mon Sep 17 00:00:00 2001 From: Zhiyuan Liang Date: Sun, 16 Aug 2026 23:04:27 +0800 Subject: [PATCH 1/2] fix isenabled null context bug --- src/Microsoft.FeatureManagement/FeatureManager.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Microsoft.FeatureManagement/FeatureManager.cs b/src/Microsoft.FeatureManagement/FeatureManager.cs index 91605ecb..e217fc80 100644 --- a/src/Microsoft.FeatureManagement/FeatureManager.cs +++ b/src/Microsoft.FeatureManagement/FeatureManager.cs @@ -155,6 +155,11 @@ public async Task IsEnabledAsync(string feature) /// True if the feature is enabled, otherwise false. public async Task IsEnabledAsync(string feature, TContext appContext) { + if (appContext is null) + { + throw new ArgumentNullException(nameof(appContext)); + } + return (await EvaluateFeature(feature, context: appContext, useContext: true, CancellationToken.None).ConfigureAwait(false)).Enabled; } @@ -178,6 +183,11 @@ public async ValueTask IsEnabledAsync(string feature, CancellationToken ca /// True if the feature is enabled, otherwise false. public async ValueTask IsEnabledAsync(string feature, TContext appContext, CancellationToken cancellationToken = default) { + if (appContext is null) + { + throw new ArgumentNullException(nameof(appContext)); + } + return (await EvaluateFeature(feature, context: appContext, useContext: true, cancellationToken).ConfigureAwait(false)).Enabled; } From 35337962201129f243bde34041eb91780a014fb8 Mon Sep 17 00:00:00 2001 From: Zhiyuan Liang Date: Wed, 19 Aug 2026 14:43:48 +0800 Subject: [PATCH 2/2] update --- src/Microsoft.FeatureManagement/FeatureManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.FeatureManagement/FeatureManager.cs b/src/Microsoft.FeatureManagement/FeatureManager.cs index e217fc80..f7bca84a 100644 --- a/src/Microsoft.FeatureManagement/FeatureManager.cs +++ b/src/Microsoft.FeatureManagement/FeatureManager.cs @@ -155,7 +155,7 @@ public async Task IsEnabledAsync(string feature) /// True if the feature is enabled, otherwise false. public async Task IsEnabledAsync(string feature, TContext appContext) { - if (appContext is null) + if (appContext == null) { throw new ArgumentNullException(nameof(appContext)); } @@ -183,7 +183,7 @@ public async ValueTask IsEnabledAsync(string feature, CancellationToken ca /// True if the feature is enabled, otherwise false. public async ValueTask IsEnabledAsync(string feature, TContext appContext, CancellationToken cancellationToken = default) { - if (appContext is null) + if (appContext == null) { throw new ArgumentNullException(nameof(appContext)); }