microsoft / microsoft/FeatureManagement-Dotnet

How to programmatically create an “always enabled” FeatureDefinition?

Open
#576 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
1.2k
Forks
129
Avg merge
1d 1h
Merged PRs (30d)
5

Description

I’m implementing a custom IFeatureDefinitionProvider that reads features from a database or an HTTP service instead of JSON configuration. My goal is to represent a feature that is always enabled, equivalent to this JSON:

"FeatureA": {
    "enabled": true
}

Looking at the source (ConfigurationFeatureDefinitionProvider.ParseMicrosoftSchemaFeatureDefinition), the library seems to convert such JSON into a FeatureDefinition with:

  • Status = FeatureStatus.Conditional
  • EnabledFor containing a single FeatureFilterConfiguration with Name = "AlwaysOn"

Example based on my understanding:

var featureEnabled = new FeatureDefinition
{
    Name = "FeatureA",
    EnabledFor = new List<FeatureFilterConfiguration>
    {
        new FeatureFilterConfiguration { Name = "AlwaysOn" }
    },
    Status = FeatureStatus.Conditional
};

My questions:

  1. Is this the correct/recommended way to create a feature that is always enabled without defining any conditions?
  2. Is there an official API or helper for this, so I don’t have to replicate the logic from ConfigurationFeatureDefinitionProvider?
  3. Are there any docs explaining this behavior?

I want to make sure my IFeatureDefinitionProvider correctly handles “always enabled” features without relying on JSON files.

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ConfigurationFeatureDefinitionProvider.ParseMicrosoftSchemaFeatureDefinition and the FeatureDefinition and IFeatureDefinitionProvider APIs. Trace how the JSON example is represented, then check whether a public helper or documentation covers constructing the equivalent definition. Done means a maintainer-verified answer describing the supported construction and its semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.