Skip to content

Commit

Permalink
Revert "Added default value for cancellation token in interfaces to k…
Browse files Browse the repository at this point in the history
…eep existing usage possible. (#133)" (#138)

This reverts commit c24f4fd.
  • Loading branch information
jimmyca15 authored Aug 31, 2021
1 parent c24f4fd commit 8f9a7e4
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion examples/ConsoleApp/FeatureFilters/AccountIdFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Consoto.Banking.AccountService.FeatureManagement
[FilterAlias("AccountId")]
class AccountIdFilter : IContextualFeatureFilter<IAccountContext>
{
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureEvaluationContext, IAccountContext accountContext, CancellationToken cancellationToken)
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureEvaluationContext, IAccountContext accountContext, CancellationToken _)
{
if (string.IsNullOrEmpty(accountContext?.AccountId))
{
Expand Down
2 changes: 1 addition & 1 deletion examples/FeatureFlagDemo/BrowserFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public BrowserFilter(IHttpContextAccessor httpContextAccessor)
_httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
}

public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, CancellationToken cancellationToken)
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, CancellationToken _)
{
BrowserFilterSettings settings = context.Parameters.Get<BrowserFilterSettings>() ?? new BrowserFilterSettings();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public HttpContextTargetingContextAccessor(IHttpContextAccessor httpContextAcces
_httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
}

public ValueTask<TargetingContext> GetContextAsync(CancellationToken cancellationToken)
public ValueTask<TargetingContext> GetContextAsync(CancellationToken _)
{
HttpContext httpContext = _httpContextAccessor.HttpContext;

Expand Down
2 changes: 1 addition & 1 deletion examples/FeatureFlagDemo/SuperUserFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace FeatureFlagDemo.FeatureManagement.FeatureFilters
{
public class SuperUserFilter : IFeatureFilter
{
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, CancellationToken cancellationToken)
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, CancellationToken _)
{
return Task.FromResult(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void Dispose()
_changeSubscription = null;
}

public Task<FeatureDefinition> GetFeatureDefinitionAsync(string featureName, CancellationToken cancellationToken)
public Task<FeatureDefinition> GetFeatureDefinitionAsync(string featureName, CancellationToken _)
{
if (featureName == null)
{
Expand All @@ -64,7 +64,7 @@ public Task<FeatureDefinition> GetFeatureDefinitionAsync(string featureName, Can
// The async key word is necessary for creating IAsyncEnumerable.
// The need to disable this warning occurs when implementaing async stream synchronously.
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async IAsyncEnumerable<FeatureDefinition> GetAllFeatureDefinitionsAsync([EnumeratorCancellation] CancellationToken cancellationToken)
public async IAsyncEnumerable<FeatureDefinition> GetAllFeatureDefinitionsAsync([EnumeratorCancellation] CancellationToken _)
#pragma warning restore CS1998
{
if (Interlocked.Exchange(ref _stale, 0) != 0)
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.FeatureManagement/EmptySessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace Microsoft.FeatureManagement
/// </summary>
class EmptySessionManager : ISessionManager
{
public Task SetAsync(string featureName, bool enabled, CancellationToken cancellationToken)
public Task SetAsync(string featureName, bool enabled, CancellationToken _)
{
return Task.CompletedTask;
}

public Task<bool?> GetAsync(string featureName, CancellationToken cancellationToken)
public Task<bool?> GetAsync(string featureName, CancellationToken _)
{
return Task.FromResult((bool?)null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public interface IContextualFeatureFilter<TContext> : IFeatureFilterMetadata
/// <param name="appContext">A context defined by the application that is passed in to the feature management system to provide contextual information for evaluating a feature's state.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>True if the filter's criteria has been met, false otherwise.</returns>
Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureFilterContext, TContext appContext, CancellationToken cancellationToken = default);
Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureFilterContext, TContext appContext, CancellationToken cancellationToken);
}
}
4 changes: 2 additions & 2 deletions src/Microsoft.FeatureManagement/IFeatureDefinitionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public interface IFeatureDefinitionProvider
/// <param name="featureName">The name of the feature to retrieve the definition for.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>The feature's definition.</returns>
Task<FeatureDefinition> GetFeatureDefinitionAsync(string featureName, CancellationToken cancellationToken = default);
Task<FeatureDefinition> GetFeatureDefinitionAsync(string featureName, CancellationToken cancellationToken);

/// <summary>
/// Retrieves definitions for all features.
/// </summary>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>An enumerator which provides asynchronous iteration over feature definitions.</returns>
IAsyncEnumerable<FeatureDefinition> GetAllFeatureDefinitionsAsync(CancellationToken cancellationToken = default);
IAsyncEnumerable<FeatureDefinition> GetAllFeatureDefinitionsAsync(CancellationToken cancellationToken);
}
}
2 changes: 1 addition & 1 deletion src/Microsoft.FeatureManagement/IFeatureFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public interface IFeatureFilter : IFeatureFilterMetadata
/// <param name="context">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.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>True if the filter's criteria has been met, false otherwise.</returns>
Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, CancellationToken cancellationToken = default);
Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, CancellationToken cancellationToken);
}
}
6 changes: 3 additions & 3 deletions src/Microsoft.FeatureManagement/IFeatureManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public interface IFeatureManager
/// </summary>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>An enumerator which provides asynchronous iteration over the feature names registered in the feature manager.</returns>
IAsyncEnumerable<string> GetFeatureNamesAsync(CancellationToken cancellationToken = default);
IAsyncEnumerable<string> GetFeatureNamesAsync(CancellationToken cancellationToken);

/// <summary>
/// Checks whether a given feature is enabled.
/// </summary>
/// <param name="feature">The name of the feature to check.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>True if the feature is enabled, otherwise false.</returns>
Task<bool> IsEnabledAsync(string feature, CancellationToken cancellationToken = default);
Task<bool> IsEnabledAsync(string feature, CancellationToken cancellationToken);

/// <summary>
/// Checks whether a given feature is enabled.
Expand All @@ -34,6 +34,6 @@ public interface IFeatureManager
/// <param name="context">A context providing information that can be used to evaluate whether a feature should be on or off.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>True if the feature is enabled, otherwise false.</returns>
Task<bool> IsEnabledAsync<TContext>(string feature, TContext context, CancellationToken cancellationToken = default);
Task<bool> IsEnabledAsync<TContext>(string feature, TContext context, CancellationToken cancellationToken);
}
}
4 changes: 2 additions & 2 deletions src/Microsoft.FeatureManagement/ISessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public interface ISessionManager
/// <param name="featureName">The name of the feature.</param>
/// <param name="enabled">The state of the feature.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
Task SetAsync(string featureName, bool enabled, CancellationToken cancellationToken = default);
Task SetAsync(string featureName, bool enabled, CancellationToken cancellationToken);

/// <summary>
/// Queries the session manager for the session's feature state, if any, for the given feature.
/// </summary>
/// <param name="featureName">The name of the feature.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>The state of the feature if it is present in the session, otherwise null.</returns>
Task<bool?> GetAsync(string featureName, CancellationToken cancellationToken = default);
Task<bool?> GetAsync(string featureName, CancellationToken cancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public interface ITargetingContextAccessor
/// </summary>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>The current targeting context.</returns>
ValueTask<TargetingContext> GetContextAsync(CancellationToken cancellationToken = default);
ValueTask<TargetingContext> GetContextAsync(CancellationToken cancellationToken);
}
}
2 changes: 1 addition & 1 deletion tests/Tests.FeatureManagement/ContextualTestFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ContextualTestFilter : IContextualFeatureFilter<IAccountContext>
{
public Func<FeatureFilterEvaluationContext, IAccountContext, bool> ContextualCallback { get; set; }

public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, IAccountContext accountContext, CancellationToken cancellationToken)
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, IAccountContext accountContext, CancellationToken _)
{
return Task.FromResult(ContextualCallback?.Invoke(context, accountContext) ?? false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public InMemoryFeatureDefinitionProvider(IEnumerable<FeatureDefinition> featureD
}

#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async IAsyncEnumerable<FeatureDefinition> GetAllFeatureDefinitionsAsync([EnumeratorCancellation] CancellationToken cancellationToken)
public async IAsyncEnumerable<FeatureDefinition> GetAllFeatureDefinitionsAsync([EnumeratorCancellation] CancellationToken _)
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
foreach (FeatureDefinition definition in _definitions)
Expand All @@ -27,7 +27,7 @@ public async IAsyncEnumerable<FeatureDefinition> GetAllFeatureDefinitionsAsync([
}
}

public Task<FeatureDefinition> GetFeatureDefinitionAsync(string featureName, CancellationToken cancellationToken)
public Task<FeatureDefinition> GetFeatureDefinitionAsync(string featureName, CancellationToken _)
{
return Task.FromResult(_definitions.FirstOrDefault(definitions => definitions.Name.Equals(featureName, StringComparison.OrdinalIgnoreCase)));
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Tests.FeatureManagement/InvalidFeatureFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace Tests.FeatureManagement
// Cannot implement more than one IFeatureFilter interface
class InvalidFeatureFilter : IContextualFeatureFilter<IAccountContext>, IContextualFeatureFilter<object>
{
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, IAccountContext accountContext, CancellationToken cancellationToken)
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, IAccountContext accountContext, CancellationToken _)
{
return Task.FromResult(false);
}

public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureFilterContext, object appContext, CancellationToken cancellationToken)
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureFilterContext, object appContext, CancellationToken _)
{
return Task.FromResult(false);
}
Expand All @@ -26,12 +26,12 @@ public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureFilterCont
// Cannot implement more than one IFeatureFilter interface
class InvalidFeatureFilter2 : IFeatureFilter, IContextualFeatureFilter<object>
{
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureFilterContext, object appContext, CancellationToken cancellationToken)
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureFilterContext, object appContext, CancellationToken _)
{
return Task.FromResult(false);
}

public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, CancellationToken cancellationToken)
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, CancellationToken _)
{
return Task.FromResult(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class OnDemandTargetingContextAccessor : ITargetingContextAccessor
{
public TargetingContext Current { get; set; }

public ValueTask<TargetingContext> GetContextAsync(CancellationToken cancellationToken)
public ValueTask<TargetingContext> GetContextAsync(CancellationToken _)
{
return new ValueTask<TargetingContext>(Current);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Tests.FeatureManagement/TestFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TestFilter : IFeatureFilter
{
public Func<FeatureFilterEvaluationContext, bool> Callback { get; set; }

public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, CancellationToken cancellationToken)
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, CancellationToken _)
{
return Task.FromResult(Callback?.Invoke(context) ?? false);
}
Expand Down

0 comments on commit 8f9a7e4

Please sign in to comment.