Skip to content

feat(variants): allow in-memory objects - #615

Open
Степан (Stepami) wants to merge 2 commits into
microsoft:mainfrom
Stepami:feature/variants-params
Open

feat(variants): allow in-memory objects#615
Степан (Stepami) wants to merge 2 commits into
microsoft:mainfrom
Stepami:feature/variants-params

Conversation

@Stepami

Copy link
Copy Markdown

Why this PR?

Implementing IFeatureDefinitionProvider makes it inconvinient to fill variant bound values if they don't come from configuration.

Similarly to feature filters I decided to introduce an object that can be used as an alternative ConfigurationValue. Custom IFeatureDefinitionProvider implementations can populate this property directly instead of constructing an IConfigurationSection instance.

Visible Changes

  • Microsoft.FeatureManagement.VariantDefinition.ConfigurationObject
  • Microsoft.FeatureManagement.Variant.ConfigurationObject

@Stepami

Copy link
Copy Markdown
Author

Hey, Zhiyuan Liang (@zhiyuanliang-ms)! could you take a look please?

@zhiyuanliang-ms

Copy link
Copy Markdown
Member

My understanding is that this enhancement is intended specifically for the custom feature definition provider scenario. Is that correct?

@Stepami

Степан (Stepami) commented Aug 26, 2026

Copy link
Copy Markdown
Author

My understanding is that this enhancement is intended specifically for the custom feature definition provider scenario. Is that correct?

yes it is. right now i am implementing a custom provider. i need to do something like this in order to put data from an external storage into the definition:

new VariantDefinition
{
    Name = "...",
    ConfigurationValue =
        new ConfigurationBuilder()
            .AddInMemoryCollection([new("Value", variantValue.ToString())])
            .Build()
            .GetSection("Value")
}

@Stepami

Copy link
Copy Markdown
Author

And the idea came to me from the FeatureFilterConfiguration class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants