Browse Source
Address Copilot review
- SettingManager.GetAllAsync / FeatureManager.GetAllWithProviderAsync: drop top-level continue and rely on the provider chain filter so allowed upstream providers can still be read via inheritance (e.g. GetAllForUserAsync now returns a Global-only setting)
- FeatureAppService.GetAsync: switch includedFeatures to HashSet for O(1) parent lookup
pull/25462/head
maliming
4 months ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
4 changed files with
24 additions and
11 deletions
modules/feature-management/src/Volo.Abp.FeatureManagement.Application/Volo/Abp/FeatureManagement/FeatureAppService.cs
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureManager.cs
modules/setting-management/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingManager.cs
modules/setting-management/test/Volo.Abp.SettingManagement.Tests/Volo/Abp/SettingManagement/SettingManager_Basic_Tests.cs
@ -38,7 +38,7 @@ public class FeatureAppService : FeatureManagementAppServiceBase, IFeatureAppSer
{
var groupDto = CreateFeatureGroupDto ( group ) ;
var includedFeatures = new Lis t< FeatureDefinition > ( ) ;
var includedFeatures = new HashSe t< FeatureDefinition > ( ) ;
foreach ( var featureDefinition in group . GetFeaturesWithChildren ( ) )
{
if ( providerName = = TenantFeatureValueProvider . ProviderName & &
@ -93,15 +93,15 @@ public class FeatureManager : IFeatureManager, ISingletonDependency
foreach ( var feature in featureDefinitions )
{
if ( feature . AllowedProviders . Any ( ) & & ! feature . AllowedProviders . Contains ( providerName ) )
{
continue ;
}
var featureProviderList = feature . AllowedProviders . Any ( )
? providerList . Where ( p = > feature . AllowedProviders . Contains ( p . Name ) ) . ToList ( )
: providerList ;
if ( ! featureProviderList . Any ( ) )
{
continue ;
}
var featureNameValueWithGrantedProvider = new FeatureNameValueWithGrantedProvider ( feature . Name , null ) ;
foreach ( var provider in featureProviderList )
{
@ -73,15 +73,15 @@ public class SettingManager : ISettingManager, ISingletonDependency
foreach ( var setting in settingDefinitions )
{
if ( setting . Providers . Any ( ) & & ! setting . Providers . Contains ( providerName ) )
{
continue ;
}
var settingProviderList = setting . Providers . Any ( )
? providerList . Where ( p = > setting . Providers . Contains ( p . Name ) ) . ToList ( )
: providerList ;
if ( ! settingProviderList . Any ( ) )
{
continue ;
}
string value = null ;
if ( setting . IsInherited )
@ -128,6 +128,19 @@ public class SettingManager_Basic_Tests : SettingsTestBase
TestSettingDefinitionProvider . UserOnlySetting ) ) . ShouldBeNull ( ) ;
}
[Fact]
public async Task GetAllForUser_Should_Inherit_Setting_From_Allowed_Upstream_Provider ( )
{
await _ settingManager . SetGlobalAsync (
TestSettingDefinitionProvider . GlobalOnlySetting ,
"global-value" ) ;
var userSettings = await _ settingManager . GetAllForUserAsync ( Guid . NewGuid ( ) ) ;
userSettings . ShouldContain ( x = >
x . Name = = TestSettingDefinitionProvider . GlobalOnlySetting & & x . Value = = "global-value" ) ;
}
[Fact]
public async Task GetOrNullForUser_Should_Inherit_Value_From_Allowed_Upstream_Provider ( )
{