diff --git a/src/Microsoft.FeatureManagement/FeatureFilterEvaluationContext.cs b/src/Microsoft.FeatureManagement/FeatureFilterEvaluationContext.cs
index 2591e667..a1f6ca99 100644
--- a/src/Microsoft.FeatureManagement/FeatureFilterEvaluationContext.cs
+++ b/src/Microsoft.FeatureManagement/FeatureFilterEvaluationContext.cs
@@ -15,6 +15,11 @@ public class FeatureFilterEvaluationContext
///
public string FeatureName { get; set; }
+ ///
+ /// The index of the feature filter this context is being used for.
+ ///
+ public int FilterIndex { get; set; }
+
///
/// The settings provided for the feature filter to use when evaluating whether the feature should be enabled.
///
diff --git a/src/Microsoft.FeatureManagement/FeatureManager.cs b/src/Microsoft.FeatureManagement/FeatureManager.cs
index c0090fe6..0101e7bf 100644
--- a/src/Microsoft.FeatureManagement/FeatureManager.cs
+++ b/src/Microsoft.FeatureManagement/FeatureManager.cs
@@ -115,10 +115,16 @@ private async Task IsEnabledAsync(string feature, TContext appCo
// We iterate until we hit our target evaluation
bool targetEvaluation = !enabled;
+ //
+ // Keep track of the index of the filter we are evaluating
+ int filterIndex = -1;
+
//
// For all enabling filters listed in the feature's state, evaluate them according to requirement type
foreach (FeatureFilterConfiguration featureFilterConfiguration in featureDefinition.EnabledFor)
{
+ filterIndex++;
+
//
// Handle AlwaysOn filters
if (string.Equals(featureFilterConfiguration.Name, "AlwaysOn", StringComparison.OrdinalIgnoreCase))
@@ -151,6 +157,7 @@ private async Task IsEnabledAsync(string feature, TContext appCo
var context = new FeatureFilterEvaluationContext()
{
FeatureName = feature,
+ FilterIndex = filterIndex,
Parameters = featureFilterConfiguration.Parameters
};
@@ -220,10 +227,12 @@ private void BindSettings(IFeatureFilterMetadata filter, FeatureFilterEvaluation
object settings;
ConfigurationCacheItem cacheItem;
-
+
+ string cacheKey = $"{context.FeatureName}.{context.FilterIndex}";
+
//
// Check if settings already bound from configuration or the parameters have changed
- if (!_parametersCache.TryGetValue(context.FeatureName, out cacheItem) ||
+ if (!_parametersCache.TryGetValue(cacheKey, out cacheItem) ||
cacheItem.Parameters != context.Parameters)
{
settings = binder.BindParameters(context.Parameters);
@@ -231,7 +240,7 @@ private void BindSettings(IFeatureFilterMetadata filter, FeatureFilterEvaluation
if (_featureDefinitionProvider is IFeatureDefinitionProviderCacheable)
{
_parametersCache.Set(
- context.FeatureName,
+ cacheKey,
new ConfigurationCacheItem
{
Settings = settings,