Skip to content

Unable to create both IFeatureFilter and IContextualFeatureFilter with same FilterAlias. #98

@aforank

Description

@aforank

When I create an implementation for both IFeatureFilter and IContextualFeatureFilter with same FilterAlias. I get the below exception

Multiple feature filters match the configured filter named

Use case
I created two feature filter with same filter alias as follows

[FilterAlias("CompanyFilter")]
public class HttpCompanyFilter : IFeatureFilter
{
	public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context)
	{
		// Return flag based on http context;
	}
}
[FilterAlias("CompanyFilter")]
public class CompanyContextFilter : IContextualFeatureFilter<CompanyContext>
{
	public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureFilterContext, CompanyContext companyContext)
	{
		// Return flag based on CompanyContext parameter;
	}
}

In some situations where I know that HTTP context will always be available, I want to call the feature manager without passing any context. This should call a filter which implements IFeatureFilter

await featureFlagManager.IsEnabledAsync("FeatureA");

However, in some cases, I do not have the HTTP context available, so I would like to call the feature manager by passing the app context this time. This should call a filter which implements IContextualFeatureFilter<CompanyContext>

var context = new CompanyContext()
{
 Code = "SomeValue"
};

await featureFlagManager.IsEnabledAsync("FeatureA", context);

I also tried to create a single filter implementing both IFeatureFilter and IContextualFeatureFilterbut apparently this is also not allowed by the framework.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions