Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private FeatureDefinition GetMicrosoftSchemaFeatureDefinition(string featureName
IEnumerable<IConfigurationSection> microsoftFeatureDefinitionSections = GetMicrosoftFeatureDefinitionSections();

IConfigurationSection configuration = microsoftFeatureDefinitionSections
.FirstOrDefault(section =>
.LastOrDefault(section =>
string.Equals(section[MicrosoftFeatureManagementFields.Id], featureName, StringComparison.OrdinalIgnoreCase));

if (configuration == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
]
}
}
}
}
20 changes: 20 additions & 0 deletions tests/Tests.FeatureManagement/FeatureManagementTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,26 @@ public async Task CustomFeatureDefinitionProvider()

Assert.True(called);
}

[Fact]
public async Task LastFeatureFlagWins()
{
IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();

IServiceCollection services = new ServiceCollection();

services
.AddSingleton(configuration)
.AddFeatureManagement();

ServiceProvider serviceProvider = services.BuildServiceProvider();

IFeatureManager featureManager = serviceProvider.GetRequiredService<IFeatureManager>();

Assert.True(await featureManager.IsEnabledAsync(Features.DuplicateFlag));
}
}

public class FeatureManagementFeatureFilterGeneralTest
Expand Down
1 change: 1 addition & 0 deletions tests/Tests.FeatureManagement/Features.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ static class Features
public const string OnTelemetryTestFeature = "OnTelemetryTestFeature";
public const string OffTelemetryTestFeature = "OffTelemetryTestFeature";
public const string ContextualFeatureWithVariant = "ContextualFeatureWithVariant";
public const string DuplicateFlag = "DuplicateFlag";
}
}
8 changes: 8 additions & 0 deletions tests/Tests.FeatureManagement/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,14 @@
"default_when_enabled": "Big",
"default_when_disabled": "Small"
}
},
{
"id": "DuplicateFlag",
"enabled": false
},
{
"id": "DuplicateFlag",
"enabled": true
}
]
}
Expand Down