From b9f16b341e9d20777c1af271369f92df215785f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 3 Jan 2023 17:04:16 +0300 Subject: [PATCH 1/2] Set defaults while adding features --- .../Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs | 2 +- .../Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs | 4 ++-- .../Volo/Abp/FeatureManagement/FeatureDefinitionRecord.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs index f94be12ba1..893b5bbc1c 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs @@ -11,7 +11,7 @@ public abstract class FeatureCheckerBase : IFeatureChecker, ITransientDependency public virtual async Task IsEnabledAsync(string name) { var value = await GetOrNullAsync(name); - if (value == null) + if (value.IsNullOrEmpty()) { return false; } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs index 5ea7377fd7..14cd0d405b 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs @@ -100,11 +100,11 @@ public class FeatureDefinition : ICanCreateChildFeature bool isVisibleToClients = true, bool isAvailableToHost = true) { - Name = name; + Name = Check.NotNullOrWhiteSpace(name, nameof(name)); DefaultValue = defaultValue; DisplayName = displayName ?? new FixedLocalizableString(name); Description = description; - ValueType = valueType; + ValueType = valueType ?? new ToggleStringValueType(); IsVisibleToClients = isVisibleToClients; IsAvailableToHost = isAvailableToHost; diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureDefinitionRecord.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureDefinitionRecord.cs index 618f52d7a1..0c181ab632 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureDefinitionRecord.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureDefinitionRecord.cs @@ -70,7 +70,7 @@ public class FeatureDefinitionRecord : BasicAggregateRoot, IHasExtraProper DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), FeatureDefinitionRecordConsts.MaxDisplayNameLength); Description = Check.Length(description, nameof(description), FeatureDefinitionRecordConsts.MaxDescriptionLength); - DefaultValue = Check.NotNullOrWhiteSpace(defaultValue, nameof(defaultValue), FeatureDefinitionRecordConsts.MaxDefaultValueLength); + DefaultValue = Check.Length(defaultValue, nameof(defaultValue), FeatureDefinitionRecordConsts.MaxDefaultValueLength); IsVisibleToClients = isVisibleToClients; IsAvailableToHost = isAvailableToHost; From e2eaa1dd37d680968a17218082191363f2c7cc88 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 4 Jan 2023 09:18:17 +0800 Subject: [PATCH 2/2] Disable `Transaction`. --- .../AbpFeatureManagementEntityFrameworkCoreTestModule.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/feature-management/test/Volo.Abp.FeatureManagement.EntityFrameworkCore.Tests/Volo/Abp/FeatureManagement/EntityFrameworkCore/AbpFeatureManagementEntityFrameworkCoreTestModule.cs b/modules/feature-management/test/Volo.Abp.FeatureManagement.EntityFrameworkCore.Tests/Volo/Abp/FeatureManagement/EntityFrameworkCore/AbpFeatureManagementEntityFrameworkCoreTestModule.cs index f1a0a4bf3b..e85e246094 100644 --- a/modules/feature-management/test/Volo.Abp.FeatureManagement.EntityFrameworkCore.Tests/Volo/Abp/FeatureManagement/EntityFrameworkCore/AbpFeatureManagementEntityFrameworkCoreTestModule.cs +++ b/modules/feature-management/test/Volo.Abp.FeatureManagement.EntityFrameworkCore.Tests/Volo/Abp/FeatureManagement/EntityFrameworkCore/AbpFeatureManagementEntityFrameworkCoreTestModule.cs @@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore.Storage; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.Sqlite; using Volo.Abp.Modularity; +using Volo.Abp.Uow; namespace Volo.Abp.FeatureManagement.EntityFrameworkCore; @@ -26,6 +27,11 @@ public class AbpFeatureManagementEntityFrameworkCoreTestModule : AbpModule abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection); }); }); + + Configure(options => + { + options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; + }); } private static SqliteConnection CreateDatabaseAndGetConnection()