Skip to content

Commit a286d43

Browse files
committed
Revert "Revert "Revert "Add cancellation token parameter to async feature management interfaces. (#131)" (#139)""
This reverts commit c1451d3.
1 parent 77fc24b commit a286d43

34 files changed

+103
-160
lines changed

examples/ConsoleApp/FeatureFilters/AccountIdFilter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Microsoft.FeatureManagement;
77
using System;
88
using System.Collections.Generic;
9-
using System.Threading;
109
using System.Threading.Tasks;
1110

1211
namespace Consoto.Banking.AccountService.FeatureManagement
@@ -18,7 +17,7 @@ namespace Consoto.Banking.AccountService.FeatureManagement
1817
[FilterAlias("AccountId")]
1918
class AccountIdFilter : IContextualFeatureFilter<IAccountContext>
2019
{
21-
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureEvaluationContext, IAccountContext accountContext, CancellationToken _)
20+
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureEvaluationContext, IAccountContext accountContext)
2221
{
2322
if (string.IsNullOrEmpty(accountContext?.AccountId))
2423
{

examples/ConsoleApp/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Microsoft.FeatureManagement.FeatureFilters;
99
using System;
1010
using System.Collections.Generic;
11-
using System.Threading;
1211
using System.Threading.Tasks;
1312

1413
namespace Consoto.Banking.AccountService
@@ -59,7 +58,7 @@ public static async Task Main(string[] args)
5958
AccountId = account
6059
};
6160

62-
bool enabled = await featureManager.IsEnabledAsync(FeatureName, accountServiceContext, CancellationToken.None);
61+
bool enabled = await featureManager.IsEnabledAsync(FeatureName, accountServiceContext);
6362

6463
//
6564
// Output results

examples/FeatureFlagDemo/BrowserFilter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Microsoft.FeatureManagement;
77
using System;
88
using System.Linq;
9-
using System.Threading;
109
using System.Threading.Tasks;
1110

1211
namespace FeatureFlagDemo.FeatureManagement.FeatureFilters
@@ -24,7 +23,7 @@ public BrowserFilter(IHttpContextAccessor httpContextAccessor)
2423
_httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
2524
}
2625

27-
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, CancellationToken _)
26+
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context)
2827
{
2928
BrowserFilterSettings settings = context.Parameters.Get<BrowserFilterSettings>() ?? new BrowserFilterSettings();
3029

examples/FeatureFlagDemo/Controllers/HomeController.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Microsoft.FeatureManagement;
99
using Microsoft.FeatureManagement.Mvc;
1010
using System.Threading.Tasks;
11-
using System.Threading;
1211

1312
namespace FeatureFlagDemo.Controllers
1413
{
@@ -22,16 +21,16 @@ public HomeController(IFeatureManagerSnapshot featureSnapshot)
2221
}
2322

2423
[FeatureGate(MyFeatureFlags.Home)]
25-
public Task<IActionResult> Index()
24+
public IActionResult Index()
2625
{
2726
return View();
2827
}
2928

30-
public async Task<IActionResult> About(CancellationToken cancellationToken)
29+
public async Task<IActionResult> About()
3130
{
3231
ViewData["Message"] = "Your application description page.";
3332

34-
if (await _featureManager.IsEnabledAsync(nameof(MyFeatureFlags.CustomViewData), cancellationToken))
33+
if (await _featureManager.IsEnabledAsync(nameof(MyFeatureFlags.CustomViewData)))
3534
{
3635
ViewData["Message"] = $"This is FANCY CONTENT you can see only if '{nameof(MyFeatureFlags.CustomViewData)}' is enabled.";
3736
};

examples/FeatureFlagDemo/HttpContextTargetingContextAccessor.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System;
77
using System.Collections.Generic;
88
using System.Security.Claims;
9-
using System.Threading;
109
using System.Threading.Tasks;
1110

1211
namespace FeatureFlagDemo
@@ -24,7 +23,7 @@ public HttpContextTargetingContextAccessor(IHttpContextAccessor httpContextAcces
2423
_httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
2524
}
2625

27-
public ValueTask<TargetingContext> GetContextAsync(CancellationToken _)
26+
public ValueTask<TargetingContext> GetContextAsync()
2827
{
2928
HttpContext httpContext = _httpContextAccessor.HttpContext;
3029

examples/FeatureFlagDemo/SuperUserFilter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
// Licensed under the MIT license.
33
//
44
using Microsoft.FeatureManagement;
5-
using System.Threading;
65
using System.Threading.Tasks;
76

87
namespace FeatureFlagDemo.FeatureManagement.FeatureFilters
98
{
109
public class SuperUserFilter : IFeatureFilter
1110
{
12-
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, CancellationToken _)
11+
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context)
1312
{
1413
return Task.FromResult(false);
1514
}

examples/TargetingConsoleApp/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System;
1010
using System.Collections.Generic;
1111
using System.Linq;
12-
using System.Threading;
1312
using System.Threading.Tasks;
1413

1514
namespace Consoto.Banking.HelpDesk
@@ -63,7 +62,7 @@ public static async Task Main(string[] args)
6362
Groups = user.Groups
6463
};
6564

66-
bool enabled = await featureManager.IsEnabledAsync(FeatureName, targetingContext, CancellationToken.None);
65+
bool enabled = await featureManager.IsEnabledAsync(FeatureName, targetingContext);
6766

6867
//
6968
// Output results

src/Microsoft.FeatureManagement.AspNetCore/FeatureGateAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ public override async Task OnActionExecutionAsync(ActionExecutingContext context
107107
//
108108
// Enabled state is determined by either 'any' or 'all' features being enabled.
109109
bool enabled = RequirementType == RequirementType.All ?
110-
await Features.All(async feature => await fm.IsEnabledAsync(feature, context.HttpContext.RequestAborted).ConfigureAwait(false)).ConfigureAwait(false) :
111-
await Features.Any(async feature => await fm.IsEnabledAsync(feature, context.HttpContext.RequestAborted).ConfigureAwait(false)).ConfigureAwait(false);
110+
await Features.All(async feature => await fm.IsEnabledAsync(feature).ConfigureAwait(false)) :
111+
await Features.Any(async feature => await fm.IsEnabledAsync(feature).ConfigureAwait(false));
112112

113113
if (enabled)
114114
{

src/Microsoft.FeatureManagement.AspNetCore/FeatureGatedAsyncActionFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionE
3030
{
3131
IFeatureManager featureManager = context.HttpContext.RequestServices.GetRequiredService<IFeatureManagerSnapshot>();
3232

33-
if (await featureManager.IsEnabledAsync(FeatureName, context.HttpContext.RequestAborted).ConfigureAwait(false))
33+
if (await featureManager.IsEnabledAsync(FeatureName).ConfigureAwait(false))
3434
{
3535
IServiceProvider serviceProvider = context.HttpContext.RequestServices.GetRequiredService<IServiceProvider>();
3636

src/Microsoft.FeatureManagement.AspNetCore/TagHelpers/FeatureTagHelper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Microsoft.AspNetCore.Razor.TagHelpers;
55
using System.Collections.Generic;
66
using System.Linq;
7-
using System.Threading;
87
using System.Threading.Tasks;
98

109
namespace Microsoft.FeatureManagement.Mvc.TagHelpers
@@ -56,8 +55,8 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
5655
IEnumerable<string> names = Name.Split(',').Select(n => n.Trim());
5756

5857
enabled = Requirement == RequirementType.All ?
59-
await names.All(async n => await _featureManager.IsEnabledAsync(n, CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false) :
60-
await names.Any(async n => await _featureManager.IsEnabledAsync(n, CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false);
58+
await names.All(async n => await _featureManager.IsEnabledAsync(n).ConfigureAwait(false)) :
59+
await names.Any(async n => await _featureManager.IsEnabledAsync(n).ConfigureAwait(false));
6160
}
6261

6362
if (Negate)

0 commit comments

Comments
 (0)