From bca1776fcafca36c8d0b75625a2f2bf0b354e365 Mon Sep 17 00:00:00 2001 From: Zhiyuan Liang Date: Wed, 15 May 2024 17:32:25 +0800 Subject: [PATCH 1/4] replace init with set --- .../ConfigurationFeatureDefinitionProvider.cs | 4 ++-- .../FeatureFilters/TimeWindowFilter.cs | 4 ++-- .../FeatureManager.cs | 12 +++++------ .../IsExternalInit.cs | 21 ------------------- 4 files changed, 10 insertions(+), 31 deletions(-) delete mode 100644 src/Microsoft.FeatureManagement/IsExternalInit.cs diff --git a/src/Microsoft.FeatureManagement/ConfigurationFeatureDefinitionProvider.cs b/src/Microsoft.FeatureManagement/ConfigurationFeatureDefinitionProvider.cs index 3ae10329..ebd1c621 100644 --- a/src/Microsoft.FeatureManagement/ConfigurationFeatureDefinitionProvider.cs +++ b/src/Microsoft.FeatureManagement/ConfigurationFeatureDefinitionProvider.cs @@ -58,12 +58,12 @@ public ConfigurationFeatureDefinitionProvider(IConfiguration configuration) /// /// The option that controls the behavior when "FeatureManagement" section in the configuration is missing. /// - public bool RootConfigurationFallbackEnabled { get; init; } + public bool RootConfigurationFallbackEnabled { get; set; } /// /// The logger for the configuration feature definition provider. /// - public ILogger Logger { get; init; } + public ILogger Logger { get; set; } /// /// Disposes the change subscription of the configuration. diff --git a/src/Microsoft.FeatureManagement/FeatureFilters/TimeWindowFilter.cs b/src/Microsoft.FeatureManagement/FeatureFilters/TimeWindowFilter.cs index 121bb4cf..fb1f6f01 100644 --- a/src/Microsoft.FeatureManagement/FeatureFilters/TimeWindowFilter.cs +++ b/src/Microsoft.FeatureManagement/FeatureFilters/TimeWindowFilter.cs @@ -34,12 +34,12 @@ public TimeWindowFilter(ILoggerFactory loggerFactory = null) /// /// The application memory cache to store the start time of the closest active time window. By caching this time, the time window can minimize redundant computations when evaluating recurrence. /// - public IMemoryCache Cache { get; init; } + public IMemoryCache Cache { get; set; } /// /// This property allows the time window filter in our test suite to use simulated time. /// - internal ISystemClock SystemClock { get; init; } + internal ISystemClock SystemClock { get; set; } /// /// Binds configuration representing filter parameters to . diff --git a/src/Microsoft.FeatureManagement/FeatureManager.cs b/src/Microsoft.FeatureManagement/FeatureManager.cs index ef850a03..9080929d 100644 --- a/src/Microsoft.FeatureManagement/FeatureManager.cs +++ b/src/Microsoft.FeatureManagement/FeatureManager.cs @@ -21,11 +21,11 @@ public sealed class FeatureManager : IFeatureManager private readonly TimeSpan ParametersCacheAbsoluteExpirationRelativeToNow = TimeSpan.FromDays(1); private readonly IFeatureDefinitionProvider _featureDefinitionProvider; - private readonly IEnumerable _featureFilters; - private readonly IEnumerable _sessionManagers; private readonly ConcurrentDictionary _filterMetadataCache; private readonly ConcurrentDictionary _contextualFeatureFilterCache; private readonly FeatureManagementOptions _options; + private IEnumerable _featureFilters; + private IEnumerable _sessionManagers; private class ConfigurationCacheItem { @@ -60,7 +60,7 @@ public IEnumerable FeatureFilters { get => _featureFilters; - init + set { _featureFilters = value ?? throw new ArgumentNullException(nameof(value)); } @@ -74,7 +74,7 @@ public IEnumerable SessionManagers { get => _sessionManagers; - init + set { _sessionManagers = value ?? throw new ArgumentNullException(nameof(value)); } @@ -83,12 +83,12 @@ public IEnumerable SessionManagers /// /// The application memory cache to store feature filter settings. /// - public IMemoryCache Cache { get; init; } + public IMemoryCache Cache { get; set; } /// /// The logger for the feature manager. /// - public ILogger Logger { get; init; } + public ILogger Logger { get; set; } /// /// Checks whether a given feature is enabled. diff --git a/src/Microsoft.FeatureManagement/IsExternalInit.cs b/src/Microsoft.FeatureManagement/IsExternalInit.cs deleted file mode 100644 index 2798741c..00000000 --- a/src/Microsoft.FeatureManagement/IsExternalInit.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -// - -// The init accessor for properties is supported in C# 9.0 and later. -// This class is used to compile .NET frameworks that don't support C# 9.0 or later while still using the init accessor for a property. -// The code referenced for this file can be found here: https://github.com/dotnet/roslyn/issues/45510#issuecomment-725091019 - -#if NETSTANDARD2_0 || NETSTANDARD2_1 - -using System.ComponentModel; - -namespace System.Runtime.CompilerServices -{ - [EditorBrowsable(EditorBrowsableState.Never)] - internal static class IsExternalInit - { - } -} - -#endif From 41a40026dd8637fdbb19a3ad3025e1ad9c833ea2 Mon Sep 17 00:00:00 2001 From: Zhiyuan Liang Date: Wed, 22 May 2024 10:31:59 +0800 Subject: [PATCH 2/4] revert to csharp 8.0 --- .../Microsoft.FeatureManagement.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj b/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj index dd67ba56..daa70b43 100644 --- a/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj +++ b/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj @@ -15,7 +15,7 @@ true false ..\..\build\Microsoft.FeatureManagement.snk - 9.0 + 8.0 From d9445086f381d5245656593912f11bf40b989755 Mon Sep 17 00:00:00 2001 From: zhiyuanliang Date: Wed, 29 May 2024 00:42:01 +0800 Subject: [PATCH 3/4] add comment for LangVersion --- .../Microsoft.FeatureManagement.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj b/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj index be86daad..4ae8ed69 100644 --- a/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj +++ b/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj @@ -15,6 +15,7 @@ true false ..\..\build\Microsoft.FeatureManagement.snk + 8.0 From c8e808c2eb54a89458a40eff198dab4e81efeb34 Mon Sep 17 00:00:00 2001 From: Zhiyuan Liang Date: Wed, 12 Jun 2024 11:43:11 +0800 Subject: [PATCH 4/4] update comment --- .../Microsoft.FeatureManagement.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj b/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj index 4ae8ed69..ea79919a 100644 --- a/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj +++ b/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj @@ -15,7 +15,8 @@ true false ..\..\build\Microsoft.FeatureManagement.snk - + 8.0