diff --git a/examples/BlazorServerApp/BlazorServerApp.csproj b/examples/BlazorServerApp/BlazorServerApp.csproj index e1ab1c73..6e98b244 100644 --- a/examples/BlazorServerApp/BlazorServerApp.csproj +++ b/examples/BlazorServerApp/BlazorServerApp.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable diff --git a/examples/ConsoleApp/ConsoleApp.csproj b/examples/ConsoleApp/ConsoleApp.csproj index fe29b948..f2e84724 100644 --- a/examples/ConsoleApp/ConsoleApp.csproj +++ b/examples/ConsoleApp/ConsoleApp.csproj @@ -2,13 +2,14 @@ Exe - net6.0 + net8.0 enable - - + + + diff --git a/examples/FeatureFlagDemo/Authentication/QueryStringAuthenticationHandler.cs b/examples/FeatureFlagDemo/Authentication/QueryStringAuthenticationHandler.cs index 7770ed3d..027ede0b 100644 --- a/examples/FeatureFlagDemo/Authentication/QueryStringAuthenticationHandler.cs +++ b/examples/FeatureFlagDemo/Authentication/QueryStringAuthenticationHandler.cs @@ -15,13 +15,8 @@ namespace FeatureFlagDemo.Authentication /// /// To assign a user, use the following query string structure "?username=JohnDoe&groups=MyGroup1,MyGroup2" /// - class QueryStringAuthenticationHandler : AuthenticationHandler + class QueryStringAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder) : AuthenticationHandler(options, logger, encoder) { - public QueryStringAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) - : base(options, logger, encoder, clock) - { - } - protected override Task HandleAuthenticateAsync() { var identity = new ClaimsIdentity(); @@ -32,9 +27,9 @@ protected override Task HandleAuthenticateAsync() { string username = value.First(); - identity.AddClaim(new Claim(System.Security.Claims.ClaimTypes.Name, username)); + identity.AddClaim(new Claim(ClaimTypes.Name, username)); - Logger.LogInformation($"Assigning the username '{username}' to the request."); + Logger.LogInformation("Assigning the username {username} to the request.", username); } // @@ -48,7 +43,7 @@ protected override Task HandleAuthenticateAsync() identity.AddClaim(new Claim(ClaimTypes.Role, group)); } - Logger.LogInformation($"Assigning the following groups '{string.Join(", ", groups)}' to the request."); + Logger.LogInformation("Assigning the following groups '{groups}' to the request.", string.Join(", ", groups)); } // diff --git a/examples/FeatureFlagDemo/FeatureFlagDemo.csproj b/examples/FeatureFlagDemo/FeatureFlagDemo.csproj index 94a10cc8..ba61461d 100644 --- a/examples/FeatureFlagDemo/FeatureFlagDemo.csproj +++ b/examples/FeatureFlagDemo/FeatureFlagDemo.csproj @@ -1,12 +1,12 @@ - net6.0 + net8.0 enable - + diff --git a/examples/RazorPages/RazorPages.csproj b/examples/RazorPages/RazorPages.csproj index 2a2cbb46..6aef5a8f 100644 --- a/examples/RazorPages/RazorPages.csproj +++ b/examples/RazorPages/RazorPages.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable diff --git a/examples/TargetingConsoleApp/Program.cs b/examples/TargetingConsoleApp/Program.cs index d8ee6359..02c17542 100644 --- a/examples/TargetingConsoleApp/Program.cs +++ b/examples/TargetingConsoleApp/Program.cs @@ -17,7 +17,7 @@ services.AddSingleton(configuration) .AddFeatureManagement(); -IUserRepository userRepository = new InMemoryUserRepository(); +var userRepository = new InMemoryUserRepository(); // // Get the feature manager from application services diff --git a/examples/TargetingConsoleApp/TargetingConsoleApp.csproj b/examples/TargetingConsoleApp/TargetingConsoleApp.csproj index fe29b948..f2e84724 100644 --- a/examples/TargetingConsoleApp/TargetingConsoleApp.csproj +++ b/examples/TargetingConsoleApp/TargetingConsoleApp.csproj @@ -2,13 +2,14 @@ Exe - net6.0 + net8.0 enable - - + + + diff --git a/examples/VariantAndTelemetryDemo/Pages/Index.cshtml b/examples/VariantAndTelemetryDemo/Pages/Index.cshtml index af56c4de..b8971500 100644 --- a/examples/VariantAndTelemetryDemo/Pages/Index.cshtml +++ b/examples/VariantAndTelemetryDemo/Pages/Index.cshtml @@ -14,7 +14,7 @@

- Rate the image on a scale of 1 - 5 ! + Rate the image on a scale of 1 - 5 !

diff --git a/examples/VariantAndTelemetryDemo/Pages/Index.cshtml.cs b/examples/VariantAndTelemetryDemo/Pages/Index.cshtml.cs index 07b1d300..55a33c35 100644 --- a/examples/VariantAndTelemetryDemo/Pages/Index.cshtml.cs +++ b/examples/VariantAndTelemetryDemo/Pages/Index.cshtml.cs @@ -10,16 +10,14 @@ public class IndexModel : PageModel private readonly IVariantFeatureManager _featureManager; private readonly TelemetryClient _telemetry; - public string Username { get; set; } - - public IndexModel( - IVariantFeatureManager featureManager, - TelemetryClient telemetry) + public IndexModel(IVariantFeatureManager featureManager, TelemetryClient telemetry) { _featureManager = featureManager ?? throw new ArgumentNullException(nameof(featureManager)); _telemetry = telemetry ?? throw new ArgumentNullException(nameof(telemetry)); } + public string Username { get; set; } + public async Task OnGet() { Username = HttpContext.User.Identity.Name; diff --git a/examples/VariantAndTelemetryDemo/VariantAndTelemetryDemo.csproj b/examples/VariantAndTelemetryDemo/VariantAndTelemetryDemo.csproj index 85547e0d..fdd07a52 100644 --- a/examples/VariantAndTelemetryDemo/VariantAndTelemetryDemo.csproj +++ b/examples/VariantAndTelemetryDemo/VariantAndTelemetryDemo.csproj @@ -1,13 +1,12 @@ - net6.0 + net8.0 enable - diff --git a/examples/VariantServiceDemo/VariantServiceDemo.csproj b/examples/VariantServiceDemo/VariantServiceDemo.csproj index f4f7bbc6..fdd07a52 100644 --- a/examples/VariantServiceDemo/VariantServiceDemo.csproj +++ b/examples/VariantServiceDemo/VariantServiceDemo.csproj @@ -1,13 +1,12 @@ - + - net6.0 + net8.0 enable - diff --git a/src/Microsoft.FeatureManagement/FeatureManager.cs b/src/Microsoft.FeatureManagement/FeatureManager.cs index 10baef9d..2661bf88 100644 --- a/src/Microsoft.FeatureManagement/FeatureManager.cs +++ b/src/Microsoft.FeatureManagement/FeatureManager.cs @@ -698,9 +698,7 @@ private ValueTask AssignVariantAsync(EvaluationEvent evaluati private void BindSettings(IFeatureFilterMetadata filter, FeatureFilterEvaluationContext context, int filterIndex) { - IFilterParametersBinder binder = filter as IFilterParametersBinder; - - if (binder == null) + if (!(filter is IFilterParametersBinder binder)) { return; } @@ -714,13 +712,11 @@ private void BindSettings(IFeatureFilterMetadata filter, FeatureFilterEvaluation object settings; - ConfigurationCacheItem cacheItem; - string cacheKey = $"Microsoft.FeatureManagement{Environment.NewLine}{context.FeatureName}{Environment.NewLine}{filterIndex}"; // // Check if settings already bound from configuration or the parameters have changed - if (!Cache.TryGetValue(cacheKey, out cacheItem) || + if (!Cache.TryGetValue(cacheKey, out ConfigurationCacheItem cacheItem) || cacheItem.Parameters != context.Parameters) { settings = binder.BindParameters(context.Parameters); diff --git a/tests/Tests.FeatureManagement.AspNetCore/Tests.FeatureManagement.AspNetCore.csproj b/tests/Tests.FeatureManagement.AspNetCore/Tests.FeatureManagement.AspNetCore.csproj index 47592cc5..72916ae8 100644 --- a/tests/Tests.FeatureManagement.AspNetCore/Tests.FeatureManagement.AspNetCore.csproj +++ b/tests/Tests.FeatureManagement.AspNetCore/Tests.FeatureManagement.AspNetCore.csproj @@ -14,26 +14,28 @@ - - - + + + - + - + + + diff --git a/tests/Tests.FeatureManagement/Tests.FeatureManagement.csproj b/tests/Tests.FeatureManagement/Tests.FeatureManagement.csproj index 367b945e..829caf87 100644 --- a/tests/Tests.FeatureManagement/Tests.FeatureManagement.csproj +++ b/tests/Tests.FeatureManagement/Tests.FeatureManagement.csproj @@ -9,32 +9,34 @@ - - - + + + - + - + - + + +