Make precedence source ordered - #623
linglingye001 wants to merge 3 commits into
Conversation
|
|
||
| private void LoadFeatureDefinitionSections() | ||
| { | ||
| _dotnetFeatureDefinitionSections = GetDotnetFeatureDefinitionSections(); |
There was a problem hiding this comment.
_dotnetFeatureDefinitionSections comes from the aggregated _configuration, while the winning schema is determined source by source.
I would expect that when custom merging is enabled, .NET feature flag sections should also be collected source by source. The current implementation is kind of inconsistant
| IConfigurationSection dotnetFeatureManagementSection = configuration | ||
| .GetSection(DotnetFeatureManagementFields.FeatureManagementSectionName); | ||
|
|
||
| foreach (IConfigurationSection featureSection in dotnetFeatureManagementSection.GetChildren()) |
There was a problem hiding this comment.
Previously, ConfigurationFeatureDefinitionProvider kept two responsibilities separate:
- Loading feature definition configuration sections.
- Parsing those sections into feature definitions.
_dotnetFeatureDefinitionSections and _microsoftFeatureDefinitionSections acted as the ground truth, and the contents were interpreted only when feature definitions were requested.
In the current implementation, the loading phase also partially parse the feature definitions while traversing the configuration sources. It reads feature flag IDs to maintain _featureDefinitionSchemas.
There was a problem hiding this comment.
I think we can use the following data structure to maintain feature definition sections grouped by configuration source:
private IEnumerable<FeatureDefinitionSectionsBySource> _featureDefinitionSources;
private class FeatureDefinitionSectionsBySource
{
public IEnumerable<IConfigurationSection> DotnetSections { get; }
public IEnumerable<IConfigurationSection> MicrosoftSections { get; }
}When getting a feature definition, we can traverse the configuration sources from highest to lowest precedence. Within each source, we check the Microsoft schema first, then .NET schema.
There was a problem hiding this comment.
Grouping sections by source would retain the information needed for precedence without a separate schema map. I think it is a cleaner design.
Why this PR?
Fix #621
ConfigurationFeatureDefinitionProvideralways evaluates the Microsoft schema first, source order is never consulted when the same flag is split across schemas. A Microsoft-schema definition from the first provider beats a .NET-schema definition from every later provider.Visible Changes
Example
When custom merging is enabled:
Provider` 1: Microsoft schema → MyFlag = false
Provider 2: .NET schema → MyFlag = targeting filter
Winning schema map:
MyFlag → .NET
Result: Provider 2 wins and the targeting filter is parsed.