2 |
3 | @Title
4 |
5 |
6 | Please take our
7 | brief survey
8 |
9 | and tell us what you think.
10 |
11 |
12 | @code {
13 | // Demonstrates how a parent component can supply parameters
14 | [Parameter]
15 | public string Title { get; set; }
16 | }
17 |
--------------------------------------------------------------------------------
/examples/FeatureFlagDemo/Authentication/QueryStringAuthenticationExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.AspNetCore.Authentication;
5 |
6 | namespace FeatureFlagDemo.Authentication
7 | {
8 | static class QueryStringAuthenticationExtensions
9 | {
10 | public static AuthenticationBuilder AddQueryString(this AuthenticationBuilder builder)
11 | {
12 | return builder.AddScheme(Schemes.QueryString, null);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/tests/Tests.FeatureManagement.AspNetCore/Pages/RazorTestAll.cshtml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.AspNetCore.Mvc.RazorPages;
6 | using Microsoft.FeatureManagement.Mvc;
7 |
8 | namespace Tests.FeatureManagement.AspNetCore.Pages
9 | {
10 | [FeatureGate(Features.ConditionalFeature, Features.ConditionalFeature2)]
11 | public class RazorTestAllModel : PageModel
12 | {
13 | public IActionResult OnGet()
14 | {
15 | return new OkResult();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/examples/VariantServiceDemo/RemoteCalculator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.FeatureManagement;
5 |
6 | namespace VariantServiceDemo
7 | {
8 | [VariantServiceAlias("RemoteCalculator")]
9 | public class RemoteCalculator : ICalculator
10 | {
11 | public async Task AddAsync(double a, double b)
12 | {
13 | //
14 | // simulate the latency caused by calling API from a remote server
15 | await Task.Delay(1000);
16 |
17 | return a + b;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/Tests.FeatureManagement.AspNetCore/MvcFilter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.AspNetCore.Mvc.Filters;
5 | using System.Threading.Tasks;
6 |
7 | namespace Tests.FeatureManagement.AspNetCore
8 | {
9 | public class MvcFilter : IAsyncActionFilter
10 | {
11 | public Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
12 | {
13 | context.HttpContext.Response.Headers[nameof(MvcFilter)] = bool.TrueString;
14 |
15 | return next();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/examples/VariantAndTelemetryDemo/Pages/Checkout.cshtml:
--------------------------------------------------------------------------------
1 | @page
2 | @model CheckoutModel
3 | @{
4 | ViewData["Title"] = "Checkout";
5 | }
6 |
@ViewData["Title"]
7 |
8 |
Click Below To Check Out!
9 |
10 |
17 |
18 |
21 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using System.Runtime.CompilerServices;
5 |
6 | // Tests
7 | [assembly: InternalsVisibleTo("Tests.FeatureManagement,PublicKey=" +
8 | "0024000004800000940000000602000000240000525341310004000001000100895524f60b44ff" +
9 | "3ae70fbea5662f61dd9d640de2205b7bd5359a43dda006e51d83d1f5f7a7d3f849267a0a28676d" +
10 | "cf49727a32487d4c75c4aacd5febb0069e1adc66ec63bbd18ec2276091a0e3c1326aa626c9e4db" +
11 | "800714a134f2a81e405f35752b55220021923429cb61776cd2fa66d25c335f8dc27bb92292905a" +
12 | "3798d896")]
13 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/Targeting/TargetingEvaluationOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | namespace Microsoft.FeatureManagement.FeatureFilters
5 | {
6 | ///
7 | /// Options that apply to all uses of a target filter inside a service collection.
8 | ///
9 | public class TargetingEvaluationOptions
10 | {
11 | ///
12 | /// Used to ignore case when comparing user id and group names during targeting evaluation.
13 | ///
14 | public bool IgnoreCase { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/tests/Tests.FeatureManagement.AspNetCore/Pages/RazorTestAllNegate.cshtml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.AspNetCore.Mvc.RazorPages;
6 | using Microsoft.FeatureManagement.Mvc;
7 |
8 | namespace Tests.FeatureManagement.AspNetCore.Pages
9 | {
10 | [FeatureGate(negate: true, Features.ConditionalFeature, Features.ConditionalFeature2)]
11 | public class RazorTestAllNegateModel : PageModel
12 | {
13 | public IActionResult OnGet()
14 | {
15 | return new OkResult();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/Targeting/TargetingFilterSettings.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | namespace Microsoft.FeatureManagement.FeatureFilters
5 | {
6 | ///
7 | /// The settings that are used to configure the feature filter.
8 | ///
9 | public class TargetingFilterSettings
10 | {
11 | ///
12 | /// The audience that a feature configured to use the should be enabled for.
13 | ///
14 | public Audience Audience { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/FeatureStatus.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | namespace Microsoft.FeatureManagement
5 | {
6 | ///
7 | /// Describes how a feature's state will be evaluated.
8 | ///
9 | public enum FeatureStatus
10 | {
11 | ///
12 | /// The state of the feature is conditional upon the feature evaluation pipeline.
13 | ///
14 | Conditional,
15 |
16 | ///
17 | /// The state of the feature is always disabled.
18 | ///
19 | Disabled
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/Tests.FeatureManagement.AspNetCore/Pages/RazorTestAny.cshtml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.AspNetCore.Mvc.RazorPages;
6 | using Microsoft.FeatureManagement;
7 | using Microsoft.FeatureManagement.Mvc;
8 |
9 | namespace Tests.FeatureManagement.AspNetCore.Pages
10 | {
11 | [FeatureGate(RequirementType.Any, Features.ConditionalFeature, Features.ConditionalFeature2)]
12 | public class RazorTestAnyModel : PageModel
13 | {
14 | public IActionResult OnGet()
15 | {
16 | return new OkResult();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/Targeting/ITargetingContextAccessor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using System.Threading.Tasks;
5 |
6 | namespace Microsoft.FeatureManagement.FeatureFilters
7 | {
8 | ///
9 | /// Provides access to the current targeting context.
10 | ///
11 | public interface ITargetingContextAccessor
12 | {
13 | ///
14 | /// Retrieves the current targeting context.
15 | ///
16 | /// The current targeting context.
17 | ValueTask GetContextAsync();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/Variant.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.Extensions.Configuration;
5 |
6 | namespace Microsoft.FeatureManagement
7 | {
8 | ///
9 | /// A variant for a feature.
10 | ///
11 | public class Variant
12 | {
13 | ///
14 | /// The name of the variant.
15 | ///
16 | public string Name { get; set; }
17 |
18 | ///
19 | /// The configuration of the variant.
20 | ///
21 | public IConfigurationSection Configuration { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/examples/RazorPages/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) .NET Foundation. All rights reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 | these files except in compliance with the License. You may obtain a copy of the
5 | License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software distributed
10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the
12 | specific language governing permissions and limitations under the License.
13 |
--------------------------------------------------------------------------------
/examples/FeatureFlagDemo/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) .NET Foundation. All rights reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 | these files except in compliance with the License. You may obtain a copy of the
5 | License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software distributed
10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the
12 | specific language governing permissions and limitations under the License.
13 |
--------------------------------------------------------------------------------
/examples/VariantServiceDemo/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) .NET Foundation. All rights reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 | these files except in compliance with the License. You may obtain a copy of the
5 | License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software distributed
10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the
12 | specific language governing permissions and limitations under the License.
13 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/FeatureFilters/PercentageFilterSettings.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | namespace Microsoft.FeatureManagement.FeatureFilters
5 | {
6 | ///
7 | /// The settings that are used to configure the feature filter.
8 | ///
9 | public class PercentageFilterSettings
10 | {
11 | ///
12 | /// A value between 0 and 100 specifying the chance that a feature configured to use the should be enabled.
13 | ///
14 | public int Value { get; set; } = -1;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/examples/VariantAndTelemetryDemo/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) .NET Foundation. All rights reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 | these files except in compliance with the License. You may obtain a copy of the
5 | License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software distributed
10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the
12 | specific language governing permissions and limitations under the License.
13 |
--------------------------------------------------------------------------------
/tests/Tests.FeatureManagement.AspNetCore/Pages/RazorTestAnyNegate.cshtml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.AspNetCore.Mvc.RazorPages;
6 | using Microsoft.FeatureManagement;
7 | using Microsoft.FeatureManagement.Mvc;
8 |
9 | namespace Tests.FeatureManagement.AspNetCore.Pages
10 | {
11 | [FeatureGate(requirementType: RequirementType.Any, negate: true, Features.ConditionalFeature, Features.ConditionalFeature2)]
12 | public class RazorTestAnyNegateModel : PageModel
13 | {
14 | public IActionResult OnGet()
15 | {
16 | return new OkResult();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/Allocation/GroupAllocation.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Microsoft.FeatureManagement
8 | {
9 | ///
10 | /// The definition of a group allocation.
11 | ///
12 | public class GroupAllocation
13 | {
14 | ///
15 | /// The name of the variant.
16 | ///
17 | public string Variant { get; set; }
18 |
19 | ///
20 | /// A list of groups that can be assigned this variant.
21 | ///
22 | public IEnumerable Groups { get; set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/Allocation/UserAllocation.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Microsoft.FeatureManagement
8 | {
9 | ///
10 | /// The definition of a user allocation.
11 | ///
12 | public class UserAllocation
13 | {
14 | ///
15 | /// The name of the variant.
16 | ///
17 | public string Variant { get; set; }
18 |
19 | ///
20 | /// A list of users that will be assigned this variant.
21 | ///
22 | public IEnumerable Users { get; set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/RequirementType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | namespace Microsoft.FeatureManagement
5 | {
6 | ///
7 | /// Describes whether any or all conditions in a set should be required to be true.
8 | ///
9 | public enum RequirementType
10 | {
11 | ///
12 | /// The set of conditions will be evaluated as true if any condition in the set is true.
13 | ///
14 | Any,
15 | ///
16 | /// The set of conditions will be evaluated as true if all the conditions in the set are true.
17 | ///
18 | All
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/DotnetFeatureManagementFields.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 |
5 | namespace Microsoft.FeatureManagement
6 | {
7 | internal static class DotnetFeatureManagementFields
8 | {
9 | public const string RequirementType = "RequirementType";
10 |
11 | // Feature filters keywords
12 | public const string FeatureFiltersSectionName = "EnabledFor";
13 | public const string FeatureFilterConfigurationParameters = "Parameters";
14 |
15 | // Other keywords
16 | public const string NameKeyword = "Name";
17 | public const string FeatureManagementSectionName = "FeatureManagement";
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/examples/VariantServiceDemo/VariantServiceDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/RazorPages/Pages/Index.cshtml:
--------------------------------------------------------------------------------
1 | @page
2 | @model IndexModel
3 | @{
4 | ViewData["Title"] = "Home page";
5 | }
6 |
7 |
8 |
13 |
14 |
15 |
16 | Razor Page Example
17 |
18 |
19 | This page uses the 'PageGateAttribute' to conditionally display this web page.
20 | Since you are seeing this, that means the 'Home' feature is enabled.
21 | If the 'Home' feature is disabled then the browser will display an HTTP 404 (Not Found) error page.
22 |
23 |
--------------------------------------------------------------------------------
/tests/Tests.FeatureManagement/ContextualTestFilter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.FeatureManagement;
5 | using System;
6 | using System.Threading.Tasks;
7 |
8 | namespace Tests.FeatureManagement
9 | {
10 | class ContextualTestFilter : IContextualFeatureFilter
11 | {
12 | public Func ContextualCallback { get; set; }
13 |
14 | public Task EvaluateAsync(FeatureFilterEvaluationContext context, IAccountContext accountContext)
15 | {
16 | return Task.FromResult(ContextualCallback?.Invoke(context, accountContext) ?? false);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/examples/VariantAndTelemetryDemo/VariantAndTelemetryDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/FeatureFlagDemo/Controllers/BetaController.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.FeatureManagement;
6 | using Microsoft.FeatureManagement.Mvc;
7 |
8 | namespace FeatureFlagDemo.Controllers
9 | {
10 | public class BetaController : Controller
11 | {
12 | private readonly IFeatureManager _featureManager;
13 |
14 | public BetaController(IFeatureManagerSnapshot featureManager)
15 | {
16 | _featureManager = featureManager;
17 | }
18 |
19 | [FeatureGate(MyFeatureFlags.Beta)]
20 | public IActionResult Index()
21 | {
22 | return View();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/OnDemandConfigurationProvider.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Configuration;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 |
5 | namespace Microsoft.FeatureManagement
6 | {
7 | internal class OnDemandConfigurationProvider : ConfigurationProvider
8 | {
9 | private static readonly PropertyInfo _DataProperty = typeof(ConfigurationProvider).GetProperty(nameof(Data), BindingFlags.NonPublic | BindingFlags.Instance);
10 |
11 | public OnDemandConfigurationProvider(ConfigurationProvider configurationProvider)
12 | {
13 | var data = _DataProperty.GetValue(configurationProvider) as IDictionary;
14 |
15 | Data = data;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/examples/RazorPages/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.FeatureManagement;
2 |
3 | var builder = WebApplication.CreateBuilder(args);
4 |
5 | // Add services to the container.
6 | builder.Services.AddRazorPages();
7 | builder.Services.AddFeatureManagement();
8 |
9 | var app = builder.Build();
10 |
11 | // Configure the HTTP request pipeline.
12 | if (!app.Environment.IsDevelopment())
13 | {
14 | app.UseExceptionHandler("/Error");
15 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
16 | app.UseHsts();
17 | }
18 |
19 | app.UseHttpsRedirection();
20 | app.UseStaticFiles();
21 |
22 | app.UseRouting();
23 |
24 | app.UseAuthorization();
25 |
26 | app.MapRazorPages();
27 |
28 | app.Run();
29 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/Targeting/BasicAudience.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using System.Collections.Generic;
5 |
6 | namespace Microsoft.FeatureManagement.FeatureFilters
7 | {
8 | ///
9 | /// A basic audience definition describing a set of users and groups.
10 | ///
11 | public class BasicAudience
12 | {
13 | ///
14 | /// Includes users in the audience by name.
15 | ///
16 | public List Users { get; set; }
17 |
18 | ///
19 | /// Includes users in the audience by group name.
20 | ///
21 | public List Groups { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/Targeting/GroupRollout.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | namespace Microsoft.FeatureManagement.FeatureFilters
5 | {
6 | ///
7 | /// Defines a percentage of a group to be included in a rollout.
8 | ///
9 | public class GroupRollout
10 | {
11 | ///
12 | /// The name of the group.
13 | ///
14 | public string Name { get; set; }
15 |
16 | ///
17 | /// The percentage of the group that should be considered part of the rollout. Valid values range from 0 to 100 inclusive.
18 | ///
19 | public double RolloutPercentage { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/FeatureFilters/Recurrence/Recurrence.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | namespace Microsoft.FeatureManagement.FeatureFilters
5 | {
6 | ///
7 | /// A recurrence definition describing how time window recurs
8 | ///
9 | public class Recurrence
10 | {
11 | ///
12 | /// The recurrence pattern specifying how often the time window repeats
13 | ///
14 | public RecurrencePattern Pattern { get; set; }
15 |
16 | ///
17 | /// The recurrence range specifying how long the recurrence pattern repeats
18 | ///
19 | public RecurrenceRange Range { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/StatusOverride.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | namespace Microsoft.FeatureManagement
5 | {
6 | ///
7 | /// Provides the capability to override whether a feature is considered enabled or disabled when a variant is assigned.
8 | ///
9 | public enum StatusOverride
10 | {
11 | ///
12 | /// Does not affect the feature state.
13 | ///
14 | None,
15 |
16 | ///
17 | /// The feature will be considered enabled.
18 | ///
19 | Enabled,
20 |
21 | ///
22 | /// The feature will be considered disabled.
23 | ///
24 | Disabled
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/BlazorServerApp/Data/WeatherForecastService.cs:
--------------------------------------------------------------------------------
1 | namespace BlazorServerApp.Data
2 | {
3 | public class WeatherForecastService
4 | {
5 | private static readonly string[] Summaries = new[]
6 | {
7 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
8 | };
9 |
10 | public Task GetForecastAsync(DateTime startDate)
11 | {
12 | return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
13 | {
14 | Date = startDate.AddDays(index),
15 | TemperatureC = Random.Shared.Next(-20, 55),
16 | Summary = Summaries[Random.Shared.Next(Summaries.Length)]
17 | }).ToArray());
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/TelemetryConfiguration.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.FeatureManagement.Telemetry;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 |
5 | namespace Microsoft.FeatureManagement
6 | {
7 | ///
8 | /// Defines telemetry related configuration settings available for features.
9 | ///
10 | public class TelemetryConfiguration
11 | {
12 | ///
13 | /// A flag to enable or disable sending events as s.
14 | ///
15 | public bool Enabled { get; set; }
16 |
17 | ///
18 | /// A container for metadata relevant to telemetry.
19 | ///
20 | public IReadOnlyDictionary Metadata { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/IVariantServiceProvider.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 |
7 | namespace Microsoft.FeatureManagement
8 | {
9 | ///
10 | /// Used to get different implementation variants of TService.
11 | ///
12 | public interface IVariantServiceProvider where TService : class
13 | {
14 | ///
15 | /// Gets an implementation variant of TService.
16 | ///
17 | /// The cancellation token to cancel the operation.
18 | /// An implementation of TService.
19 | ValueTask GetServiceAsync(CancellationToken cancellationToken);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/examples/RazorPages/Pages/Error.cshtml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.AspNetCore.Mvc.RazorPages;
3 | using System.Diagnostics;
4 |
5 | namespace RazorPages.Pages
6 | {
7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8 | [IgnoreAntiforgeryToken]
9 | public class ErrorModel : PageModel
10 | {
11 | public string? RequestId { get; set; }
12 |
13 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
14 |
15 | private readonly ILogger _logger;
16 |
17 | public ErrorModel(ILogger logger)
18 | {
19 | _logger = logger;
20 | }
21 |
22 | public void OnGet()
23 | {
24 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/BlazorServerApp/Shared/MainLayout.razor:
--------------------------------------------------------------------------------
1 | @inherits LayoutComponentBase
2 |
3 | BlazorServerApp
4 |
5 |
19 | Swapping to the Development environment displays detailed information about the error that occurred.
20 |
21 |
22 | The Development environment shouldn't be enabled for deployed applications.
23 | It can result in displaying sensitive information from exceptions to end users.
24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
25 | and restarting the app.
26 |
27 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/VariantDefinition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 |
5 | using Microsoft.Extensions.Configuration;
6 |
7 | namespace Microsoft.FeatureManagement
8 | {
9 | ///
10 | /// The definition for a variant of a feature.
11 | ///
12 | public class VariantDefinition
13 | {
14 | ///
15 | /// The name of the variant.
16 | ///
17 | public string Name { get; set; }
18 |
19 | ///
20 | /// The value of the configuration for this variant of the feature.
21 | ///
22 | public IConfigurationSection ConfigurationValue { get; set; }
23 |
24 | ///
25 | /// Overrides the state of the feature if this variant has been assigned.
26 | ///
27 | public StatusOverride StatusOverride { get; set; } = StatusOverride.None;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/examples/VariantServiceDemo/Pages/Error.cshtml:
--------------------------------------------------------------------------------
1 | @page
2 | @model ErrorModel
3 | @{
4 | ViewData["Title"] = "Error";
5 | }
6 |
7 |
Error.
8 |
An error occurred while processing your request.
9 |
10 | @if (Model.ShowRequestId)
11 | {
12 |
13 | Request ID:@Model.RequestId
14 |
15 | }
16 |
17 |
Development Mode
18 |
19 | Swapping to the Development environment displays detailed information about the error that occurred.
20 |
21 |
22 | The Development environment shouldn't be enabled for deployed applications.
23 | It can result in displaying sensitive information from exceptions to end users.
24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
25 | and restarting the app.
26 |
19 | Swapping to the Development environment displays detailed information about the error that occurred.
20 |
21 |
22 | The Development environment shouldn't be enabled for deployed applications.
23 | It can result in displaying sensitive information from exceptions to end users.
24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
25 | and restarting the app.
26 |
19 | Swapping to the Development environment displays detailed information about the error that occurred.
20 |
21 |
22 | The Development environment shouldn't be enabled for deployed applications.
23 | It can result in displaying sensitive information from exceptions to end users.
24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
25 | and restarting the app.
26 |
27 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/FeatureFilters/Recurrence/RecurrenceRange.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using System;
5 |
6 | namespace Microsoft.FeatureManagement.FeatureFilters
7 | {
8 | ///
9 | /// The recurrence range describes a date range over which the time window repeats.
10 | ///
11 | public class RecurrenceRange
12 | {
13 | ///
14 | /// The recurrence range type.
15 | ///
16 | public RecurrenceRangeType Type { get; set; }
17 |
18 | ///
19 | /// The date to stop applying the recurrence pattern.
20 | ///
21 | public DateTimeOffset EndDate { get; set; } = DateTimeOffset.MaxValue;
22 |
23 | ///
24 | /// The number of times to repeat the time window.
25 | ///
26 | public int NumberOfOccurrences { get; set; } = int.MaxValue;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/examples/VariantAndTelemetryDemo/Pages/RandomizeUser.cshtml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Authentication;
2 | using Microsoft.AspNetCore.Mvc;
3 | using Microsoft.AspNetCore.Mvc.RazorPages;
4 | using System.Security.Claims;
5 |
6 | namespace VariantAndTelemetryDemo.Pages
7 | {
8 | public class RandomizeUserModel : PageModel
9 | {
10 | public IActionResult OnGet()
11 | {
12 | // Clear Application Insights cookies and
13 | Response.Cookies.Delete("ai_user");
14 | Response.Cookies.Delete("ai_session");
15 |
16 | // Generate new user claim
17 | var claims = new List
18 | {
19 | new Claim(ClaimTypes.Name, Random.Shared.Next().ToString())
20 | };
21 |
22 | var identity = new ClaimsIdentity(claims, "CookieAuth");
23 | var principal = new ClaimsPrincipal(identity);
24 |
25 | HttpContext.SignInAsync("CookieAuth", principal);
26 |
27 | return RedirectToPage("/Index");
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/examples/FeatureFlagDemo/ThirdPartyMiddleware.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | namespace FeatureFlagDemo
5 | {
6 | public class ThirdPartyMiddleware
7 | {
8 | //
9 | // The middleware delegate to call after this one finishes processing
10 | private readonly RequestDelegate _next;
11 | private readonly ILogger _logger;
12 |
13 | public ThirdPartyMiddleware(RequestDelegate next, ILoggerFactory loggerFactory)
14 | {
15 | _next = next;
16 | _logger = loggerFactory.CreateLogger();
17 | }
18 |
19 | public async Task Invoke(HttpContext httpContext)
20 | {
21 | _logger.LogInformation($"Third party middleware inward path.");
22 |
23 | //
24 | // Call the next middleware delegate in the pipeline
25 | await _next.Invoke(httpContext);
26 |
27 | _logger.LogInformation($"Third party middleware outward path.");
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement.AspNetCore/IDisabledFeatureHandler.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.AspNetCore.Mvc.Filters;
5 | using System.Collections.Generic;
6 | using System.Threading.Tasks;
7 |
8 | namespace Microsoft.FeatureManagement.Mvc
9 | {
10 | ///
11 | /// A handler that is invoked when an MVC action requires a feature and the feature is not enabled.
12 | ///
13 | public interface IDisabledFeaturesHandler
14 | {
15 | ///
16 | /// Callback used to handle requests to an MVC action that require a feature that is disabled.
17 | ///
18 | /// The name of the features that the action could have been activated for.
19 | /// The action executing context provided by MVC.
20 | /// The task.
21 | Task HandleDisabledFeatures(IEnumerable features, ActionExecutingContext context);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/IFilterParametersBinder.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.Extensions.Configuration;
5 |
6 | namespace Microsoft.FeatureManagement
7 | {
8 | ///
9 | /// An interface used by the feature management system to pre-bind feature filter parameters to a settings type.
10 | /// s can implement this interface to take advantage of caching of settings by the feature management system.
11 | ///
12 | public interface IFilterParametersBinder
13 | {
14 | ///
15 | /// Binds a set of feature filter parameters to a settings object.
16 | ///
17 | /// The configuration representing filter parameters to bind to a settings object
18 | /// A settings object that is understood by the implementer of .
19 | object BindParameters(IConfiguration parameters);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/Tests.FeatureManagement/TestFilter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.Extensions.Configuration;
5 | using Microsoft.FeatureManagement;
6 | using System;
7 | using System.Threading.Tasks;
8 |
9 | namespace Tests.FeatureManagement
10 | {
11 | class TestFilter : IFeatureFilter, IFilterParametersBinder
12 | {
13 | public Func ParametersBinderCallback { get; set; }
14 |
15 | public Func> Callback { get; set; }
16 |
17 | public object BindParameters(IConfiguration parameters)
18 | {
19 | if (ParametersBinderCallback != null)
20 | {
21 | return ParametersBinderCallback(parameters);
22 | }
23 |
24 | return parameters;
25 | }
26 |
27 | public Task EvaluateAsync(FeatureFilterEvaluationContext context)
28 | {
29 | return Callback?.Invoke(context) ?? Task.FromResult(false);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/tests/Tests.FeatureManagement.AspNetCore/TestFilter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.Extensions.Configuration;
5 | using Microsoft.FeatureManagement;
6 | using System;
7 | using System.Threading.Tasks;
8 |
9 | namespace Tests.FeatureManagement.AspNetCore
10 | {
11 | class TestFilter : IFeatureFilter, IFilterParametersBinder
12 | {
13 | public Func ParametersBinderCallback { get; set; }
14 |
15 | public Func> Callback { get; set; }
16 |
17 | public object BindParameters(IConfiguration parameters)
18 | {
19 | if (ParametersBinderCallback != null)
20 | {
21 | return ParametersBinderCallback(parameters);
22 | }
23 |
24 | return parameters;
25 | }
26 |
27 | public Task EvaluateAsync(FeatureFilterEvaluationContext context)
28 | {
29 | return Callback?.Invoke(context) ?? Task.FromResult(false);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/IFeatureDefinitionProvider.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using System.Collections.Generic;
5 | using System.Threading.Tasks;
6 |
7 | namespace Microsoft.FeatureManagement
8 | {
9 | ///
10 | /// A provider of feature definitions.
11 | ///
12 | public interface IFeatureDefinitionProvider
13 | {
14 | ///
15 | /// Retrieves the definition for a given feature.
16 | ///
17 | /// The name of the feature to retrieve the definition for.
18 | /// The feature's definition.
19 | Task GetFeatureDefinitionAsync(string featureName);
20 |
21 | ///
22 | /// Retrieves definitions for all features.
23 | ///
24 | /// An enumerator which provides asynchronous iteration over feature definitions.
25 | IAsyncEnumerable GetAllFeatureDefinitionsAsync();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/FeatureFlagDemo/FeatureNotEnabledDisabledHandler.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.AspNetCore.Mvc.Filters;
6 | using Microsoft.AspNetCore.Mvc.ModelBinding;
7 | using Microsoft.AspNetCore.Mvc.ViewFeatures;
8 | using Microsoft.FeatureManagement.Mvc;
9 |
10 | namespace FeatureFlagDemo.FeatureManagement
11 | {
12 | public class FeatureNotEnabledDisabledHandler : IDisabledFeaturesHandler
13 | {
14 | public Task HandleDisabledFeatures(IEnumerable features, ActionExecutingContext context)
15 | {
16 | var result = new ViewResult()
17 | {
18 | ViewName = "Views/Shared/FeatureNotEnabled.cshtml",
19 | ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary())
20 | };
21 |
22 | result.ViewData["FeatureName"] = string.Join(", ", features);
23 |
24 | context.Result = result;
25 |
26 | return Task.CompletedTask;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/examples/VariantServiceDemo/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | },
8 | "AllowedHosts": "*",
9 | "ApplicationInsights": {
10 | "ConnectionString": ""
11 | },
12 | "feature_management": {
13 | "feature_flags": [
14 | {
15 | "id": "Calculator",
16 | "enabled": true,
17 | "telemetry": {
18 | "enabled": true
19 | },
20 | "variants": [
21 | {
22 | "name": "DefaultCalculator"
23 | },
24 | {
25 | "name": "RemoteCalculator"
26 | }
27 | ],
28 | "allocation": {
29 | "percentile": [
30 | {
31 | "variant": "DefaultCalculator",
32 | "from": 0,
33 | "to": 50
34 | },
35 | {
36 | "variant": "RemoteCalculator",
37 | "from": 50,
38 | "to": 100
39 | }
40 | ]
41 | }
42 | }
43 | ]
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement.AspNetCore/InlineDisabledFeatureHandler.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.AspNetCore.Mvc.Filters;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Threading.Tasks;
8 |
9 | namespace Microsoft.FeatureManagement.Mvc
10 | {
11 | ///
12 | /// A disabled feature handler that wraps an inline handler.
13 | ///
14 | class InlineDisabledFeaturesHandler : IDisabledFeaturesHandler
15 | {
16 | private readonly Action, ActionExecutingContext> _handler;
17 |
18 | public InlineDisabledFeaturesHandler(Action, ActionExecutingContext> handler)
19 | {
20 | _handler = handler ?? throw new ArgumentNullException(nameof(handler));
21 | }
22 |
23 | public Task HandleDisabledFeatures(IEnumerable features, ActionExecutingContext context)
24 | {
25 | _handler(features, context);
26 |
27 | return Task.CompletedTask;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/examples/RazorPages/Pages/Shared/_Layout.cshtml.css:
--------------------------------------------------------------------------------
1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2 | for details on configuring this project to bundle and minify static web assets. */
3 |
4 | a.navbar-brand {
5 | white-space: normal;
6 | text-align: center;
7 | word-break: break-all;
8 | }
9 |
10 | a {
11 | color: #0077cc;
12 | }
13 |
14 | .btn-primary {
15 | color: #fff;
16 | background-color: #1b6ec2;
17 | border-color: #1861ac;
18 | }
19 |
20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link {
21 | color: #fff;
22 | background-color: #1b6ec2;
23 | border-color: #1861ac;
24 | }
25 |
26 | .border-top {
27 | border-top: 1px solid #e5e5e5;
28 | }
29 | .border-bottom {
30 | border-bottom: 1px solid #e5e5e5;
31 | }
32 |
33 | .box-shadow {
34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
35 | }
36 |
37 | button.accept-policy {
38 | font-size: 1rem;
39 | line-height: inherit;
40 | }
41 |
42 | .footer {
43 | position: absolute;
44 | bottom: 0;
45 | width: 100%;
46 | white-space: nowrap;
47 | line-height: 60px;
48 | }
49 |
--------------------------------------------------------------------------------
/examples/FeatureFlagDemo/Views/Shared/_Layout.cshtml.css:
--------------------------------------------------------------------------------
1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2 | for details on configuring this project to bundle and minify static web assets. */
3 |
4 | a.navbar-brand {
5 | white-space: normal;
6 | text-align: center;
7 | word-break: break-all;
8 | }
9 |
10 | a {
11 | color: #0077cc;
12 | }
13 |
14 | .btn-primary {
15 | color: #fff;
16 | background-color: #1b6ec2;
17 | border-color: #1861ac;
18 | }
19 |
20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link {
21 | color: #fff;
22 | background-color: #1b6ec2;
23 | border-color: #1861ac;
24 | }
25 |
26 | .border-top {
27 | border-top: 1px solid #e5e5e5;
28 | }
29 | .border-bottom {
30 | border-bottom: 1px solid #e5e5e5;
31 | }
32 |
33 | .box-shadow {
34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
35 | }
36 |
37 | button.accept-policy {
38 | font-size: 1rem;
39 | line-height: inherit;
40 | }
41 |
42 | .footer {
43 | position: absolute;
44 | bottom: 0;
45 | width: 100%;
46 | white-space: nowrap;
47 | line-height: 60px;
48 | }
49 |
--------------------------------------------------------------------------------
/examples/VariantServiceDemo/Pages/Shared/_Layout.cshtml.css:
--------------------------------------------------------------------------------
1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2 | for details on configuring this project to bundle and minify static web assets. */
3 |
4 | a.navbar-brand {
5 | white-space: normal;
6 | text-align: center;
7 | word-break: break-all;
8 | }
9 |
10 | a {
11 | color: #0077cc;
12 | }
13 |
14 | .btn-primary {
15 | color: #fff;
16 | background-color: #1b6ec2;
17 | border-color: #1861ac;
18 | }
19 |
20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link {
21 | color: #fff;
22 | background-color: #1b6ec2;
23 | border-color: #1861ac;
24 | }
25 |
26 | .border-top {
27 | border-top: 1px solid #e5e5e5;
28 | }
29 | .border-bottom {
30 | border-bottom: 1px solid #e5e5e5;
31 | }
32 |
33 | .box-shadow {
34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
35 | }
36 |
37 | button.accept-policy {
38 | font-size: 1rem;
39 | line-height: inherit;
40 | }
41 |
42 | .footer {
43 | position: absolute;
44 | bottom: 0;
45 | width: 100%;
46 | white-space: nowrap;
47 | line-height: 60px;
48 | }
49 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/FilterAliasAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using System;
5 |
6 | namespace Microsoft.FeatureManagement
7 | {
8 | ///
9 | /// Allows the name of an to be customized to relate to the name specified in configuration.
10 | ///
11 | public class FilterAliasAttribute : Attribute
12 | {
13 | ///
14 | /// Creates a filter alias using the provided alias.
15 | ///
16 | /// The alias of the feature filter.
17 | public FilterAliasAttribute(string alias)
18 | {
19 | if (string.IsNullOrEmpty(alias))
20 | {
21 | throw new ArgumentNullException(nameof(alias));
22 | }
23 |
24 | Alias = alias;
25 | }
26 |
27 | ///
28 | /// The name that will be used to match feature filters specified in the configuration.
29 | ///
30 | public string Alias { get; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/examples/VariantAndTelemetryDemo/Pages/Shared/_Layout.cshtml.css:
--------------------------------------------------------------------------------
1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2 | for details on configuring this project to bundle and minify static web assets. */
3 |
4 | a.navbar-brand {
5 | white-space: normal;
6 | text-align: center;
7 | word-break: break-all;
8 | }
9 |
10 | a {
11 | color: #0077cc;
12 | }
13 |
14 | .btn-primary {
15 | color: #fff;
16 | background-color: #1b6ec2;
17 | border-color: #1861ac;
18 | }
19 |
20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link {
21 | color: #fff;
22 | background-color: #1b6ec2;
23 | border-color: #1861ac;
24 | }
25 |
26 | .border-top {
27 | border-top: 1px solid #e5e5e5;
28 | }
29 | .border-bottom {
30 | border-bottom: 1px solid #e5e5e5;
31 | }
32 |
33 | .box-shadow {
34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
35 | }
36 |
37 | button.accept-policy {
38 | font-size: 1rem;
39 | line-height: inherit;
40 | }
41 |
42 | .footer {
43 | position: absolute;
44 | bottom: 0;
45 | width: 100%;
46 | white-space: nowrap;
47 | line-height: 60px;
48 | }
49 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/FeatureManagementException.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using System;
5 |
6 | namespace Microsoft.FeatureManagement
7 | {
8 | ///
9 | /// Represents errors that occur during feature management.
10 | ///
11 | public class FeatureManagementException : Exception
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The feature management error that the exception represents.
17 | /// Error message for the exception.
18 | public FeatureManagementException(FeatureManagementError errorType, string message)
19 | : base(message)
20 | {
21 | Error = errorType;
22 | }
23 |
24 | ///
25 | /// The feature management error that the exception represents.
26 | ///
27 | public FeatureManagementError Error { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/VariantServiceAliasAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using System;
5 |
6 | namespace Microsoft.FeatureManagement
7 | {
8 | ///
9 | /// Allows the name of a variant service to be customized to relate to the variant name specified in configuration.
10 | ///
11 | public class VariantServiceAliasAttribute : Attribute
12 | {
13 | ///
14 | /// Creates a variant service alias using the provided alias.
15 | ///
16 | /// The alias of the variant service.
17 | public VariantServiceAliasAttribute(string alias)
18 | {
19 | if (string.IsNullOrEmpty(alias))
20 | {
21 | throw new ArgumentNullException(nameof(alias));
22 | }
23 |
24 | Alias = alias;
25 | }
26 |
27 | ///
28 | /// The name that will be used to match variant name specified in the configuration.
29 | ///
30 | public string Alias { get; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/FeatureFilters/Recurrence/RecurrenceRangeType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | namespace Microsoft.FeatureManagement.FeatureFilters
5 | {
6 | ///
7 | /// The type of specifying the date range over which the time window repeats.
8 | ///
9 | public enum RecurrenceRangeType
10 | {
11 | ///
12 | /// The time window repeats on all the days that fit the corresponding .
13 | ///
14 | NoEnd,
15 |
16 | ///
17 | /// The time window repeats on all the days that fit the corresponding before or on the end date specified in EndDate of .
18 | ///
19 | EndDate,
20 |
21 | ///
22 | /// The time window repeats for the number specified in the NumberOfOccurrences of that fit based on the .
23 | ///
24 | Numbered
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/ISessionManager.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using System.Threading.Tasks;
5 |
6 | namespace Microsoft.FeatureManagement
7 | {
8 | ///
9 | /// Used to store feature state across a session. The implementor is free to decide what constitutes a session.
10 | ///
11 | public interface ISessionManager
12 | {
13 | ///
14 | /// Set the state of a feature to be used for a session.
15 | ///
16 | /// The name of the feature.
17 | /// The state of the feature.
18 | Task SetAsync(string featureName, bool enabled);
19 |
20 | ///
21 | /// Queries the session manager for the session's feature state, if any, for the given feature.
22 | ///
23 | /// The name of the feature.
24 | /// The state of the feature if it is present in the session, otherwise null.
25 | Task GetAsync(string featureName);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/BlazorServerApp/wwwroot/css/open-iconic/ICON-LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Waybury
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/Targeting/Audience.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using System.Collections.Generic;
5 |
6 | namespace Microsoft.FeatureManagement.FeatureFilters
7 | {
8 | ///
9 | /// An audience definition describing a set of users.
10 | ///
11 | public class Audience
12 | {
13 | ///
14 | /// Includes users in the audience by name.
15 | ///
16 | public List Users { get; set; }
17 |
18 | ///
19 | /// Includes users in the audience based off a group rollout.
20 | ///
21 | public List Groups { get; set; }
22 |
23 | ///
24 | /// Includes users in the audience based off a percentage of the total possible audience. Valid values range from 0 to 100 inclusive.
25 | ///
26 | public double DefaultRolloutPercentage { get; set; }
27 |
28 | ///
29 | /// Excludes a basic audience from this audience.
30 | ///
31 | public BasicAudience Exclusion { get; set; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/tests/Tests.FeatureManagement/TestCache.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.Extensions.Caching.Memory;
5 |
6 | namespace Tests.FeatureManagement
7 | {
8 | class TestCache : IMemoryCache
9 | {
10 | private readonly IMemoryCache _cache;
11 | private int _countOfEntryCreation;
12 |
13 | public TestCache()
14 | {
15 | _cache = new MemoryCache(new MemoryCacheOptions());
16 | }
17 |
18 | public int CountOfEntryCreation
19 | {
20 | get => _countOfEntryCreation;
21 | }
22 |
23 | public bool TryGetValue(object key, out object value)
24 | {
25 | return _cache.TryGetValue(key, out value);
26 | }
27 |
28 | public ICacheEntry CreateEntry(object key)
29 | {
30 | _countOfEntryCreation += 1;
31 |
32 | return _cache.CreateEntry(key);
33 | }
34 |
35 | public void Remove(object key)
36 | {
37 | _cache.Remove(key);
38 | }
39 |
40 | public void Dispose()
41 | {
42 | _cache.Dispose();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/tests/Tests.FeatureManagement/CustomTargetingFilter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.Extensions.Logging;
5 | using Microsoft.Extensions.Options;
6 | using Microsoft.FeatureManagement;
7 | using Microsoft.FeatureManagement.FeatureFilters;
8 | using System;
9 | using System.Threading.Tasks;
10 |
11 | namespace Tests.FeatureManagement
12 | {
13 | [FilterAlias(Alias)]
14 | class CustomTargetingFilter : IFeatureFilter
15 | {
16 | private const string Alias = "CustomTargetingFilter";
17 | private readonly ContextualTargetingFilter _contextualFilter;
18 |
19 | public CustomTargetingFilter(IOptions options, ILoggerFactory loggerFactory)
20 | {
21 | _contextualFilter = new ContextualTargetingFilter(options, loggerFactory);
22 | }
23 |
24 | public Func> Callback { get; set; }
25 |
26 | public Task EvaluateAsync(FeatureFilterEvaluationContext context)
27 | {
28 | return _contextualFilter.EvaluateAsync(context, new TargetingContext() { UserId = "Jeff" });
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/examples/RazorPages/wwwroot/lib/jquery-validation/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | =====================
3 |
4 | Copyright Jörn Zaefferer
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/examples/ConsoleApp/FeatureFilters/AccountIdFilter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using Microsoft.Extensions.Configuration;
5 | using Microsoft.FeatureManagement;
6 |
7 | ///
8 | /// A filter that uses the feature management context to ensure that the current task has the notion of an account id, and that the account id is allowed.
9 | /// This filter will only be executed if an object implementing is passed in during feature evaluation.
10 | ///
11 | [FilterAlias("AccountId")]
12 | class AccountIdFilter : IContextualFeatureFilter
13 | {
14 | public Task EvaluateAsync(FeatureFilterEvaluationContext featureEvaluationContext, IAccountContext accountContext)
15 | {
16 | if (string.IsNullOrEmpty(accountContext?.AccountId))
17 | {
18 | throw new ArgumentNullException(nameof(accountContext));
19 | }
20 |
21 | var allowedAccounts = new List();
22 |
23 | featureEvaluationContext.Parameters.Bind("AllowedAccounts", allowedAccounts);
24 |
25 | return Task.FromResult(allowedAccounts.Contains(accountContext.AccountId));
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/FeatureFlagDemo/wwwroot/lib/jquery-validation/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | =====================
3 |
4 | Copyright Jörn Zaefferer
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/examples/VariantServiceDemo/wwwroot/lib/jquery-validation/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | =====================
3 |
4 | Copyright Jörn Zaefferer
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Microsoft Corporation. All rights reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
22 |
--------------------------------------------------------------------------------
/examples/BlazorServerApp/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | },
8 | "AllowedHosts": "*",
9 | "feature_management": {
10 | "feature_flags": [
11 | {
12 | "id": "BrowserEnhancement",
13 | "enabled": true,
14 | "conditions": {
15 | "client_filters": [
16 | {
17 | "name": "Browser",
18 | "parameters": {
19 | "AllowedBrowsers": [ "Edge" ]
20 | }
21 | }
22 | ]
23 | }
24 | },
25 | {
26 | "id": "Beta",
27 | "enabled": true,
28 | "conditions": {
29 | "client_filters": [
30 | {
31 | "name": "Targeting",
32 | "parameters": {
33 | "Audience": {
34 | "DefaultRolloutPercentage": 50,
35 | "Exclusion": {
36 | "Groups": [
37 | "Guests"
38 | ]
39 | }
40 | }
41 | }
42 | }
43 | ]
44 | }
45 | }
46 | ]
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/examples/VariantAndTelemetryDemo/wwwroot/lib/jquery-validation/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | =====================
3 |
4 | Copyright Jörn Zaefferer
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/examples/RazorPages/wwwroot/lib/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2021 Twitter, Inc.
4 | Copyright (c) 2011-2021 The Bootstrap Authors
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/FeatureManagementError.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | namespace Microsoft.FeatureManagement
5 | {
6 | ///
7 | /// An error that can occur during feature management.
8 | ///
9 | public enum FeatureManagementError
10 | {
11 | ///
12 | /// A feature filter that was listed for feature evaluation was not found.
13 | ///
14 | MissingFeatureFilter,
15 |
16 | ///
17 | /// A feature filter configured for the feature being evaluated is an ambiguous reference to multiple registered feature filters.
18 | ///
19 | AmbiguousFeatureFilter,
20 |
21 | ///
22 | /// A feature that was requested for evaluation was not found.
23 | ///
24 | MissingFeature,
25 |
26 | ///
27 | /// There was a conflict in the feature management system.
28 | ///
29 | Conflict,
30 |
31 | ///
32 | /// The given configuration setting was invalid.
33 | ///
34 | InvalidConfigurationSetting
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/examples/FeatureFlagDemo/wwwroot/lib/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2021 Twitter, Inc.
4 | Copyright (c) 2011-2021 The Bootstrap Authors
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/examples/VariantServiceDemo/wwwroot/lib/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2021 Twitter, Inc.
4 | Copyright (c) 2011-2021 The Bootstrap Authors
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/examples/BlazorServerApp/Pages/_Layout.cshtml:
--------------------------------------------------------------------------------
1 | @using Microsoft.AspNetCore.Components.Web
2 | @namespace BlazorServerApp.Pages
3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | @RenderBody()
18 |
19 |
20 |
21 | An error has occurred. This application may no longer respond until reloaded.
22 |
23 |
24 | An unhandled exception has occurred. See browser dev tools for details.
25 |
26 | Reload
27 | 🗙
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/examples/VariantAndTelemetryDemo/wwwroot/lib/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2021 Twitter, Inc.
4 | Copyright (c) 2011-2021 The Bootstrap Authors
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/pack.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .Synopsis
3 | This script creates NuGet packages from all of the projects in this repo.
4 |
5 | Note: build.cmd should be run before running this script.
6 |
7 | #>
8 |
9 | [CmdletBinding()]
10 | param(
11 | [Parameter()]
12 | [ValidateSet('Debug','Release')]
13 | [string]$BuildConfig = "Release"
14 | )
15 |
16 | $ErrorActionPreference = "Stop"
17 |
18 | $PublishRelativePath = "bin\PackageOutput"
19 | $LogDirectory = "$PSScriptRoot\buildlogs"
20 |
21 | $targetProjects = @(
22 |
23 | "Microsoft.FeatureManagement",
24 | "Microsoft.FeatureManagement.AspNetCore",
25 | "Microsoft.FeatureManagement.Telemetry.ApplicationInsights"
26 | )
27 |
28 | # Create the log directory.
29 | if ((Test-Path -Path $LogDirectory) -ne $true) {
30 | New-Item -ItemType Directory -Path $LogDirectory | Write-Verbose
31 | }
32 |
33 | $dotnet = & "$PSScriptRoot/build/resolve-dotnet.ps1"
34 |
35 | foreach ($project in $targetProjects)
36 | {
37 | $projectPath = "$PSScriptRoot\src\$project\$project.csproj"
38 | $outputPath = "$PSScriptRoot\src\$project\$PublishRelativePath"
39 |
40 | & $dotnet pack -c $BuildConfig -o "$outputPath" "$projectPath" --no-build | Tee-Object -FilePath "$LogDirectory\build.log"
41 | }
42 |
43 | exit $LASTEXITCODE
44 |
--------------------------------------------------------------------------------
/src/Microsoft.FeatureManagement/IFeatureFilter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT license.
3 | //
4 | using System.Threading.Tasks;
5 |
6 | namespace Microsoft.FeatureManagement
7 | {
8 | ///
9 | /// A filter that can be used to determine whether some criteria is met to enable a feature. A feature filter is free to use any criteria available, such as process state or request content. Feature filters can be registered for a given feature and if any feature filter evaluates to true, that feature will be considered enabled.
10 | ///
11 | public interface IFeatureFilter : IFeatureFilterMetadata
12 | {
13 | ///
14 | /// Evaluates the feature filter to see if the filter's criteria for being enabled has been satisfied.
15 | ///
16 | /// A feature filter evaluation context that contains information that may be needed to evaluate the filter. This context includes configuration, if any, for this filter for the feature being evaluated.
17 | /// True if the filter's criteria has been met, false otherwise.
18 | Task EvaluateAsync(FeatureFilterEvaluationContext context);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/examples/FeatureFlagDemo/Views/Home/Beta.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "Home Page";
3 | }
4 |
5 |
6 | Welcome to the new and sleek company portal.
7 |