Skip to content

Commit 808d669

Browse files
committed
Improve feature filter naming to avoid potential collisions
A filter simply named "FeatureFilter" as an alias might collide with consumers that also use filters for their own functionality. So we make it more unique. Also, since leveraging feature flags is something we use as an internal implementation detail, we make the FeatureFlags enum internal instead, since it's not intended for public consumption.
1 parent eedb621 commit 808d669

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/WhatsApp/FeatureFilter.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ namespace Devlooped.WhatsApp;
1111
/// application's dependency injection container. It supports evaluating features such as <see
1212
/// cref="FeatureFlags.Storage"/> and <see cref="FeatureFlags.Conversation"/>.</remarks>
1313
/// <param name="serviceProvider"></param>
14-
[FilterAlias(nameof(FeatureFilter))]
14+
[FilterAlias(Alias)]
1515
public class FeatureFilter(IServiceProvider serviceProvider) : IFeatureFilter
1616
{
17+
public const string Alias = "whatsapp_features";
18+
1719
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context)
1820
{
1921
var result = default(bool);
@@ -36,8 +38,8 @@ public static void AddFeatures(this IServiceCollection services, IConfiguration
3638
.AddConfiguration(configuration)
3739
.AddInMemoryCollection(new Dictionary<string, string?>
3840
{
39-
{ $"FeatureManagement:{FeatureFlags.Storage.ToString()}:EnabledFor:0:Name", nameof(FeatureFilter) },
40-
{ $"FeatureManagement:{FeatureFlags.Conversation.ToString()}:EnabledFor:0:Name", nameof(FeatureFilter) }
41+
{ $"FeatureManagement:{FeatureFlags.Storage}:EnabledFor:0:Name", FeatureFilter.Alias },
42+
{ $"FeatureManagement:{FeatureFlags.Conversation}:EnabledFor:0:Name", FeatureFilter.Alias }
4143
})
4244
.Build();
4345

src/WhatsApp/FeatureFlags.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Devlooped.WhatsApp;
77
/// </summary>
88
/// <remarks>Feature flags are used to control the availability of specific features within the application. Use
99
/// this enumeration to specify which features are being targeted for configuration or runtime checks.</remarks>
10-
public enum FeatureFlags
10+
enum FeatureFlags
1111
{
1212
Storage,
1313
Conversation

0 commit comments

Comments
 (0)