From fdd547b85238493f76e686edb2f390b3546b708d Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 6 Jun 2023 15:36:50 +0800 Subject: [PATCH] Enable nullable annotations for Volo.Abp.ObjectExtending --- .../Volo.Abp.ObjectExtending.csproj | 2 ++ .../Data/ExtraPropertyDictionaryExtensions.cs | 4 +-- .../Abp/Data/HasExtraPropertiesExtensions.cs | 10 +++---- .../ObjectExtending/ExtensibleObjectMapper.cs | 16 +++++----- .../ExtensibleObjectValidator.cs | 30 +++++++++---------- .../ExtensionPropertyHelper.cs | 6 ++-- ...xtraPropertiesObjectExtendingExtensions.cs | 2 +- .../IBasicObjectExtensionPropertyInfo.cs | 9 ++---- .../EntityExtensionConfiguration.cs | 4 +-- .../ExtensionPropertyConfiguration.cs | 11 +++---- ...xtensionPropertyConfigurationExtensions.cs | 4 +-- .../ExtensionPropertyLookupConfiguration.cs | 2 +- .../ModuleExtensionConfigurationHelper.cs | 22 +++++++------- .../ModuleObjectExtensionManagerExtensions.cs | 4 +-- .../ObjectExtending/ObjectExtensionInfo.cs | 7 ++--- .../ObjectExtending/ObjectExtensionManager.cs | 12 ++++---- .../ObjectExtensionManagerExtensions.cs | 12 ++++---- .../ObjectExtensionPropertyInfo.cs | 11 +++---- ...bjectExtensionPropertyValidationContext.cs | 8 ++--- .../ObjectExtensionValidationContext.cs | 3 +- 20 files changed, 83 insertions(+), 96 deletions(-) diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo.Abp.ObjectExtending.csproj b/framework/src/Volo.Abp.ObjectExtending/Volo.Abp.ObjectExtending.csproj index de9711ff6a..e427f154c7 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo.Abp.ObjectExtending.csproj +++ b/framework/src/Volo.Abp.ObjectExtending/Volo.Abp.ObjectExtending.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.ObjectExtending Volo.Abp.ObjectExtending $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/ExtraPropertyDictionaryExtensions.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/ExtraPropertyDictionaryExtensions.cs index d5de504afc..6c4cd02d1b 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/ExtraPropertyDictionaryExtensions.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/ExtraPropertyDictionaryExtensions.cs @@ -13,7 +13,7 @@ public static class ExtraPropertyDictionaryExtensions return (T)extraPropertyDictionary[key]; } - extraPropertyDictionary[key] = Enum.Parse(typeof(T), extraPropertyDictionary[key].ToString(), ignoreCase: true); + extraPropertyDictionary[key] = Enum.Parse(typeof(T), extraPropertyDictionary[key].ToString()!, ignoreCase: true); return (T)extraPropertyDictionary[key]; } @@ -24,7 +24,7 @@ public static class ExtraPropertyDictionaryExtensions return extraPropertyDictionary[key]; } - extraPropertyDictionary[key] = Enum.Parse(enumType, extraPropertyDictionary[key].ToString(), ignoreCase: true); + extraPropertyDictionary[key] = Enum.Parse(enumType, extraPropertyDictionary[key].ToString()!, ignoreCase: true); return extraPropertyDictionary[key]; } diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/HasExtraPropertiesExtensions.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/HasExtraPropertiesExtensions.cs index 2e32a1b7dc..7423052772 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/HasExtraPropertiesExtensions.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/HasExtraPropertiesExtensions.cs @@ -18,13 +18,13 @@ public static class HasExtraPropertiesExtensions return source.ExtraProperties.ContainsKey(name); } - public static object GetProperty(this IHasExtraProperties source, string name, object defaultValue = null) + public static object? GetProperty(this IHasExtraProperties source, string name, object? defaultValue = null) { return source.ExtraProperties?.GetOrDefault(name) ?? defaultValue; } - public static TProperty GetProperty(this IHasExtraProperties source, string name, TProperty defaultValue = default) + public static TProperty? GetProperty(this IHasExtraProperties source, string name, TProperty? defaultValue = default) { var value = source.GetProperty(name); if (value == null) @@ -42,7 +42,7 @@ public static class HasExtraPropertiesExtensions if (conversionType == typeof(Guid)) { - return (TProperty)TypeDescriptor.GetConverter(conversionType).ConvertFromInvariantString(value.ToString()); + return (TProperty)TypeDescriptor.GetConverter(conversionType).ConvertFromInvariantString(value.ToString()!)!; } if (conversionType.IsEnum) @@ -80,7 +80,7 @@ public static class HasExtraPropertiesExtensions return source; } - public static TSource SetDefaultsForExtraProperties(this TSource source, Type objectType = null) + public static TSource SetDefaultsForExtraProperties(this TSource source, Type? objectType = null) where TSource : IHasExtraProperties { if (objectType == null) @@ -98,7 +98,7 @@ public static class HasExtraPropertiesExtensions continue; } - source.ExtraProperties[property.Name] = property.GetDefaultValue(); + source.ExtraProperties[property.Name] = property.GetDefaultValue()!; } return source; diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensibleObjectMapper.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensibleObjectMapper.cs index 2de527866b..fbf277c55b 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensibleObjectMapper.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensibleObjectMapper.cs @@ -27,7 +27,7 @@ public static class ExtensibleObjectMapper [NotNull] TSource source, [NotNull] TDestination destination, MappingPropertyDefinitionChecks? definitionChecks = null, - string[] ignoredProperties = null) + string[]? ignoredProperties = null) where TSource : IHasExtraProperties where TDestination : IHasExtraProperties { @@ -78,7 +78,7 @@ public static class ExtensibleObjectMapper [NotNull] Dictionary sourceDictionary, [NotNull] Dictionary destinationDictionary, MappingPropertyDefinitionChecks? definitionChecks = null, - string[] ignoredProperties = null) + string[]? ignoredProperties = null) where TSource : IHasExtraProperties where TDestination : IHasExtraProperties { @@ -113,7 +113,7 @@ public static class ExtensibleObjectMapper [NotNull] Dictionary sourceDictionary, [NotNull] Dictionary destinationDictionary, MappingPropertyDefinitionChecks? definitionChecks = null, - string[] ignoredProperties = null) + string[]? ignoredProperties = null) { Check.AssignableTo(sourceType, nameof(sourceType)); Check.AssignableTo(destinationType, nameof(destinationType)); @@ -140,7 +140,7 @@ public static class ExtensibleObjectMapper public static bool CanMapProperty( [NotNull] string propertyName, MappingPropertyDefinitionChecks? definitionChecks = null, - string[] ignoredProperties = null) + string[]? ignoredProperties = null) { return CanMapProperty( typeof(TSource), @@ -156,7 +156,7 @@ public static class ExtensibleObjectMapper [NotNull] Type destinationType, [NotNull] string propertyName, MappingPropertyDefinitionChecks? definitionChecks = null, - string[] ignoredProperties = null) + string[]? ignoredProperties = null) { Check.AssignableTo(sourceType, nameof(sourceType)); Check.AssignableTo(destinationType, nameof(destinationType)); @@ -175,10 +175,10 @@ public static class ExtensibleObjectMapper private static bool CanMapProperty( [NotNull] string propertyName, - [CanBeNull] ObjectExtensionInfo sourceObjectExtension, - [CanBeNull] ObjectExtensionInfo destinationObjectExtension, + ObjectExtensionInfo? sourceObjectExtension, + ObjectExtensionInfo? destinationObjectExtension, MappingPropertyDefinitionChecks? definitionChecks = null, - string[] ignoredProperties = null) + string[]? ignoredProperties = null) { Check.NotNull(propertyName, nameof(propertyName)); diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensibleObjectValidator.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensibleObjectValidator.cs index 8252051fad..09228fe927 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensibleObjectValidator.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensibleObjectValidator.cs @@ -13,7 +13,7 @@ public static class ExtensibleObjectValidator public static void CheckValue( [NotNull] IHasExtraProperties extensibleObject, [NotNull] string propertyName, - [CanBeNull] object value) + object? value) { var validationErrors = GetValidationErrors( extensibleObject, @@ -29,7 +29,7 @@ public static class ExtensibleObjectValidator public static bool IsValid( [NotNull] IHasExtraProperties extensibleObject, - [CanBeNull] ValidationContext objectValidationContext = null) + ValidationContext? objectValidationContext = null) { return GetValidationErrors( extensibleObject, @@ -40,8 +40,8 @@ public static class ExtensibleObjectValidator public static bool IsValid( [NotNull] IHasExtraProperties extensibleObject, [NotNull] string propertyName, - [CanBeNull] object value, - [CanBeNull] ValidationContext objectValidationContext = null) + object? value, + ValidationContext? objectValidationContext = null) { return GetValidationErrors( extensibleObject, @@ -54,7 +54,7 @@ public static class ExtensibleObjectValidator [NotNull] public static List GetValidationErrors( [NotNull] IHasExtraProperties extensibleObject, - [CanBeNull] ValidationContext objectValidationContext = null) + ValidationContext? objectValidationContext = null) { var validationErrors = new List(); @@ -71,8 +71,8 @@ public static class ExtensibleObjectValidator public static List GetValidationErrors( [NotNull] IHasExtraProperties extensibleObject, [NotNull] string propertyName, - [CanBeNull] object value, - [CanBeNull] ValidationContext objectValidationContext = null) + object? value, + ValidationContext? objectValidationContext = null) { var validationErrors = new List(); @@ -90,7 +90,7 @@ public static class ExtensibleObjectValidator public static void AddValidationErrors( [NotNull] IHasExtraProperties extensibleObject, [NotNull] List validationErrors, - [CanBeNull] ValidationContext objectValidationContext = null) + ValidationContext? objectValidationContext = null) { Check.NotNull(extensibleObject, nameof(extensibleObject)); Check.NotNull(validationErrors, nameof(validationErrors)); @@ -100,7 +100,7 @@ public static class ExtensibleObjectValidator objectValidationContext = new ValidationContext( extensibleObject, null, - new Dictionary() + new Dictionary() ); } @@ -133,8 +133,8 @@ public static class ExtensibleObjectValidator [NotNull] IHasExtraProperties extensibleObject, [NotNull] List validationErrors, [NotNull] string propertyName, - [CanBeNull] object value, - [CanBeNull] ValidationContext objectValidationContext = null) + object? value, + ValidationContext? objectValidationContext = null) { Check.NotNull(extensibleObject, nameof(extensibleObject)); Check.NotNull(validationErrors, nameof(validationErrors)); @@ -145,7 +145,7 @@ public static class ExtensibleObjectValidator objectValidationContext = new ValidationContext( extensibleObject, null, - new Dictionary() + new Dictionary() ); } @@ -203,7 +203,7 @@ public static class ExtensibleObjectValidator List validationErrors, ValidationContext objectValidationContext, ObjectExtensionPropertyInfo property, - object value) + object? value) { AddPropertyValidationAttributeErrors( extensibleObject, @@ -227,7 +227,7 @@ public static class ExtensibleObjectValidator List validationErrors, ValidationContext objectValidationContext, ObjectExtensionPropertyInfo property, - object value) + object? value) { var validationAttributes = property.GetValidationAttributes(); @@ -261,7 +261,7 @@ public static class ExtensibleObjectValidator List validationErrors, ValidationContext objectValidationContext, ObjectExtensionPropertyInfo property, - object value) + object? value) { if (!property.Validators.Any()) { diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensionPropertyHelper.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensionPropertyHelper.cs index d2b6976bf1..89a5e8c87c 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensionPropertyHelper.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensionPropertyHelper.cs @@ -20,10 +20,10 @@ internal static class ExtensionPropertyHelper } } - public static object GetDefaultValue( + public static object? GetDefaultValue( Type propertyType, - Func defaultValueFactory, - object defaultValue) + Func? defaultValueFactory, + object? defaultValue) { if (defaultValueFactory != null) { diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/HasExtraPropertiesObjectExtendingExtensions.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/HasExtraPropertiesObjectExtendingExtensions.cs index 12c6bfb984..d44a900314 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/HasExtraPropertiesObjectExtendingExtensions.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/HasExtraPropertiesObjectExtendingExtensions.cs @@ -24,7 +24,7 @@ public static class HasExtraPropertiesObjectExtendingExtensions [NotNull] this TSource source, [NotNull] TDestination destination, MappingPropertyDefinitionChecks? definitionChecks = null, - string[] ignoredProperties = null) + string[]? ignoredProperties = null) where TSource : IHasExtraProperties where TDestination : IHasExtraProperties { diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/IBasicObjectExtensionPropertyInfo.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/IBasicObjectExtensionPropertyInfo.cs index 8fd6270eda..86f34354a8 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/IBasicObjectExtensionPropertyInfo.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/IBasicObjectExtensionPropertyInfo.cs @@ -20,19 +20,16 @@ public interface IBasicObjectExtensionPropertyInfo [NotNull] public List> Validators { get; } - [CanBeNull] - public ILocalizableString DisplayName { get; } + public ILocalizableString? DisplayName { get; } /// /// Uses as the default value if was not set. /// - [CanBeNull] - public object DefaultValue { get; set; } + public object? DefaultValue { get; set; } /// /// Used with the first priority to create the default value for the property. /// Uses to the if this was not set. /// - [CanBeNull] - public Func DefaultValueFactory { get; set; } + public Func? DefaultValueFactory { get; set; } } diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/EntityExtensionConfiguration.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/EntityExtensionConfiguration.cs index 82c6658c23..2755b4d608 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/EntityExtensionConfiguration.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/EntityExtensionConfiguration.cs @@ -26,7 +26,7 @@ public class EntityExtensionConfiguration [NotNull] public virtual EntityExtensionConfiguration AddOrUpdateProperty( [NotNull] string propertyName, - [CanBeNull] Action configureAction = null) + Action? configureAction = null) { return AddOrUpdateProperty( typeof(TProperty), @@ -39,7 +39,7 @@ public class EntityExtensionConfiguration public virtual EntityExtensionConfiguration AddOrUpdateProperty( [NotNull] Type propertyType, [NotNull] string propertyName, - [CanBeNull] Action configureAction = null) + Action? configureAction = null) { Check.NotNull(propertyType, nameof(propertyType)); Check.NotNull(propertyName, nameof(propertyName)); diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyConfiguration.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyConfiguration.cs index eaad223cfa..8099f1fc14 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyConfiguration.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyConfiguration.cs @@ -23,8 +23,7 @@ public class ExtensionPropertyConfiguration : IHasNameWithLocalizableDisplayName [NotNull] public List> Validators { get; } - [CanBeNull] - public ILocalizableString DisplayName { get; set; } + public ILocalizableString? DisplayName { get; set; } [NotNull] public Dictionary Configuration { get; } @@ -49,15 +48,13 @@ public class ExtensionPropertyConfiguration : IHasNameWithLocalizableDisplayName /// /// Uses as the default value if was not set. /// - [CanBeNull] - public object DefaultValue { get; set; } + public object? DefaultValue { get; set; } /// /// Used with the first priority to create the default value for the property. /// Uses to the if this was not set. /// - [CanBeNull] - public Func DefaultValueFactory { get; set; } + public Func? DefaultValueFactory { get; set; } public ExtensionPropertyConfiguration( [NotNull] EntityExtensionConfiguration entityExtensionConfiguration, @@ -80,7 +77,7 @@ public class ExtensionPropertyConfiguration : IHasNameWithLocalizableDisplayName DefaultValue = TypeHelper.GetDefaultValue(Type); } - public object GetDefaultValue() + public object? GetDefaultValue() { return ExtensionPropertyHelper.GetDefaultValue(Type, DefaultValueFactory, DefaultValue); } diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyConfigurationExtensions.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyConfigurationExtensions.cs index 085e486756..0b826a0ec5 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyConfigurationExtensions.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyConfigurationExtensions.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.ObjectExtending.Modularity; public static class ExtensionPropertyConfigurationExtensions { - public static string GetLocalizationResourceNameOrNull( + public static string? GetLocalizationResourceNameOrNull( this ExtensionPropertyConfiguration property) { if (property.DisplayName is LocalizableString localizableString) @@ -16,7 +16,7 @@ public static class ExtensionPropertyConfigurationExtensions return null; } - public static Type GetLocalizationResourceTypeOrNull( + public static Type? GetLocalizationResourceTypeOrNull( this ExtensionPropertyConfiguration property) { if (property.DisplayName is LocalizableString localizableString) diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyLookupConfiguration.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyLookupConfiguration.cs index 599ed7bed5..bd1cb61b20 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyLookupConfiguration.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyLookupConfiguration.cs @@ -4,7 +4,7 @@ namespace Volo.Abp.ObjectExtending.Modularity; public class ExtensionPropertyLookupConfiguration { - public string Url { get; set; } + public string Url { get; set; } = default!; /// /// Default value: "items". diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ModuleExtensionConfigurationHelper.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ModuleExtensionConfigurationHelper.cs index 642cd07a84..cdde4211e9 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ModuleExtensionConfigurationHelper.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ModuleExtensionConfigurationHelper.cs @@ -29,9 +29,9 @@ public static class ModuleExtensionConfigurationHelper public static void ApplyEntityConfigurationToApi( string moduleName, string objectName, - Type[] getApiTypes = null, - Type[] createApiTypes = null, - Type[] updateApiTypes = null) + Type[]? getApiTypes = null, + Type[]? createApiTypes = null, + Type[]? updateApiTypes = null) { lock (SyncLock) { @@ -66,8 +66,8 @@ public static class ModuleExtensionConfigurationHelper public static void ApplyEntityConfigurationToUi( string moduleName, string entityName, - Type[] createFormTypes = null, - Type[] editFormTypes = null) + Type[]? createFormTypes = null, + Type[]? editFormTypes = null) { lock (SyncLock) { @@ -96,12 +96,12 @@ public static class ModuleExtensionConfigurationHelper public static void ApplyEntityConfigurations( string moduleName, string entityName, - Type entityType = null, - Type[] createFormTypes = null, - Type[] editFormTypes = null, - Type[] getApiTypes = null, - Type[] createApiTypes = null, - Type[] updateApiTypes = null) + Type? entityType = null, + Type[]? createFormTypes = null, + Type[]? editFormTypes = null, + Type[]? getApiTypes = null, + Type[]? createApiTypes = null, + Type[]? updateApiTypes = null) { lock (SyncLock) { diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionManagerExtensions.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionManagerExtensions.cs index f74b36f6ca..92a8f9ecd5 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionManagerExtensions.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionManagerExtensions.cs @@ -12,9 +12,9 @@ public static class ModuleObjectExtensionManagerExtensions { Check.NotNull(objectExtensionManager, nameof(objectExtensionManager)); - return objectExtensionManager.Configuration.GetOrAdd( + return (objectExtensionManager.Configuration.GetOrAdd( ObjectExtensionManagerConfigurationKey, _ => new ModuleExtensionConfigurationDictionary() - ) as ModuleExtensionConfigurationDictionary; + ) as ModuleExtensionConfigurationDictionary)!; } } diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionInfo.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionInfo.cs index 69b7123c50..6656e6127c 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionInfo.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionInfo.cs @@ -38,7 +38,7 @@ public class ObjectExtensionInfo [NotNull] public virtual ObjectExtensionInfo AddOrUpdateProperty( [NotNull] string propertyName, - [CanBeNull] Action configureAction = null) + Action? configureAction = null) { return AddOrUpdateProperty( typeof(TProperty), @@ -51,7 +51,7 @@ public class ObjectExtensionInfo public virtual ObjectExtensionInfo AddOrUpdateProperty( [NotNull] Type propertyType, [NotNull] string propertyName, - [CanBeNull] Action configureAction = null) + Action? configureAction = null) { Check.NotNull(propertyType, nameof(propertyType)); Check.NotNull(propertyName, nameof(propertyName)); @@ -74,8 +74,7 @@ public class ObjectExtensionInfo .ToImmutableList(); } - [CanBeNull] - public virtual ObjectExtensionPropertyInfo GetPropertyOrNull( + public virtual ObjectExtensionPropertyInfo? GetPropertyOrNull( [NotNull] string propertyName) { Check.NotNullOrEmpty(propertyName, nameof(propertyName)); diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionManager.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionManager.cs index ff62d1bd91..1d7ad836b4 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionManager.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionManager.cs @@ -24,7 +24,7 @@ public class ObjectExtensionManager [NotNull] public virtual ObjectExtensionManager AddOrUpdate( - [CanBeNull] Action configureAction = null) + Action? configureAction = null) { return AddOrUpdate(typeof(TObject), configureAction); } @@ -32,7 +32,7 @@ public class ObjectExtensionManager [NotNull] public virtual ObjectExtensionManager AddOrUpdate( [NotNull] Type[] types, - [CanBeNull] Action configureAction = null) + Action? configureAction = null) { Check.NotNull(types, nameof(types)); @@ -47,7 +47,7 @@ public class ObjectExtensionManager [NotNull] public virtual ObjectExtensionManager AddOrUpdate( [NotNull] Type type, - [CanBeNull] Action configureAction = null) + Action? configureAction = null) { var extensionInfo = ObjectsExtensions.GetOrAdd( type, @@ -59,14 +59,12 @@ public class ObjectExtensionManager return this; } - [CanBeNull] - public virtual ObjectExtensionInfo GetOrNull() + public virtual ObjectExtensionInfo? GetOrNull() { return GetOrNull(typeof(TObject)); } - [CanBeNull] - public virtual ObjectExtensionInfo GetOrNull([NotNull] Type type) + public virtual ObjectExtensionInfo? GetOrNull([NotNull] Type type) { return ObjectsExtensions.GetOrDefault(type); } diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionManagerExtensions.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionManagerExtensions.cs index a9c5c8a76f..71c7d78353 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionManagerExtensions.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionManagerExtensions.cs @@ -13,7 +13,7 @@ public static class ObjectExtensionManagerExtensions [NotNull] this ObjectExtensionManager objectExtensionManager, [NotNull] Type[] objectTypes, [NotNull] string propertyName, - [CanBeNull] Action configureAction = null) + Action? configureAction = null) { return objectExtensionManager.AddOrUpdateProperty( objectTypes, @@ -26,7 +26,7 @@ public static class ObjectExtensionManagerExtensions public static ObjectExtensionManager AddOrUpdateProperty( [NotNull] this ObjectExtensionManager objectExtensionManager, [NotNull] string propertyName, - [CanBeNull] Action configureAction = null) + Action? configureAction = null) where TObject : IHasExtraProperties { return objectExtensionManager.AddOrUpdateProperty( @@ -43,7 +43,7 @@ public static class ObjectExtensionManagerExtensions [NotNull] Type[] objectTypes, [NotNull] Type propertyType, [NotNull] string propertyName, - [CanBeNull] Action configureAction = null) + Action? configureAction = null) { Check.NotNull(objectTypes, nameof(objectTypes)); @@ -66,7 +66,7 @@ public static class ObjectExtensionManagerExtensions [NotNull] Type objectType, [NotNull] Type propertyType, [NotNull] string propertyName, - [CanBeNull] Action configureAction = null) + Action? configureAction = null) { Check.NotNull(objectExtensionManager, nameof(objectExtensionManager)); @@ -82,7 +82,7 @@ public static class ObjectExtensionManagerExtensions }); } - public static ObjectExtensionPropertyInfo GetPropertyOrNull( + public static ObjectExtensionPropertyInfo? GetPropertyOrNull( [NotNull] this ObjectExtensionManager objectExtensionManager, [NotNull] string propertyName) { @@ -92,7 +92,7 @@ public static class ObjectExtensionManagerExtensions ); } - public static ObjectExtensionPropertyInfo GetPropertyOrNull( + public static ObjectExtensionPropertyInfo? GetPropertyOrNull( [NotNull] this ObjectExtensionManager objectExtensionManager, [NotNull] Type objectType, [NotNull] string propertyName) diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs index f89035d733..8c3a54414e 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs @@ -24,8 +24,7 @@ public class ObjectExtensionPropertyInfo : IHasNameWithLocalizableDisplayName, I [NotNull] public List> Validators { get; } - [CanBeNull] - public ILocalizableString DisplayName { get; set; } + public ILocalizableString? DisplayName { get; set; } /// /// Indicates whether to check the other side of the object mapping @@ -47,15 +46,13 @@ public class ObjectExtensionPropertyInfo : IHasNameWithLocalizableDisplayName, I /// /// Uses as the default value if was not set. /// - [CanBeNull] - public object DefaultValue { get; set; } + public object? DefaultValue { get; set; } /// /// Used with the first priority to create the default value for the property. /// Uses to the if this was not set. /// - [CanBeNull] - public Func DefaultValueFactory { get; set; } + public Func? DefaultValueFactory { get; set; } [NotNull] public ExtensionPropertyLookupConfiguration Lookup { get; set; } @@ -78,7 +75,7 @@ public class ObjectExtensionPropertyInfo : IHasNameWithLocalizableDisplayName, I Lookup = new ExtensionPropertyLookupConfiguration(); } - public object GetDefaultValue() + public object? GetDefaultValue() { return ExtensionPropertyHelper.GetDefaultValue(Type, DefaultValueFactory, DefaultValue); } diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyValidationContext.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyValidationContext.cs index 7546954dfa..077941d91c 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyValidationContext.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyValidationContext.cs @@ -35,22 +35,20 @@ public class ObjectExtensionPropertyValidationContext /// /// The value of the validating property of the . /// - [CanBeNull] - public object Value { get; } + public object? Value { get; } /// /// Can be used to resolve services from the dependency injection container. /// This can be null when SetProperty method is used on the object. /// - [CanBeNull] - public IServiceProvider ServiceProvider => ValidationContext; + public IServiceProvider? ServiceProvider => ValidationContext; public ObjectExtensionPropertyValidationContext( [NotNull] ObjectExtensionPropertyInfo objectExtensionPropertyInfo, [NotNull] IHasExtraProperties validatingObject, [NotNull] List validationErrors, [NotNull] ValidationContext validationContext, - [CanBeNull] object value) + object? value) { ExtensionPropertyInfo = Check.NotNull(objectExtensionPropertyInfo, nameof(objectExtensionPropertyInfo)); ValidatingObject = Check.NotNull(validatingObject, nameof(validatingObject)); diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionValidationContext.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionValidationContext.cs index 14b5b042f2..df7b8de8a2 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionValidationContext.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionValidationContext.cs @@ -35,8 +35,7 @@ public class ObjectExtensionValidationContext /// /// Can be used to resolve services from the dependency injection container. /// - [CanBeNull] - public IServiceProvider ServiceProvider => ValidationContext; + public IServiceProvider? ServiceProvider => ValidationContext; public ObjectExtensionValidationContext( [NotNull] ObjectExtensionInfo objectExtensionInfo,