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
1,101 changes: 13 additions & 1,088 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
<Description>Microsoft.FeatureManagement.AspNetCore provides a way to develop and expose application functionality based on features. Many applications have special requirements when a new feature is developed such as when the feature should be enabled and under what conditions. This library provides a way to define these relationships, and also integrates into common ASP.NET Core code patterns to make exposing these features possible.</Description>
<Authors>Microsoft</Authors>
<Company>Microsoft</Company>
<PackageLicenseUrl>https://licenses.nuget.org/MIT</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/Azure/AppConfiguration</PackageProjectUrl>
<PackageProjectUrl>https://github.com/microsoft/FeatureManagement-Dotnet</PackageProjectUrl>
<RepositoryUrl>https://github.com/microsoft/FeatureManagement-Dotnet.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReleaseNotes>Release notes can be found at https://aka.ms/MicrosoftFeatureManagementReleaseNotes</PackageReleaseNotes>
<PackageTags>Microsoft FeatureManagement FeatureFlags AzureAppConfiguration aspnetcore</PackageTags>
<PackageIconUrl>https://aka.ms/AzureAppConfigurationPackageIcon</PackageIconUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public ConfigurationFeatureDefinitionProvider(IConfiguration configuration)
/// <summary>
/// The option that controls the behavior when "FeatureManagement" section in the configuration is missing.
/// </summary>
public bool RootConfigurationFallbackEnabled { get; init; }
public bool RootConfigurationFallbackEnabled { get; set; }

/// <summary>
/// The logger for the configuration feature definition provider.
/// </summary>
public ILogger Logger { get; init; }
public ILogger Logger { get; set; }

/// <summary>
/// Disposes the change subscription of the configuration.
Expand Down Expand Up @@ -129,7 +129,14 @@ public async IAsyncEnumerable<FeatureDefinition> GetAllFeatureDefinitionsAsync()

//
// Underlying IConfigurationSection data is dynamic so latest feature definitions are returned
yield return _definitions.GetOrAdd(featureName, (_) => ReadFeatureDefinition(featureSection));
FeatureDefinition definition = _definitions.GetOrAdd(featureName, (_) => ReadFeatureDefinition(featureSection));

//
// Null cache entry possible if someone accesses non-existent flag directly (IsEnabled)
if (definition != null)
{
yield return definition;
}
}
}

Expand Down
20 changes: 20 additions & 0 deletions src/Microsoft.FeatureManagement/FeatureFilters/ISystemClock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//

using System;

namespace Microsoft.FeatureManagement.FeatureFilters
{
/// <summary>
/// Abstracts the system clock to facilitate testing.
/// .NET8 offers an abstract class TimeProvider. After we stop supporting .NET version less than .NET8, this ISystemClock should retire.
/// </summary>
internal interface ISystemClock
{
/// <summary>
/// Retrieves the current system time in UTC.
/// </summary>
public DateTimeOffset UtcNow { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.FeatureManagement.Utils;
using System;
using System.Threading.Tasks;

namespace Microsoft.FeatureManagement.FeatureFilters
Expand Down Expand Up @@ -43,6 +44,11 @@ public object BindParameters(IConfiguration filterParameters)
/// <returns>True if the feature is enabled, false otherwise.</returns>
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}

//
// Check if prebound settings available, otherwise bind from parameters.
PercentageFilterSettings settings = (PercentageFilterSettings)context.Settings ?? (PercentageFilterSettings)BindParameters(context.Parameters);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
namespace Microsoft.FeatureManagement.FeatureFilters
{
/// <summary>
/// A recurrence definition describing how time window recurs
/// </summary>
public class Recurrence
{
/// <summary>
/// The recurrence pattern specifying how often the time window repeats
/// </summary>
public RecurrencePattern Pattern { get; set; }

/// <summary>
/// The recurrence range specifying how long the recurrence pattern repeats
/// </summary>
public RecurrenceRange Range { get; set; }
}
}
Loading