From d63f205526d05a1c00fd335523417c7ebe679a9e Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 31 May 2023 18:01:00 +0800 Subject: [PATCH 01/32] Enable nullable annotations for Volo.Abp.Uow --- .../src/Volo.Abp.Uow/Volo.Abp.Uow.csproj | 2 ++ ...aysDisableTransactionsUnitOfWorkManager.cs | 2 +- .../Volo/Abp/Uow/AmbientUnitOfWork.cs | 10 +++--- .../Volo/Abp/Uow/ChildUnitOfWork.cs | 24 ++++++------- .../Volo/Abp/Uow/IAmbientUnitOfWork.cs | 2 +- .../Volo/Abp/Uow/IDatabaseApiContainer.cs | 3 +- .../Volo/Abp/Uow/ITransactionApiContainer.cs | 3 +- .../Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWork.cs | 12 +++---- .../Volo/Abp/Uow/IUnitOfWorkAccessor.cs | 5 ++- .../Volo/Abp/Uow/IUnitOfWorkManager.cs | 3 +- .../Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs | 36 +++++++++---------- .../Volo/Abp/Uow/UnitOfWorkFailedEventArgs.cs | 5 ++- .../Volo/Abp/Uow/UnitOfWorkHelper.cs | 15 ++++---- .../Volo/Abp/Uow/UnitOfWorkInterceptor.cs | 2 +- .../Volo/Abp/Uow/UnitOfWorkManager.cs | 2 +- 15 files changed, 63 insertions(+), 63 deletions(-) diff --git a/framework/src/Volo.Abp.Uow/Volo.Abp.Uow.csproj b/framework/src/Volo.Abp.Uow/Volo.Abp.Uow.csproj index f33af433e7..f1c8b13cad 100644 --- a/framework/src/Volo.Abp.Uow/Volo.Abp.Uow.csproj +++ b/framework/src/Volo.Abp.Uow/Volo.Abp.Uow.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Uow Volo.Abp.Uow $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AlwaysDisableTransactionsUnitOfWorkManager.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AlwaysDisableTransactionsUnitOfWorkManager.cs index a02f63c3e1..462c001e6d 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AlwaysDisableTransactionsUnitOfWorkManager.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AlwaysDisableTransactionsUnitOfWorkManager.cs @@ -12,7 +12,7 @@ public class AlwaysDisableTransactionsUnitOfWorkManager : IUnitOfWorkManager _unitOfWorkManager = unitOfWorkManager; } - public IUnitOfWork Current => _unitOfWorkManager.Current; + public IUnitOfWork? Current => _unitOfWorkManager.Current; public IUnitOfWork Begin(AbpUnitOfWorkOptions options, bool requiresNew = false) { diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AmbientUnitOfWork.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AmbientUnitOfWork.cs index 183126cb50..dc70dfad46 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AmbientUnitOfWork.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AmbientUnitOfWork.cs @@ -6,21 +6,21 @@ namespace Volo.Abp.Uow; [ExposeServices(typeof(IAmbientUnitOfWork), typeof(IUnitOfWorkAccessor))] public class AmbientUnitOfWork : IAmbientUnitOfWork, ISingletonDependency { - public IUnitOfWork UnitOfWork => _currentUow.Value; + public IUnitOfWork? UnitOfWork => _currentUow.Value; - private readonly AsyncLocal _currentUow; + private readonly AsyncLocal _currentUow; public AmbientUnitOfWork() { - _currentUow = new AsyncLocal(); + _currentUow = new AsyncLocal(); } - public void SetUnitOfWork(IUnitOfWork unitOfWork) + public void SetUnitOfWork(IUnitOfWork? unitOfWork) { _currentUow.Value = unitOfWork; } - public IUnitOfWork GetCurrentByChecking() + public IUnitOfWork? GetCurrentByChecking() { var uow = UnitOfWork; diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ChildUnitOfWork.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ChildUnitOfWork.cs index bf8a44f724..eb51d8c189 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ChildUnitOfWork.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ChildUnitOfWork.cs @@ -10,9 +10,9 @@ internal class ChildUnitOfWork : IUnitOfWork { public Guid Id => _parent.Id; - public IAbpUnitOfWorkOptions Options => _parent.Options; + public IAbpUnitOfWorkOptions? Options => _parent.Options; - public IUnitOfWork Outer => _parent.Outer; + public IUnitOfWork? Outer => _parent.Outer; public bool IsReserved => _parent.IsReserved; @@ -20,10 +20,10 @@ internal class ChildUnitOfWork : IUnitOfWork public bool IsCompleted => _parent.IsCompleted; - public string ReservationName => _parent.ReservationName; + public string? ReservationName => _parent.ReservationName; - public event EventHandler Failed; - public event EventHandler Disposed; + public event EventHandler Failed = default!; + public event EventHandler Disposed = default!; public IServiceProvider ServiceProvider => _parent.ServiceProvider; @@ -37,11 +37,11 @@ internal class ChildUnitOfWork : IUnitOfWork _parent = parent; - _parent.Failed += (sender, args) => { Failed.InvokeSafely(sender, args); }; - _parent.Disposed += (sender, args) => { Disposed.InvokeSafely(sender, args); }; + _parent.Failed += (sender, args) => { Failed.InvokeSafely(sender!, args); }; + _parent.Disposed += (sender, args) => { Disposed.InvokeSafely(sender!, args); }; } - public void SetOuter(IUnitOfWork outer) + public void SetOuter(IUnitOfWork? outer) { _parent.SetOuter(outer); } @@ -78,19 +78,19 @@ internal class ChildUnitOfWork : IUnitOfWork public void AddOrReplaceLocalEvent( UnitOfWorkEventRecord eventRecord, - Predicate replacementSelector = null) + Predicate? replacementSelector = null) { _parent.AddOrReplaceLocalEvent(eventRecord, replacementSelector); } public void AddOrReplaceDistributedEvent( UnitOfWorkEventRecord eventRecord, - Predicate replacementSelector = null) + Predicate? replacementSelector = null) { _parent.AddOrReplaceDistributedEvent(eventRecord, replacementSelector); } - public IDatabaseApi FindDatabaseApi(string key) + public IDatabaseApi? FindDatabaseApi(string key) { return _parent.FindDatabaseApi(key); } @@ -105,7 +105,7 @@ internal class ChildUnitOfWork : IUnitOfWork return _parent.GetOrAddDatabaseApi(key, factory); } - public ITransactionApi FindTransactionApi(string key) + public ITransactionApi? FindTransactionApi(string key) { return _parent.FindTransactionApi(key); } diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IAmbientUnitOfWork.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IAmbientUnitOfWork.cs index e29ed5aa6a..5781da4140 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IAmbientUnitOfWork.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IAmbientUnitOfWork.cs @@ -2,5 +2,5 @@ public interface IAmbientUnitOfWork : IUnitOfWorkAccessor { - IUnitOfWork GetCurrentByChecking(); + IUnitOfWork? GetCurrentByChecking(); } diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IDatabaseApiContainer.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IDatabaseApiContainer.cs index 429bd48998..23d3b0f20b 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IDatabaseApiContainer.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IDatabaseApiContainer.cs @@ -6,8 +6,7 @@ namespace Volo.Abp.Uow; public interface IDatabaseApiContainer : IServiceProviderAccessor { - [CanBeNull] - IDatabaseApi FindDatabaseApi([NotNull] string key); + IDatabaseApi? FindDatabaseApi([NotNull] string key); void AddDatabaseApi([NotNull] string key, [NotNull] IDatabaseApi api); diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ITransactionApiContainer.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ITransactionApiContainer.cs index f5bdf13ccb..9acce6ce69 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ITransactionApiContainer.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ITransactionApiContainer.cs @@ -5,8 +5,7 @@ namespace Volo.Abp.Uow; public interface ITransactionApiContainer { - [CanBeNull] - ITransactionApi FindTransactionApi([NotNull] string key); + ITransactionApi? FindTransactionApi([NotNull] string key); void AddTransactionApi([NotNull] string key, [NotNull] ITransactionApi api); diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWork.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWork.cs index 200ce937d9..15dc2bdec0 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWork.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWork.cs @@ -17,9 +17,9 @@ public interface IUnitOfWork : IDatabaseApiContainer, ITransactionApiContainer, event EventHandler Disposed; - IAbpUnitOfWorkOptions Options { get; } + IAbpUnitOfWorkOptions? Options { get; } - IUnitOfWork Outer { get; } + IUnitOfWork? Outer { get; } bool IsReserved { get; } @@ -27,9 +27,9 @@ public interface IUnitOfWork : IDatabaseApiContainer, ITransactionApiContainer, bool IsCompleted { get; } - string ReservationName { get; } + string? ReservationName { get; } - void SetOuter([CanBeNull] IUnitOfWork outer); + void SetOuter(IUnitOfWork? outer); void Initialize([NotNull] AbpUnitOfWorkOptions options); @@ -45,11 +45,11 @@ public interface IUnitOfWork : IDatabaseApiContainer, ITransactionApiContainer, void AddOrReplaceLocalEvent( UnitOfWorkEventRecord eventRecord, - Predicate replacementSelector = null + Predicate? replacementSelector = null ); void AddOrReplaceDistributedEvent( UnitOfWorkEventRecord eventRecord, - Predicate replacementSelector = null + Predicate? replacementSelector = null ); } diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWorkAccessor.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWorkAccessor.cs index 59fd00ce96..e2333b5bbc 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWorkAccessor.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWorkAccessor.cs @@ -4,8 +4,7 @@ namespace Volo.Abp.Uow; public interface IUnitOfWorkAccessor { - [CanBeNull] - IUnitOfWork UnitOfWork { get; } + IUnitOfWork? UnitOfWork { get; } - void SetUnitOfWork([CanBeNull] IUnitOfWork unitOfWork); + void SetUnitOfWork(IUnitOfWork? unitOfWork); } diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWorkManager.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWorkManager.cs index 34796fe15b..4263dc5778 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWorkManager.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IUnitOfWorkManager.cs @@ -4,8 +4,7 @@ namespace Volo.Abp.Uow; public interface IUnitOfWorkManager { - [CanBeNull] - IUnitOfWork Current { get; } + IUnitOfWork? Current { get; } [NotNull] IUnitOfWork Begin([NotNull] AbpUnitOfWorkOptions options, bool requiresNew = false); diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs index 626c74478b..b9b39f2f28 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs @@ -21,9 +21,9 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency public Guid Id { get; } = Guid.NewGuid(); - public IAbpUnitOfWorkOptions Options { get; private set; } + public IAbpUnitOfWorkOptions? Options { get; private set; } - public IUnitOfWork Outer { get; private set; } + public IUnitOfWork? Outer { get; private set; } public bool IsReserved { get; set; } @@ -31,14 +31,14 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency public bool IsCompleted { get; private set; } - public string ReservationName { get; set; } + public string? ReservationName { get; set; } protected List> CompletedHandlers { get; } = new List>(); protected List DistributedEvents { get; } = new List(); protected List LocalEvents { get; } = new List(); - public event EventHandler Failed; - public event EventHandler Disposed; + public event EventHandler Failed = default!; + public event EventHandler Disposed = default!; public IServiceProvider ServiceProvider { get; } protected IUnitOfWorkEventPublisher UnitOfWorkEventPublisher { get; } @@ -50,7 +50,7 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency private readonly Dictionary _transactionApis; private readonly AbpUnitOfWorkDefaultOptions _defaultOptions; - private Exception _exception; + private Exception? _exception; private bool _isCompleting; private bool _isRolledback; @@ -90,7 +90,7 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency IsReserved = true; } - public virtual void SetOuter(IUnitOfWork outer) + public virtual void SetOuter(IUnitOfWork? outer) { Outer = outer; } @@ -104,9 +104,9 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency foreach (var databaseApi in GetAllActiveDatabaseApis()) { - if (databaseApi is ISupportsSavingChanges) + if (databaseApi is ISupportsSavingChanges supportsSavingChangesDatabaseApi) { - await (databaseApi as ISupportsSavingChanges).SaveChangesAsync(cancellationToken); + await supportsSavingChangesDatabaseApi.SaveChangesAsync(cancellationToken); } } } @@ -181,7 +181,7 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency await RollbackAllAsync(cancellationToken); } - public virtual IDatabaseApi FindDatabaseApi(string key) + public virtual IDatabaseApi? FindDatabaseApi(string key) { return _databaseApis.GetOrDefault(key); } @@ -207,7 +207,7 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency return _databaseApis.GetOrAdd(key, factory); } - public virtual ITransactionApi FindTransactionApi(string key) + public virtual ITransactionApi? FindTransactionApi(string key) { Check.NotNull(key, nameof(key)); @@ -242,14 +242,14 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency public virtual void AddOrReplaceLocalEvent( UnitOfWorkEventRecord eventRecord, - Predicate replacementSelector = null) + Predicate? replacementSelector = null) { AddOrReplaceEvent(LocalEvents, eventRecord, replacementSelector); } public virtual void AddOrReplaceDistributedEvent( UnitOfWorkEventRecord eventRecord, - Predicate replacementSelector = null) + Predicate? replacementSelector = null) { AddOrReplaceEvent(DistributedEvents, eventRecord, replacementSelector); } @@ -257,7 +257,7 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency public virtual void AddOrReplaceEvent( List eventRecords, UnitOfWorkEventRecord eventRecord, - Predicate replacementSelector = null) + Predicate? replacementSelector = null) { if (replacementSelector == null) { @@ -340,11 +340,11 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency { foreach (var databaseApi in GetAllActiveDatabaseApis()) { - if (databaseApi is ISupportsRollback) + if (databaseApi is ISupportsRollback supportsRollbackDatabaseApi) { try { - await (databaseApi as ISupportsRollback).RollbackAsync(cancellationToken); + await supportsRollbackDatabaseApi.RollbackAsync(cancellationToken); } catch { } } @@ -352,11 +352,11 @@ public class UnitOfWork : IUnitOfWork, ITransientDependency foreach (var transactionApi in GetAllActiveTransactionApis()) { - if (transactionApi is ISupportsRollback) + if (transactionApi is ISupportsRollback supportsRollbackTransactionApi) { try { - await (transactionApi as ISupportsRollback).RollbackAsync(cancellationToken); + await supportsRollbackTransactionApi.RollbackAsync(cancellationToken); } catch { } } diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkFailedEventArgs.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkFailedEventArgs.cs index e8c1d293d7..5867beab13 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkFailedEventArgs.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkFailedEventArgs.cs @@ -13,8 +13,7 @@ public class UnitOfWorkFailedEventArgs : UnitOfWorkEventArgs /// Can be null if there is no exception, but is not called. /// Can be null if another exception occurred during the UOW. /// - [CanBeNull] - public Exception Exception { get; } + public Exception? Exception { get; } /// /// True, if the unit of work is manually rolled back. @@ -24,7 +23,7 @@ public class UnitOfWorkFailedEventArgs : UnitOfWorkEventArgs /// /// Creates a new object. /// - public UnitOfWorkFailedEventArgs([NotNull] IUnitOfWork unitOfWork, [CanBeNull] Exception exception, bool isRolledback) + public UnitOfWorkFailedEventArgs([NotNull] IUnitOfWork unitOfWork, Exception? exception, bool isRolledback) : base(unitOfWork) { Exception = exception; diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkHelper.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkHelper.cs index 94929a6d1c..3e836a9ed0 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkHelper.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkHelper.cs @@ -23,7 +23,7 @@ public static class UnitOfWorkHelper return false; } - public static bool IsUnitOfWorkMethod([NotNull] MethodInfo methodInfo, [CanBeNull] out UnitOfWorkAttribute unitOfWorkAttribute) + public static bool IsUnitOfWorkMethod([NotNull] MethodInfo methodInfo, out UnitOfWorkAttribute? unitOfWorkAttribute) { Check.NotNull(methodInfo, nameof(methodInfo)); @@ -57,7 +57,7 @@ public static class UnitOfWorkHelper return false; } - public static UnitOfWorkAttribute GetUnitOfWorkAttributeOrNull(MethodInfo methodInfo) + public static UnitOfWorkAttribute? GetUnitOfWorkAttributeOrNull(MethodInfo methodInfo) { var attrs = methodInfo.GetCustomAttributes(true).OfType().ToArray(); if (attrs.Length > 0) @@ -65,12 +65,15 @@ public static class UnitOfWorkHelper return attrs[0]; } - attrs = methodInfo.DeclaringType.GetTypeInfo().GetCustomAttributes(true).OfType().ToArray(); - if (attrs.Length > 0) + if (methodInfo.DeclaringType != null) { - return attrs[0]; + attrs = methodInfo.DeclaringType.GetTypeInfo().GetCustomAttributes(true).OfType().ToArray(); + if (attrs.Length > 0) + { + return attrs[0]; + } } - + return null; } diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkInterceptor.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkInterceptor.cs index 130f1d3e7b..d49d131299 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkInterceptor.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkInterceptor.cs @@ -52,7 +52,7 @@ public class UnitOfWorkInterceptor : AbpInterceptor, ITransientDependency } } - private AbpUnitOfWorkOptions CreateOptions(IServiceProvider serviceProvider, IAbpMethodInvocation invocation, [CanBeNull] UnitOfWorkAttribute unitOfWorkAttribute) + private AbpUnitOfWorkOptions CreateOptions(IServiceProvider serviceProvider, IAbpMethodInvocation invocation, UnitOfWorkAttribute? unitOfWorkAttribute) { var options = new AbpUnitOfWorkOptions(); diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManager.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManager.cs index 4752f5bdba..970f7030ca 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManager.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManager.cs @@ -10,7 +10,7 @@ public class UnitOfWorkManager : IUnitOfWorkManager, ISingletonDependency [Obsolete("This will be removed in next versions.")] public static AsyncLocal DisableObsoleteDbContextCreationWarning { get; } = new AsyncLocal(); - public IUnitOfWork Current => _ambientUnitOfWork.GetCurrentByChecking(); + public IUnitOfWork? Current => _ambientUnitOfWork.GetCurrentByChecking(); private readonly IServiceScopeFactory _serviceScopeFactory; private readonly IAmbientUnitOfWork _ambientUnitOfWork; From a551464e4ce41c45ef58ed5f9fd2e052f0ce90b0 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 6 Jun 2023 14:09:16 +0800 Subject: [PATCH 02/32] Enable nullable annotations for Volo.Abp.Localization.Abstractions --- .../AbpStringLocalizerFactoryExtensions.cs | 9 +++------ .../Localization/IAbpStringLocalizerFactory.cs | 9 +++------ .../Volo.Abp.Localization.Abstractions.csproj | 2 ++ ...asNameWithLocalizableDisplayNameExtensions.cs | 2 +- .../IHasNameWithLocalizableDisplayName.cs | 3 +-- .../Volo/Abp/Localization/LocalizableString.cs | 16 +++++++--------- .../LocalizationResourceNameAttribute.cs | 4 ++-- 7 files changed, 19 insertions(+), 26 deletions(-) diff --git a/framework/src/Volo.Abp.Localization.Abstractions/Microsoft/Extensions/Localization/AbpStringLocalizerFactoryExtensions.cs b/framework/src/Volo.Abp.Localization.Abstractions/Microsoft/Extensions/Localization/AbpStringLocalizerFactoryExtensions.cs index 8aa2515a54..492372cc30 100644 --- a/framework/src/Volo.Abp.Localization.Abstractions/Microsoft/Extensions/Localization/AbpStringLocalizerFactoryExtensions.cs +++ b/framework/src/Volo.Abp.Localization.Abstractions/Microsoft/Extensions/Localization/AbpStringLocalizerFactoryExtensions.cs @@ -6,15 +6,13 @@ namespace Microsoft.Extensions.Localization; public static class AbpStringLocalizerFactoryExtensions { - [CanBeNull] - public static IStringLocalizer CreateDefaultOrNull(this IStringLocalizerFactory localizerFactory) + public static IStringLocalizer? CreateDefaultOrNull(this IStringLocalizerFactory localizerFactory) { return (localizerFactory as IAbpStringLocalizerFactory) ?.CreateDefaultOrNull(); } - [CanBeNull] - public static IStringLocalizer CreateByResourceNameOrNull( + public static IStringLocalizer? CreateByResourceNameOrNull( this IStringLocalizerFactory localizerFactory, string resourceName) { @@ -36,8 +34,7 @@ public static class AbpStringLocalizerFactoryExtensions return localizer; } - [ItemCanBeNull] - public static async Task CreateByResourceNameOrNullAsync( + public static async Task CreateByResourceNameOrNullAsync( this IStringLocalizerFactory localizerFactory, string resourceName) { diff --git a/framework/src/Volo.Abp.Localization.Abstractions/Microsoft/Extensions/Localization/IAbpStringLocalizerFactory.cs b/framework/src/Volo.Abp.Localization.Abstractions/Microsoft/Extensions/Localization/IAbpStringLocalizerFactory.cs index 8f6699a13d..030617583a 100644 --- a/framework/src/Volo.Abp.Localization.Abstractions/Microsoft/Extensions/Localization/IAbpStringLocalizerFactory.cs +++ b/framework/src/Volo.Abp.Localization.Abstractions/Microsoft/Extensions/Localization/IAbpStringLocalizerFactory.cs @@ -5,12 +5,9 @@ namespace Microsoft.Extensions.Localization; public interface IAbpStringLocalizerFactory { - [CanBeNull] - IStringLocalizer CreateDefaultOrNull(); + IStringLocalizer? CreateDefaultOrNull(); - [CanBeNull] - IStringLocalizer CreateByResourceNameOrNull([NotNull] string resourceName); + IStringLocalizer? CreateByResourceNameOrNull([NotNull] string resourceName); - [ItemCanBeNull] - Task CreateByResourceNameOrNullAsync([NotNull] string resourceName); + Task CreateByResourceNameOrNullAsync([NotNull] string resourceName); } diff --git a/framework/src/Volo.Abp.Localization.Abstractions/Volo.Abp.Localization.Abstractions.csproj b/framework/src/Volo.Abp.Localization.Abstractions/Volo.Abp.Localization.Abstractions.csproj index 952d59b739..1fb66c9b7c 100644 --- a/framework/src/Volo.Abp.Localization.Abstractions/Volo.Abp.Localization.Abstractions.csproj +++ b/framework/src/Volo.Abp.Localization.Abstractions/Volo.Abp.Localization.Abstractions.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Localization.Abstractions Volo.Abp.Localization.Abstractions $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/HasNameWithLocalizableDisplayNameExtensions.cs b/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/HasNameWithLocalizableDisplayNameExtensions.cs index a73e4a6509..348d5b696b 100644 --- a/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/HasNameWithLocalizableDisplayNameExtensions.cs +++ b/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/HasNameWithLocalizableDisplayNameExtensions.cs @@ -10,7 +10,7 @@ public static class HasNameWithLocalizableDisplayNameExtensions public static string GetLocalizedDisplayName( [NotNull] this IHasNameWithLocalizableDisplayName source, [NotNull] IStringLocalizerFactory stringLocalizerFactory, - [CanBeNull] string localizationNamePrefix = "DisplayName:") + string? localizationNamePrefix = "DisplayName:") { if (source.DisplayName != null) { diff --git a/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/IHasNameWithLocalizableDisplayName.cs b/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/IHasNameWithLocalizableDisplayName.cs index f582a31379..de29047ddf 100644 --- a/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/IHasNameWithLocalizableDisplayName.cs +++ b/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/IHasNameWithLocalizableDisplayName.cs @@ -7,6 +7,5 @@ public interface IHasNameWithLocalizableDisplayName [NotNull] public string Name { get; } - [CanBeNull] - public ILocalizableString DisplayName { get; } + public ILocalizableString? DisplayName { get; } } diff --git a/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/LocalizableString.cs b/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/LocalizableString.cs index a98f207a55..038d170f2a 100644 --- a/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/LocalizableString.cs +++ b/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/LocalizableString.cs @@ -7,16 +7,14 @@ namespace Volo.Abp.Localization; public class LocalizableString : ILocalizableString, IAsyncLocalizableString { - [CanBeNull] - public string ResourceName { get; } + public string? ResourceName { get; } - [CanBeNull] - public Type ResourceType { get; } + public Type? ResourceType { get; } [NotNull] public string Name { get; } - public LocalizableString([CanBeNull] Type resourceType, [NotNull] string name) + public LocalizableString(Type? resourceType, [NotNull] string name) { Name = Check.NotNullOrEmpty(name, nameof(name)); ResourceType = resourceType; @@ -27,7 +25,7 @@ public class LocalizableString : ILocalizableString, IAsyncLocalizableString } } - public LocalizableString([NotNull] string name, [CanBeNull] string resourceName = null) + public LocalizableString([NotNull] string name, string? resourceName = null) { Name = Check.NotNullOrEmpty(name, nameof(name)); ResourceName = resourceName; @@ -79,7 +77,7 @@ public class LocalizableString : ILocalizableString, IAsyncLocalizableString return result; } - private IStringLocalizer CreateStringLocalizerOrNull(IStringLocalizerFactory stringLocalizerFactory) + private IStringLocalizer? CreateStringLocalizerOrNull(IStringLocalizerFactory stringLocalizerFactory) { if (ResourceType != null) { @@ -98,7 +96,7 @@ public class LocalizableString : ILocalizableString, IAsyncLocalizableString return stringLocalizerFactory.CreateDefaultOrNull(); } - private async Task CreateStringLocalizerOrNullAsync(IStringLocalizerFactory stringLocalizerFactory) + private async Task CreateStringLocalizerOrNullAsync(IStringLocalizerFactory stringLocalizerFactory) { if (ResourceType != null) { @@ -127,7 +125,7 @@ public class LocalizableString : ILocalizableString, IAsyncLocalizableString return new LocalizableString(resourceType, name); } - public static LocalizableString Create([NotNull] string name, [CanBeNull] string resourceName = null) + public static LocalizableString Create([NotNull] string name, string? resourceName = null) { return new LocalizableString(name, resourceName); } diff --git a/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/LocalizationResourceNameAttribute.cs b/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/LocalizationResourceNameAttribute.cs index 303214393b..fb3b5f0f7f 100644 --- a/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/LocalizationResourceNameAttribute.cs +++ b/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/LocalizationResourceNameAttribute.cs @@ -12,7 +12,7 @@ public class LocalizationResourceNameAttribute : Attribute Name = name; } - public static LocalizationResourceNameAttribute GetOrNull(Type resourceType) + public static LocalizationResourceNameAttribute? GetOrNull(Type resourceType) { return resourceType .GetCustomAttributes(true) @@ -20,7 +20,7 @@ public class LocalizationResourceNameAttribute : Attribute .FirstOrDefault(); } - public static string GetName(Type resourceType) + public static string? GetName(Type resourceType) { return GetOrNull(resourceType)?.Name ?? resourceType.FullName; } From d27ed42492b3aa62459c64314aee3304f0f1b84f Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 6 Jun 2023 14:11:28 +0800 Subject: [PATCH 03/32] Enable nullable annotations for Volo.Abp.Validation.Abstractions --- .../Volo.Abp.Validation.Abstractions.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.Validation.Abstractions/Volo.Abp.Validation.Abstractions.csproj b/framework/src/Volo.Abp.Validation.Abstractions/Volo.Abp.Validation.Abstractions.csproj index ff9731ff00..ea7347dd66 100644 --- a/framework/src/Volo.Abp.Validation.Abstractions/Volo.Abp.Validation.Abstractions.csproj +++ b/framework/src/Volo.Abp.Validation.Abstractions/Volo.Abp.Validation.Abstractions.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Validation.Abstractions Volo.Abp.Validation.Abstractions $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; From a410b254a5b0f27d53a6f5ab47715c497596b0df Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 6 Jun 2023 15:08:24 +0800 Subject: [PATCH 04/32] Enable nullable annotations for Volo.Abp.Security --- .../src/Volo.Abp.Core/Volo/Abp/AbpException.cs | 4 ++-- .../LocalizationResourceNameAttribute.cs | 4 ++-- .../Principal/AbpClaimsIdentityExtensions.cs | 4 ++-- .../Volo.Abp.Security/Volo.Abp.Security.csproj | 2 ++ .../Authorization/AbpAuthorizationException.cs | 4 ++-- .../Volo/Abp/Clients/CurrentClient.cs | 2 +- .../Volo/Abp/Clients/ICurrentClient.cs | 2 +- .../Volo/Abp/Security/AbpSecurityModule.cs | 8 ++++---- .../Claims/AbpClaimsPrincipalFactory.cs | 2 +- .../Claims/IAbpClaimsPrincipalFactory.cs | 2 +- .../Claims/ThreadCurrentPrincipalAccessor.cs | 2 +- .../Encryption/IStringEncryptionService.cs | 6 ++---- .../Encryption/StringEncryptionService.cs | 4 ++-- .../Abp/SecurityLog/AbpSecurityLogOptions.cs | 2 +- .../SecurityLog/DefaultSecurityLogManager.cs | 2 +- .../Abp/SecurityLog/ISecurityLogManager.cs | 2 +- .../Volo/Abp/SecurityLog/SecurityLogInfo.cs | 18 +++++++++--------- .../Volo/Abp/Users/CurrentUser.cs | 12 ++++++------ .../Volo/Abp/Users/CurrentUserExtensions.cs | 9 ++++----- .../Volo/Abp/Users/ICurrentUser.cs | 18 ++++++------------ 20 files changed, 51 insertions(+), 58 deletions(-) diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/AbpException.cs b/framework/src/Volo.Abp.Core/Volo/Abp/AbpException.cs index cf779ff7e0..906d3a7fcb 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/AbpException.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/AbpException.cs @@ -13,13 +13,13 @@ public class AbpException : Exception } - public AbpException(string message) + public AbpException(string? message) : base(message) { } - public AbpException(string message, Exception innerException) + public AbpException(string? message, Exception? innerException) : base(message, innerException) { diff --git a/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/LocalizationResourceNameAttribute.cs b/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/LocalizationResourceNameAttribute.cs index fb3b5f0f7f..6657ba5d2e 100644 --- a/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/LocalizationResourceNameAttribute.cs +++ b/framework/src/Volo.Abp.Localization.Abstractions/Volo/Abp/Localization/LocalizationResourceNameAttribute.cs @@ -20,8 +20,8 @@ public class LocalizationResourceNameAttribute : Attribute .FirstOrDefault(); } - public static string? GetName(Type resourceType) + public static string GetName(Type resourceType) { - return GetOrNull(resourceType)?.Name ?? resourceType.FullName; + return (GetOrNull(resourceType)?.Name ?? resourceType.FullName)!; } } diff --git a/framework/src/Volo.Abp.Security/System/Security/Principal/AbpClaimsIdentityExtensions.cs b/framework/src/Volo.Abp.Security/System/Security/Principal/AbpClaimsIdentityExtensions.cs index b48c372728..6c12decd19 100644 --- a/framework/src/Volo.Abp.Security/System/Security/Principal/AbpClaimsIdentityExtensions.cs +++ b/framework/src/Volo.Abp.Security/System/Security/Principal/AbpClaimsIdentityExtensions.cs @@ -84,7 +84,7 @@ public static class AbpClaimsIdentityExtensions return null; } - public static string FindClientId([NotNull] this ClaimsPrincipal principal) + public static string? FindClientId([NotNull] this ClaimsPrincipal principal) { Check.NotNull(principal, nameof(principal)); @@ -97,7 +97,7 @@ public static class AbpClaimsIdentityExtensions return clientIdOrNull.Value; } - public static string FindClientId([NotNull] this IIdentity identity) + public static string? FindClientId([NotNull] this IIdentity identity) { Check.NotNull(identity, nameof(identity)); diff --git a/framework/src/Volo.Abp.Security/Volo.Abp.Security.csproj b/framework/src/Volo.Abp.Security/Volo.Abp.Security.csproj index ab99014a5d..b12428be84 100644 --- a/framework/src/Volo.Abp.Security/Volo.Abp.Security.csproj +++ b/framework/src/Volo.Abp.Security/Volo.Abp.Security.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Security Volo.Abp.Security $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/Authorization/AbpAuthorizationException.cs b/framework/src/Volo.Abp.Security/Volo/Abp/Authorization/AbpAuthorizationException.cs index 68cdf5431d..5cae98964c 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/Authorization/AbpAuthorizationException.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/Authorization/AbpAuthorizationException.cs @@ -21,7 +21,7 @@ public class AbpAuthorizationException : AbpException, IHasLogLevel, IHasErrorCo /// /// Error code. /// - public string Code { get; } + public string? Code { get; } /// /// Creates a new object. @@ -67,7 +67,7 @@ public class AbpAuthorizationException : AbpException, IHasLogLevel, IHasErrorCo /// Exception message /// Exception code /// Inner exception - public AbpAuthorizationException(string message = null, string code = null, Exception innerException = null) + public AbpAuthorizationException(string? message = null, string? code = null, Exception? innerException = null) : base(message, innerException) { Code = code; diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/Clients/CurrentClient.cs b/framework/src/Volo.Abp.Security/Volo/Abp/Clients/CurrentClient.cs index b82098d737..4ce2382c25 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/Clients/CurrentClient.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/Clients/CurrentClient.cs @@ -6,7 +6,7 @@ namespace Volo.Abp.Clients; public class CurrentClient : ICurrentClient, ITransientDependency { - public virtual string Id => _principalAccessor.Principal?.FindClientId(); + public virtual string? Id => _principalAccessor.Principal?.FindClientId(); public virtual bool IsAuthenticated => Id != null; diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/Clients/ICurrentClient.cs b/framework/src/Volo.Abp.Security/Volo/Abp/Clients/ICurrentClient.cs index 6ecd3f216d..9db5834f4f 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/Clients/ICurrentClient.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/Clients/ICurrentClient.cs @@ -2,7 +2,7 @@ public interface ICurrentClient { - string Id { get; } + string? Id { get; } bool IsAuthenticated { get; } } diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/Security/AbpSecurityModule.cs b/framework/src/Volo.Abp.Security/Volo/Abp/Security/AbpSecurityModule.cs index 921aca8d7e..69107c6d1d 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/Security/AbpSecurityModule.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/Security/AbpSecurityModule.cs @@ -23,7 +23,7 @@ public class AbpSecurityModule : AbpModule { Configure(options => { - options.ApplicationName = applicationName; + options.ApplicationName = applicationName!; }); } @@ -42,19 +42,19 @@ public class AbpSecurityModule : AbpModule var defaultPassPhrase = configuration["StringEncryption:DefaultPassPhrase"]; if (!defaultPassPhrase.IsNullOrWhiteSpace()) { - options.DefaultPassPhrase = defaultPassPhrase; + options.DefaultPassPhrase = defaultPassPhrase!; } var initVectorBytes = configuration["StringEncryption:InitVectorBytes"]; if (!initVectorBytes.IsNullOrWhiteSpace()) { - options.InitVectorBytes = Encoding.ASCII.GetBytes(initVectorBytes); ; + options.InitVectorBytes = Encoding.ASCII.GetBytes(initVectorBytes!); } var defaultSalt = configuration["StringEncryption:DefaultSalt"]; if (!defaultSalt.IsNullOrWhiteSpace()) { - options.DefaultSalt = Encoding.ASCII.GetBytes(defaultSalt); ; + options.DefaultSalt = Encoding.ASCII.GetBytes(defaultSalt!); } }); } diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/AbpClaimsPrincipalFactory.cs b/framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/AbpClaimsPrincipalFactory.cs index 1e9221cd88..ae9d947fb0 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/AbpClaimsPrincipalFactory.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/AbpClaimsPrincipalFactory.cs @@ -21,7 +21,7 @@ public class AbpClaimsPrincipalFactory : IAbpClaimsPrincipalFactory, ITransientD Options = abpClaimOptions.Value; } - public virtual async Task CreateAsync(ClaimsPrincipal existsClaimsPrincipal = null) + public virtual async Task CreateAsync(ClaimsPrincipal? existsClaimsPrincipal = null) { using (var scope = ServiceScopeFactory.CreateScope()) { diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/IAbpClaimsPrincipalFactory.cs b/framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/IAbpClaimsPrincipalFactory.cs index fcfcf4d348..b4f3046c9d 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/IAbpClaimsPrincipalFactory.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/IAbpClaimsPrincipalFactory.cs @@ -5,5 +5,5 @@ namespace Volo.Abp.Security.Claims; public interface IAbpClaimsPrincipalFactory { - Task CreateAsync(ClaimsPrincipal existsClaimsPrincipal = null); + Task CreateAsync(ClaimsPrincipal? existsClaimsPrincipal = null); } diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/ThreadCurrentPrincipalAccessor.cs b/framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/ThreadCurrentPrincipalAccessor.cs index 76030076a3..ab42441f98 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/ThreadCurrentPrincipalAccessor.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/ThreadCurrentPrincipalAccessor.cs @@ -8,6 +8,6 @@ public class ThreadCurrentPrincipalAccessor : CurrentPrincipalAccessorBase, ISin { protected override ClaimsPrincipal GetClaimsPrincipal() { - return Thread.CurrentPrincipal as ClaimsPrincipal; + return (Thread.CurrentPrincipal as ClaimsPrincipal)!; } } diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/Security/Encryption/IStringEncryptionService.cs b/framework/src/Volo.Abp.Security/Volo/Abp/Security/Encryption/IStringEncryptionService.cs index 8a28dc7703..fdf077d483 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/Security/Encryption/IStringEncryptionService.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/Security/Encryption/IStringEncryptionService.cs @@ -15,8 +15,7 @@ public interface IStringEncryptionService /// A phrase to use as the encryption key (optional, uses default if not provided) /// Salt value (optional, uses default if not provided) /// Enrypted text - [CanBeNull] - string Encrypt([CanBeNull] string plainText, string passPhrase = null, byte[] salt = null); + string? Encrypt(string? plainText, string? passPhrase = null, byte[]? salt = null); /// /// Decrypts a text that is encrypted by the method. @@ -25,6 +24,5 @@ public interface IStringEncryptionService /// A phrase to use as the encryption key (optional, uses default if not provided) /// Salt value (optional, uses default if not provided) /// Decrypted text - [CanBeNull] - string Decrypt([CanBeNull] string cipherText, string passPhrase = null, byte[] salt = null); + string? Decrypt(string? cipherText, string? passPhrase = null, byte[]? salt = null); } diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/Security/Encryption/StringEncryptionService.cs b/framework/src/Volo.Abp.Security/Volo/Abp/Security/Encryption/StringEncryptionService.cs index c02c6bca9a..e1e7e94b7a 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/Security/Encryption/StringEncryptionService.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/Security/Encryption/StringEncryptionService.cs @@ -19,7 +19,7 @@ public class StringEncryptionService : IStringEncryptionService, ITransientDepen Options = options.Value; } - public virtual string Encrypt(string plainText, string passPhrase = null, byte[] salt = null) + public virtual string? Encrypt(string? plainText, string? passPhrase = null, byte[]? salt = null) { if (plainText == null) { @@ -60,7 +60,7 @@ public class StringEncryptionService : IStringEncryptionService, ITransientDepen } } - public virtual string Decrypt(string cipherText, string passPhrase = null, byte[] salt = null) + public virtual string? Decrypt(string? cipherText, string? passPhrase = null, byte[]? salt = null) { if (string.IsNullOrEmpty(cipherText)) { diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/AbpSecurityLogOptions.cs b/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/AbpSecurityLogOptions.cs index 24a885cba4..23db29baff 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/AbpSecurityLogOptions.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/AbpSecurityLogOptions.cs @@ -11,7 +11,7 @@ public class AbpSecurityLogOptions /// The name of the application or service writing security log. /// Default: null. /// - public string ApplicationName { get; set; } + public string? ApplicationName { get; set; } public AbpSecurityLogOptions() { diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/DefaultSecurityLogManager.cs b/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/DefaultSecurityLogManager.cs index 392c8fa869..b870b553c3 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/DefaultSecurityLogManager.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/DefaultSecurityLogManager.cs @@ -19,7 +19,7 @@ public class DefaultSecurityLogManager : ISecurityLogManager, ITransientDependen SecurityLogOptions = securityLogOptions.Value; } - public async Task SaveAsync(Action saveAction = null) + public async Task SaveAsync(Action? saveAction = null) { if (!SecurityLogOptions.IsEnabled) { diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/ISecurityLogManager.cs b/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/ISecurityLogManager.cs index 69c71b96af..0e406d2daf 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/ISecurityLogManager.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/ISecurityLogManager.cs @@ -5,5 +5,5 @@ namespace Volo.Abp.SecurityLog; public interface ISecurityLogManager { - Task SaveAsync(Action saveAction = null); + Task SaveAsync(Action? saveAction = null); } diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/SecurityLogInfo.cs b/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/SecurityLogInfo.cs index b5bef5e3fc..f2bb55b5ea 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/SecurityLogInfo.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/SecurityLogInfo.cs @@ -6,29 +6,29 @@ namespace Volo.Abp.SecurityLog; [Serializable] public class SecurityLogInfo { - public string ApplicationName { get; set; } + public string? ApplicationName { get; set; } - public string Identity { get; set; } + public string? Identity { get; set; } - public string Action { get; set; } + public string? Action { get; set; } public Dictionary ExtraProperties { get; } public Guid? UserId { get; set; } - public string UserName { get; set; } + public string? UserName { get; set; } public Guid? TenantId { get; set; } - public string TenantName { get; set; } + public string? TenantName { get; set; } - public string ClientId { get; set; } + public string? ClientId { get; set; } - public string CorrelationId { get; set; } + public string? CorrelationId { get; set; } - public string ClientIpAddress { get; set; } + public string? ClientIpAddress { get; set; } - public string BrowserInfo { get; set; } + public string? BrowserInfo { get; set; } public DateTime CreationTime { get; set; } diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/Users/CurrentUser.cs b/framework/src/Volo.Abp.Security/Volo/Abp/Users/CurrentUser.cs index 771fa7927b..cf52f1afa7 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/Users/CurrentUser.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/Users/CurrentUser.cs @@ -15,17 +15,17 @@ public class CurrentUser : ICurrentUser, ITransientDependency public virtual Guid? Id => _principalAccessor.Principal?.FindUserId(); - public virtual string UserName => this.FindClaimValue(AbpClaimTypes.UserName); + public virtual string? UserName => this.FindClaimValue(AbpClaimTypes.UserName); - public virtual string Name => this.FindClaimValue(AbpClaimTypes.Name); + public virtual string? Name => this.FindClaimValue(AbpClaimTypes.Name); - public virtual string SurName => this.FindClaimValue(AbpClaimTypes.SurName); + public virtual string? SurName => this.FindClaimValue(AbpClaimTypes.SurName); - public virtual string PhoneNumber => this.FindClaimValue(AbpClaimTypes.PhoneNumber); + public virtual string? PhoneNumber => this.FindClaimValue(AbpClaimTypes.PhoneNumber); public virtual bool PhoneNumberVerified => string.Equals(this.FindClaimValue(AbpClaimTypes.PhoneNumberVerified), "true", StringComparison.InvariantCultureIgnoreCase); - public virtual string Email => this.FindClaimValue(AbpClaimTypes.Email); + public virtual string? Email => this.FindClaimValue(AbpClaimTypes.Email); public virtual bool EmailVerified => string.Equals(this.FindClaimValue(AbpClaimTypes.EmailVerified), "true", StringComparison.InvariantCultureIgnoreCase); @@ -40,7 +40,7 @@ public class CurrentUser : ICurrentUser, ITransientDependency _principalAccessor = principalAccessor; } - public virtual Claim FindClaim(string claimType) + public virtual Claim? FindClaim(string claimType) { return _principalAccessor.Principal?.Claims.FirstOrDefault(c => c.Type == claimType); } diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/Users/CurrentUserExtensions.cs b/framework/src/Volo.Abp.Security/Volo/Abp/Users/CurrentUserExtensions.cs index 7e10df87c6..b702bcffde 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/Users/CurrentUserExtensions.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/Users/CurrentUserExtensions.cs @@ -7,8 +7,7 @@ namespace Volo.Abp.Users; public static class CurrentUserExtensions { - [CanBeNull] - public static string FindClaimValue(this ICurrentUser currentUser, string claimType) + public static string? FindClaimValue(this ICurrentUser currentUser, string claimType) { return currentUser.FindClaim(claimType)?.Value; } @@ -29,7 +28,7 @@ public static class CurrentUserExtensions { Debug.Assert(currentUser.Id != null, "currentUser.Id != null"); - return currentUser.Id.Value; + return currentUser!.Id!.Value; } public static Guid? FindImpersonatorTenantId([NotNull] this ICurrentUser currentUser) @@ -62,12 +61,12 @@ public static class CurrentUserExtensions return null; } - public static string FindImpersonatorTenantName([NotNull] this ICurrentUser currentUser) + public static string? FindImpersonatorTenantName([NotNull] this ICurrentUser currentUser) { return currentUser.FindClaimValue(AbpClaimTypes.ImpersonatorTenantName); } - public static string FindImpersonatorUserName([NotNull] this ICurrentUser currentUser) + public static string? FindImpersonatorUserName([NotNull] this ICurrentUser currentUser) { return currentUser.FindClaimValue(AbpClaimTypes.ImpersonatorUserName); } diff --git a/framework/src/Volo.Abp.Security/Volo/Abp/Users/ICurrentUser.cs b/framework/src/Volo.Abp.Security/Volo/Abp/Users/ICurrentUser.cs index 95aecca83a..aacf001279 100644 --- a/framework/src/Volo.Abp.Security/Volo/Abp/Users/ICurrentUser.cs +++ b/framework/src/Volo.Abp.Security/Volo/Abp/Users/ICurrentUser.cs @@ -11,22 +11,17 @@ public interface ICurrentUser [CanBeNull] Guid? Id { get; } - [CanBeNull] - string UserName { get; } + string? UserName { get; } - [CanBeNull] - string Name { get; } + string? Name { get; } - [CanBeNull] - string SurName { get; } + string? SurName { get; } - [CanBeNull] - string PhoneNumber { get; } + string? PhoneNumber { get; } bool PhoneNumberVerified { get; } - [CanBeNull] - string Email { get; } + string? Email { get; } bool EmailVerified { get; } @@ -35,8 +30,7 @@ public interface ICurrentUser [NotNull] string[] Roles { get; } - [CanBeNull] - Claim FindClaim(string claimType); + Claim? FindClaim(string claimType); [NotNull] Claim[] FindClaims(string claimType); From fdd547b85238493f76e686edb2f390b3546b708d Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 6 Jun 2023 15:36:50 +0800 Subject: [PATCH 05/32] 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, From 22df19f755aa67508731b13fa75815b4efc16da6 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 6 Jun 2023 16:04:40 +0800 Subject: [PATCH 06/32] Enable nullable annotations for Volo.Abp.Data --- framework/src/Volo.Abp.Data/Volo.Abp.Data.csproj | 2 ++ .../Volo/Abp/Data/AbpCommonDbProperties.cs | 2 +- .../Data/AbpDataMigrationEnvironmentExtensions.cs | 8 ++++---- .../Volo/Abp/Data/AbpDatabaseInfoDictionary.cs | 3 +-- .../Volo/Abp/Data/AbpDbConnectionOptions.cs | 2 +- .../Volo/Abp/Data/ApplyDatabaseMigrationsEto.cs | 2 +- .../Volo/Abp/Data/ConcurrencyStampExtensions.cs | 4 ++-- .../Volo/Abp/Data/ConnectionStringNameAttribute.cs | 2 +- .../Volo.Abp.Data/Volo/Abp/Data/ConnectionStrings.cs | 4 ++-- .../src/Volo.Abp.Data/Volo/Abp/Data/DataFilter.cs | 12 ++++++------ .../Volo.Abp.Data/Volo/Abp/Data/DataSeedContext.cs | 9 ++++----- .../src/Volo.Abp.Data/Volo/Abp/Data/DataSeeder.cs | 4 ++-- .../Volo/Abp/Data/DataSeederExtensions.cs | 2 +- .../Volo/Abp/Data/DefaultConnectionStringResolver.cs | 10 +++++----- .../Volo/Abp/Data/IConnectionStringResolver.cs | 4 ++-- 15 files changed, 35 insertions(+), 35 deletions(-) diff --git a/framework/src/Volo.Abp.Data/Volo.Abp.Data.csproj b/framework/src/Volo.Abp.Data/Volo.Abp.Data.csproj index b5d2589b19..751042e62c 100644 --- a/framework/src/Volo.Abp.Data/Volo.Abp.Data.csproj +++ b/framework/src/Volo.Abp.Data/Volo.Abp.Data.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Data Volo.Abp.Data $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpCommonDbProperties.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpCommonDbProperties.cs index eacedc2408..16236a4e10 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpCommonDbProperties.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpCommonDbProperties.cs @@ -13,5 +13,5 @@ public static class AbpCommonDbProperties /// /// Default value: null. /// - public static string DbSchema { get; set; } = null; + public static string? DbSchema { get; set; } = null; } diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDataMigrationEnvironmentExtensions.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDataMigrationEnvironmentExtensions.cs index 796b547164..18b990ce73 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDataMigrationEnvironmentExtensions.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDataMigrationEnvironmentExtensions.cs @@ -6,17 +6,17 @@ namespace Volo.Abp.Data; public static class AbpDataMigrationEnvironmentExtensions { - public static void AddDataMigrationEnvironment(this AbpApplicationCreationOptions options, AbpDataMigrationEnvironment environment = null) + public static void AddDataMigrationEnvironment(this AbpApplicationCreationOptions options, AbpDataMigrationEnvironment? environment = null) { options.Services.AddDataMigrationEnvironment(environment ?? new AbpDataMigrationEnvironment()); } - public static void AddDataMigrationEnvironment(this IServiceCollection services, AbpDataMigrationEnvironment environment = null) + public static void AddDataMigrationEnvironment(this IServiceCollection services, AbpDataMigrationEnvironment? environment = null) { services.AddObjectAccessor(environment ?? new AbpDataMigrationEnvironment()); } - public static AbpDataMigrationEnvironment GetDataMigrationEnvironment(this IServiceCollection services) + public static AbpDataMigrationEnvironment? GetDataMigrationEnvironment(this IServiceCollection services) { return services.GetObjectOrNull(); } @@ -26,7 +26,7 @@ public static class AbpDataMigrationEnvironmentExtensions return services.GetDataMigrationEnvironment() != null; } - public static AbpDataMigrationEnvironment GetDataMigrationEnvironment(this IServiceProvider serviceProvider) + public static AbpDataMigrationEnvironment? GetDataMigrationEnvironment(this IServiceProvider serviceProvider) { return serviceProvider.GetService>()?.Value; } diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDatabaseInfoDictionary.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDatabaseInfoDictionary.cs index 2f17b320dd..06334be6db 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDatabaseInfoDictionary.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDatabaseInfoDictionary.cs @@ -13,8 +13,7 @@ public class AbpDatabaseInfoDictionary : Dictionary ConnectionIndex = new Dictionary(); } - [CanBeNull] - public AbpDatabaseInfo GetMappedDatabaseOrNull(string connectionStringName) + public AbpDatabaseInfo? GetMappedDatabaseOrNull(string connectionStringName) { return ConnectionIndex.GetOrDefault(connectionStringName); } diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDbConnectionOptions.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDbConnectionOptions.cs index a8101e2f7c..3e27ae97ae 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDbConnectionOptions.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDbConnectionOptions.cs @@ -15,7 +15,7 @@ public class AbpDbConnectionOptions Databases = new AbpDatabaseInfoDictionary(); } - public string GetConnectionStringOrNull( + public string? GetConnectionStringOrNull( string connectionStringName, bool fallbackToDatabaseMappings = true, bool fallbackToDefault = true) diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/ApplyDatabaseMigrationsEto.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/ApplyDatabaseMigrationsEto.cs index 061ce94a79..8ac1290fad 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/ApplyDatabaseMigrationsEto.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/ApplyDatabaseMigrationsEto.cs @@ -10,5 +10,5 @@ public class ApplyDatabaseMigrationsEto : EtoBase { public Guid? TenantId { get; set; } - public string DatabaseName { get; set; } + public string DatabaseName { get; set; } = default!; } diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/ConcurrencyStampExtensions.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/ConcurrencyStampExtensions.cs index 4b0cd87252..84232a7a88 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/ConcurrencyStampExtensions.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/ConcurrencyStampExtensions.cs @@ -7,11 +7,11 @@ namespace Volo.Abp.Data; public static class ConcurrencyStampExtensions { - public static void SetConcurrencyStampIfNotNull(this IHasConcurrencyStamp entity, [CanBeNull] string concurrencyStamp) + public static void SetConcurrencyStampIfNotNull(this IHasConcurrencyStamp entity, string? concurrencyStamp) { if (!concurrencyStamp.IsNullOrEmpty()) { - entity.ConcurrencyStamp = concurrencyStamp; + entity.ConcurrencyStamp = concurrencyStamp!; } } } diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/ConnectionStringNameAttribute.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/ConnectionStringNameAttribute.cs index 9e028eef12..e5936ab932 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/ConnectionStringNameAttribute.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/ConnectionStringNameAttribute.cs @@ -27,7 +27,7 @@ public class ConnectionStringNameAttribute : Attribute if (nameAttribute == null) { - return type.FullName; + return type.FullName!; } return nameAttribute.Name; diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/ConnectionStrings.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/ConnectionStrings.cs index ca84675c10..22354defc4 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/ConnectionStrings.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/ConnectionStrings.cs @@ -4,11 +4,11 @@ using System.Collections.Generic; namespace Volo.Abp.Data; [Serializable] -public class ConnectionStrings : Dictionary +public class ConnectionStrings : Dictionary { public const string DefaultConnectionStringName = "Default"; - public string Default { + public string? Default { get => this.GetOrDefault(DefaultConnectionStringName); set => this[DefaultConnectionStringName] = value; } diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataFilter.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataFilter.cs index cca494bb07..40ff5cdf70 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataFilter.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataFilter.cs @@ -42,10 +42,10 @@ public class DataFilter : IDataFilter, ISingletonDependency private IDataFilter GetFilter() where TFilter : class { - return _filters.GetOrAdd( + return (_filters.GetOrAdd( typeof(TFilter), - factory: () => _serviceProvider.GetRequiredService>() - ) as IDataFilter; + factory: () => _serviceProvider.GetRequiredService>() + ) as IDataFilter)!; } } @@ -55,7 +55,7 @@ public class DataFilter : IDataFilter public bool IsEnabled { get { EnsureInitialized(); - return _filter.Value.IsEnabled; + return _filter.Value!.IsEnabled; } } @@ -76,7 +76,7 @@ public class DataFilter : IDataFilter return NullDisposable.Instance; } - _filter.Value.IsEnabled = true; + _filter.Value!.IsEnabled = true; return new DisposeAction(() => Disable()); } @@ -88,7 +88,7 @@ public class DataFilter : IDataFilter return NullDisposable.Instance; } - _filter.Value.IsEnabled = false; + _filter.Value!.IsEnabled = false; return new DisposeAction(() => Enable()); } diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeedContext.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeedContext.cs index 783fddecb3..3a4aa1c0d7 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeedContext.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeedContext.cs @@ -16,8 +16,7 @@ public class DataSeedContext /// Returns the value in the dictionary by given . /// Returns null if given is not present in the dictionary. /// - [CanBeNull] - public object this[string name] { + public object? this[string name] { get => Properties.GetOrDefault(name); set => Properties[name] = value; } @@ -26,19 +25,19 @@ public class DataSeedContext /// Can be used to get/set custom properties. /// [NotNull] - public Dictionary Properties { get; } + public Dictionary Properties { get; } public DataSeedContext(Guid? tenantId = null) { TenantId = tenantId; - Properties = new Dictionary(); + Properties = new Dictionary(); } /// /// Sets a property in the dictionary. /// This is a shortcut for nested calls on this object. /// - public virtual DataSeedContext WithProperty(string key, object value) + public virtual DataSeedContext WithProperty(string key, object? value) { Properties[key] = value; return this; diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeeder.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeeder.cs index 45729fcb86..83586e8e70 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeeder.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeeder.cs @@ -33,9 +33,9 @@ public class DataSeeder : IDataSeeder, ITransientDependency foreach (var contributorType in Options.Contributors) { var options = context.Properties.TryGetValue(DataSeederExtensions.SeedInSeparateUowOptions, out var uowOptions) - ? (AbpUnitOfWorkOptions) uowOptions + ? (AbpUnitOfWorkOptions) uowOptions! : new AbpUnitOfWorkOptions(); - var requiresNew = context.Properties.TryGetValue(DataSeederExtensions.SeedInSeparateUowRequiresNew, out var obj) && (bool) obj; + var requiresNew = context.Properties.TryGetValue(DataSeederExtensions.SeedInSeparateUowRequiresNew, out var obj) && (bool) obj!; using (var uow = manager.Begin(options, requiresNew)) { diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeederExtensions.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeederExtensions.cs index bd17736b46..f8f3cf8dc5 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeederExtensions.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/DataSeederExtensions.cs @@ -15,7 +15,7 @@ public static class DataSeederExtensions return seeder.SeedAsync(new DataSeedContext(tenantId)); } - public static Task SeedInSeparateUowAsync(this IDataSeeder seeder, Guid? tenantId = null, AbpUnitOfWorkOptions options = null, bool requiresNew = false) + public static Task SeedInSeparateUowAsync(this IDataSeeder seeder, Guid? tenantId = null, AbpUnitOfWorkOptions? options = null, bool requiresNew = false) { var context = new DataSeedContext(tenantId); context.WithProperty(SeedInSeparateUow, true); diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/DefaultConnectionStringResolver.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/DefaultConnectionStringResolver.cs index d3edbd30b0..257c0be663 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/DefaultConnectionStringResolver.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/DefaultConnectionStringResolver.cs @@ -16,17 +16,17 @@ public class DefaultConnectionStringResolver : IConnectionStringResolver, ITrans } [Obsolete("Use ResolveAsync method.")] - public virtual string Resolve(string connectionStringName = null) + public virtual string Resolve(string? connectionStringName = null) { - return ResolveInternal(connectionStringName); + return ResolveInternal(connectionStringName)!; } - public virtual Task ResolveAsync(string connectionStringName = null) + public virtual Task ResolveAsync(string? connectionStringName = null) { - return Task.FromResult(ResolveInternal(connectionStringName)); + return Task.FromResult(ResolveInternal(connectionStringName))!; } - private string ResolveInternal(string connectionStringName) + private string? ResolveInternal(string? connectionStringName) { if (connectionStringName == null) { diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/IConnectionStringResolver.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/IConnectionStringResolver.cs index 793fb309cb..8ef7df4e60 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/IConnectionStringResolver.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/IConnectionStringResolver.cs @@ -8,8 +8,8 @@ public interface IConnectionStringResolver { [NotNull] [Obsolete("Use ResolveAsync method.")] - string Resolve(string connectionStringName = null); + string Resolve(string? connectionStringName = null); [NotNull] - Task ResolveAsync(string connectionStringName = null); + Task ResolveAsync(string? connectionStringName = null); } From 57b87b4dcfa9ac2f7fb3a153d99e27a7892ca1a6 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 6 Jun 2023 16:22:19 +0800 Subject: [PATCH 07/32] Enable nullable annotations for Volo.Abp.Json.Abstractions --- .../Volo.Abp.Json.Abstractions.csproj | 2 ++ .../Volo.Abp.Json.Abstractions/Volo/Abp/Json/AbpJsonOptions.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Json.Abstractions/Volo.Abp.Json.Abstractions.csproj b/framework/src/Volo.Abp.Json.Abstractions/Volo.Abp.Json.Abstractions.csproj index d3f63e6e20..1be747846e 100644 --- a/framework/src/Volo.Abp.Json.Abstractions/Volo.Abp.Json.Abstractions.csproj +++ b/framework/src/Volo.Abp.Json.Abstractions/Volo.Abp.Json.Abstractions.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Json.Abstractions $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; false diff --git a/framework/src/Volo.Abp.Json.Abstractions/Volo/Abp/Json/AbpJsonOptions.cs b/framework/src/Volo.Abp.Json.Abstractions/Volo/Abp/Json/AbpJsonOptions.cs index 043c1081d7..bed36c8afa 100644 --- a/framework/src/Volo.Abp.Json.Abstractions/Volo/Abp/Json/AbpJsonOptions.cs +++ b/framework/src/Volo.Abp.Json.Abstractions/Volo/Abp/Json/AbpJsonOptions.cs @@ -12,7 +12,7 @@ public class AbpJsonOptions /// /// Format of output json date, Null or empty string means default format. /// - public string OutputDateTimeFormat { get; set; } + public string? OutputDateTimeFormat { get; set; } public AbpJsonOptions() { From 02199e52d485d130b9c3376b9a432c3ede164424 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 6 Jun 2023 16:34:17 +0800 Subject: [PATCH 08/32] Enable nullable annotations for Volo.Abp.Json.SystemTextJson --- .../Volo.Abp.Json.SystemTextJson.csproj | 2 ++ .../AbpSystemTextJsonSerializer.cs | 4 ++-- .../AbpNullableStringToGuidConverter.cs | 2 +- .../AbpStringToBooleanConverter.cs | 2 +- .../AbpStringToEnumConverter.cs | 10 +++++----- .../JsonConverters/AbpStringToEnumFactory.cs | 6 +++--- .../AbpStringToGuidConverter.cs | 2 +- .../ObjectToInferredTypesConverter.cs | 20 +++++++++---------- .../Modifiers/AbpDateTimeConverterModifier.cs | 2 +- .../Modifiers/AbpIgnorePropertiesModifiers.cs | 2 +- .../AbpIncludeExtraPropertiesModifiers.cs | 2 +- .../AbpIncludeNonPublicPropertiesModifiers.cs | 2 +- 12 files changed, 29 insertions(+), 27 deletions(-) diff --git a/framework/src/Volo.Abp.Json.SystemTextJson/Volo.Abp.Json.SystemTextJson.csproj b/framework/src/Volo.Abp.Json.SystemTextJson/Volo.Abp.Json.SystemTextJson.csproj index e7551a0e42..08ea7d91e6 100644 --- a/framework/src/Volo.Abp.Json.SystemTextJson/Volo.Abp.Json.SystemTextJson.csproj +++ b/framework/src/Volo.Abp.Json.SystemTextJson/Volo.Abp.Json.SystemTextJson.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Json.SystemTextJson Volo.Abp.Json.SystemTextJson $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializer.cs b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializer.cs index 8313f6ee99..6f433ce918 100644 --- a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializer.cs +++ b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializer.cs @@ -22,12 +22,12 @@ public class AbpSystemTextJsonSerializer : IJsonSerializer, ITransientDependency public T Deserialize(string jsonString, bool camelCase = true) { - return JsonSerializer.Deserialize(jsonString, CreateJsonSerializerOptions(camelCase)); + return JsonSerializer.Deserialize(jsonString, CreateJsonSerializerOptions(camelCase))!; } public object Deserialize(Type type, string jsonString, bool camelCase = true) { - return JsonSerializer.Deserialize(jsonString, type, CreateJsonSerializerOptions(camelCase)); + return JsonSerializer.Deserialize(jsonString, type, CreateJsonSerializerOptions(camelCase))!; } private static readonly ConcurrentDictionary JsonSerializerOptionsCache = diff --git a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpNullableStringToGuidConverter.cs b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpNullableStringToGuidConverter.cs index c80e5aa9a5..973faca170 100644 --- a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpNullableStringToGuidConverter.cs +++ b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpNullableStringToGuidConverter.cs @@ -6,7 +6,7 @@ namespace Volo.Abp.Json.SystemTextJson.JsonConverters; public class AbpNullableStringToGuidConverter : JsonConverter { - private JsonSerializerOptions _writeJsonSerializerOptions; + private JsonSerializerOptions? _writeJsonSerializerOptions; public override Guid? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { diff --git a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToBooleanConverter.cs b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToBooleanConverter.cs index e704f2ceb0..443150e41a 100644 --- a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToBooleanConverter.cs +++ b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToBooleanConverter.cs @@ -8,7 +8,7 @@ namespace Volo.Abp.Json.SystemTextJson.JsonConverters; public class AbpStringToBooleanConverter : JsonConverter { - private JsonSerializerOptions _writeJsonSerializerOptions; + private JsonSerializerOptions? _writeJsonSerializerOptions; public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { diff --git a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs index 6b7f32807e..d1e8fc555d 100644 --- a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs +++ b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs @@ -9,9 +9,9 @@ public class AbpStringToEnumConverter : JsonConverter { private readonly JsonStringEnumConverter _innerJsonStringEnumConverter; - private JsonSerializerOptions _readJsonSerializerOptions; + private JsonSerializerOptions? _readJsonSerializerOptions; - private JsonSerializerOptions _writeJsonSerializerOptions; + private JsonSerializerOptions? _writeJsonSerializerOptions; public AbpStringToEnumConverter() : this(namingPolicy: null, allowIntegerValues: true) @@ -19,7 +19,7 @@ public class AbpStringToEnumConverter : JsonConverter } - public AbpStringToEnumConverter(JsonNamingPolicy namingPolicy = null, bool allowIntegerValues = true) + public AbpStringToEnumConverter(JsonNamingPolicy? namingPolicy = null, bool allowIntegerValues = true) { _innerJsonStringEnumConverter = new JsonStringEnumConverter(namingPolicy, allowIntegerValues); } @@ -50,11 +50,11 @@ public class AbpStringToEnumConverter : JsonConverter public override T ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - return (T)Enum.Parse(typeToConvert, reader.GetString()); + return (T)Enum.Parse(typeToConvert, reader.GetString()!); } public override void WriteAsPropertyName(Utf8JsonWriter writer, T value, JsonSerializerOptions options) { - writer.WritePropertyName(Enum.GetName(typeof(T), value)); + writer.WritePropertyName(Enum.GetName(typeof(T), value)!); } } diff --git a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumFactory.cs b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumFactory.cs index d94d85e546..bda510e5dc 100644 --- a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumFactory.cs +++ b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumFactory.cs @@ -7,7 +7,7 @@ namespace Volo.Abp.Json.SystemTextJson.JsonConverters; public class AbpStringToEnumFactory : JsonConverterFactory { - private readonly JsonNamingPolicy _namingPolicy; + private readonly JsonNamingPolicy? _namingPolicy; private readonly bool _allowIntegerValues; public AbpStringToEnumFactory() @@ -16,7 +16,7 @@ public class AbpStringToEnumFactory : JsonConverterFactory } - public AbpStringToEnumFactory(JsonNamingPolicy namingPolicy, bool allowIntegerValues) + public AbpStringToEnumFactory(JsonNamingPolicy? namingPolicy, bool allowIntegerValues) { _namingPolicy = namingPolicy; _allowIntegerValues = allowIntegerValues; @@ -33,7 +33,7 @@ public class AbpStringToEnumFactory : JsonConverterFactory typeof(AbpStringToEnumConverter<>).MakeGenericType(typeToConvert), BindingFlags.Instance | BindingFlags.Public, binder: null, - new object[] { _namingPolicy, _allowIntegerValues }, + new object?[] { _namingPolicy, _allowIntegerValues }, culture: null)!; } } diff --git a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToGuidConverter.cs b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToGuidConverter.cs index 586e4462cf..5cb1062c0c 100644 --- a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToGuidConverter.cs +++ b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToGuidConverter.cs @@ -6,7 +6,7 @@ namespace Volo.Abp.Json.SystemTextJson.JsonConverters; public class AbpStringToGuidConverter : JsonConverter { - private JsonSerializerOptions _writeJsonSerializerOptions; + private JsonSerializerOptions? _writeJsonSerializerOptions; public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { diff --git a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/ObjectToInferredTypesConverter.cs b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/ObjectToInferredTypesConverter.cs index b1bffc95b8..bf017d041e 100644 --- a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/ObjectToInferredTypesConverter.cs +++ b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/ObjectToInferredTypesConverter.cs @@ -12,16 +12,16 @@ public class ObjectToInferredTypesConverter : JsonConverter public override object Read( ref Utf8JsonReader reader, Type typeToConvert, - JsonSerializerOptions options) => reader.TokenType switch - { - JsonTokenType.True => true, - JsonTokenType.False => false, - JsonTokenType.Number when reader.TryGetInt64(out long l) => l, - JsonTokenType.Number => reader.GetDouble(), - JsonTokenType.String when reader.TryGetDateTime(out DateTime datetime) => datetime, - JsonTokenType.String => reader.GetString(), - _ => JsonDocument.ParseValue(ref reader).RootElement.Clone() - }; + JsonSerializerOptions options) => (reader.TokenType switch + { + JsonTokenType.True => true, + JsonTokenType.False => false, + JsonTokenType.Number when reader.TryGetInt64(out long l) => l, + JsonTokenType.Number => reader.GetDouble(), + JsonTokenType.String when reader.TryGetDateTime(out DateTime datetime) => datetime, + JsonTokenType.String => reader.GetString(), + _ => JsonDocument.ParseValue(ref reader).RootElement.Clone() + })!; public override void Write( Utf8JsonWriter writer, diff --git a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpDateTimeConverterModifier.cs b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpDateTimeConverterModifier.cs index a691423cf3..ba19ccfa29 100644 --- a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpDateTimeConverterModifier.cs +++ b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpDateTimeConverterModifier.cs @@ -10,7 +10,7 @@ namespace Volo.Abp.Json.SystemTextJson.Modifiers; public class AbpDateTimeConverterModifier { - private IServiceProvider _serviceProvider; + private IServiceProvider _serviceProvider = default!; public Action CreateModifyAction(IServiceProvider serviceProvider) { diff --git a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpIgnorePropertiesModifiers.cs b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpIgnorePropertiesModifiers.cs index 27a50395bf..7c1db739d1 100644 --- a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpIgnorePropertiesModifiers.cs +++ b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpIgnorePropertiesModifiers.cs @@ -9,7 +9,7 @@ namespace Volo.Abp.Json.SystemTextJson.Modifiers; public class AbpIgnorePropertiesModifiers where TClass : class { - private Expression> _propertySelector; + private Expression> _propertySelector = default!; public Action CreateModifyAction(Expression> propertySelector) { diff --git a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpIncludeExtraPropertiesModifiers.cs b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpIncludeExtraPropertiesModifiers.cs index f4a97e0e9d..c7fadc47db 100644 --- a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpIncludeExtraPropertiesModifiers.cs +++ b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpIncludeExtraPropertiesModifiers.cs @@ -17,7 +17,7 @@ public static class AbpIncludeExtraPropertiesModifiers .Where(x => x.AttributeProvider is MemberInfo) .FirstOrDefault(x => x.PropertyType == typeof(ExtraPropertyDictionary) && - x.AttributeProvider.As().Name == nameof(ExtensibleObject.ExtraProperties) && + x.AttributeProvider!.As().Name == nameof(ExtensibleObject.ExtraProperties) && x.Set == null); if (propertyJsonInfo != null) diff --git a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpIncludeNonPublicPropertiesModifiers.cs b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpIncludeNonPublicPropertiesModifiers.cs index 4669ddc666..cc13db8d0c 100644 --- a/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpIncludeNonPublicPropertiesModifiers.cs +++ b/framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/Modifiers/AbpIncludeNonPublicPropertiesModifiers.cs @@ -9,7 +9,7 @@ namespace Volo.Abp.Json.SystemTextJson.Modifiers; public class AbpIncludeNonPublicPropertiesModifiers where TClass : class { - private Expression> _propertySelector; + private Expression> _propertySelector = default!; public Action CreateModifyAction(Expression> propertySelector) { From 95fc35f134a03cfad3d3a946d040e8c2c7d2b653 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 6 Jun 2023 16:42:18 +0800 Subject: [PATCH 09/32] Enable nullable annotations for Volo.Abp.Json.Newtonsoft --- .../Volo.Abp.Json.Newtonsoft.csproj | 2 ++ .../Volo/Abp/Json/Newtonsoft/AbpDateTimeConverter.cs | 10 +++++----- .../Abp/Json/Newtonsoft/AbpNewtonsoftJsonSerializer.cs | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/framework/src/Volo.Abp.Json.Newtonsoft/Volo.Abp.Json.Newtonsoft.csproj b/framework/src/Volo.Abp.Json.Newtonsoft/Volo.Abp.Json.Newtonsoft.csproj index 5349254ea3..094a6e3c0a 100644 --- a/framework/src/Volo.Abp.Json.Newtonsoft/Volo.Abp.Json.Newtonsoft.csproj +++ b/framework/src/Volo.Abp.Json.Newtonsoft/Volo.Abp.Json.Newtonsoft.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Json.Newtonsoft Volo.Abp.Json.Newtonsoft $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Json.Newtonsoft/Volo/Abp/Json/Newtonsoft/AbpDateTimeConverter.cs b/framework/src/Volo.Abp.Json.Newtonsoft/Volo/Abp/Json/Newtonsoft/AbpDateTimeConverter.cs index 408f38e772..effda40057 100644 --- a/framework/src/Volo.Abp.Json.Newtonsoft/Volo/Abp/Json/Newtonsoft/AbpDateTimeConverter.cs +++ b/framework/src/Volo.Abp.Json.Newtonsoft/Volo/Abp/Json/Newtonsoft/AbpDateTimeConverter.cs @@ -31,7 +31,7 @@ public class AbpDateTimeConverter : DateTimeConverterBase, ITransientDependency return objectType == typeof(DateTime) || objectType == typeof(DateTime?); } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { var nullable = Nullable.GetUnderlyingType(objectType) != null; if (reader.TokenType == JsonToken.Null) @@ -46,7 +46,7 @@ public class AbpDateTimeConverter : DateTimeConverterBase, ITransientDependency if (reader.TokenType == JsonToken.Date) { - return _clock.Normalize(reader.Value.To()); + return _clock.Normalize(reader.Value!.To()); } if (reader.TokenType != JsonToken.String) @@ -72,11 +72,11 @@ public class AbpDateTimeConverter : DateTimeConverterBase, ITransientDependency } } - var date = DateTime.Parse(dateText, _culture, _dateTimeStyles); + var date = DateTime.Parse(dateText!, _culture, _dateTimeStyles); return _clock.Normalize(date); } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { if (value != null) { @@ -97,7 +97,7 @@ public class AbpDateTimeConverter : DateTimeConverterBase, ITransientDependency } else { - throw new JsonSerializationException($"Unexpected value when converting date. Expected DateTime or DateTimeOffset, got {value.GetType()}."); + throw new JsonSerializationException($"Unexpected value when converting date. Expected DateTime or DateTimeOffset, got {value?.GetType()}."); } } diff --git a/framework/src/Volo.Abp.Json.Newtonsoft/Volo/Abp/Json/Newtonsoft/AbpNewtonsoftJsonSerializer.cs b/framework/src/Volo.Abp.Json.Newtonsoft/Volo/Abp/Json/Newtonsoft/AbpNewtonsoftJsonSerializer.cs index ab65909cf9..2a21f5fbd7 100644 --- a/framework/src/Volo.Abp.Json.Newtonsoft/Volo/Abp/Json/Newtonsoft/AbpNewtonsoftJsonSerializer.cs +++ b/framework/src/Volo.Abp.Json.Newtonsoft/Volo/Abp/Json/Newtonsoft/AbpNewtonsoftJsonSerializer.cs @@ -26,12 +26,12 @@ public class AbpNewtonsoftJsonSerializer : IJsonSerializer, ITransientDependency public T Deserialize(string jsonString, bool camelCase = true) { - return JsonConvert.DeserializeObject(jsonString, CreateJsonSerializerOptions(camelCase)); + return JsonConvert.DeserializeObject(jsonString, CreateJsonSerializerOptions(camelCase))!; } public object Deserialize(Type type, string jsonString, bool camelCase = true) { - return JsonConvert.DeserializeObject(jsonString, type, CreateJsonSerializerOptions(camelCase)); + return JsonConvert.DeserializeObject(jsonString, type, CreateJsonSerializerOptions(camelCase))!; } private readonly static ConcurrentDictionary JsonSerializerOptionsCache = From f3292d63b2f549f8fa4ac209ca20c0c8eae48957 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 6 Jun 2023 16:50:50 +0800 Subject: [PATCH 10/32] Enable nullable annotations for Volo.Abp.Localization --- .../Volo.Abp.Localization.csproj | 2 ++ .../AbpDictionaryBasedStringLocalizer.cs | 8 ++--- .../Volo/Abp/Localization/AbpEnumLocalizer.cs | 8 ++--- .../Localization/AbpLocalizationOptions.cs | 2 +- .../AbpStringLocalizerExtensions.cs | 2 +- .../Localization/AbpStringLocalizerFactory.cs | 16 +++++----- .../External/IExternalLocalizationStore.cs | 6 ++-- .../External/NullExternalLocalizationStore.cs | 6 ++-- .../Volo/Abp/Localization/ILanguageInfo.cs | 2 +- .../ILocalizableStringSerializer.cs | 2 +- .../Localization/ILocalizationDictionary.cs | 2 +- .../ILocalizationResourceContributor.cs | 2 +- .../Json/JsonLocalizationDictionaryBuilder.cs | 14 +++++---- .../Localization/Json/JsonLocalizationFile.cs | 2 +- .../Volo/Abp/Localization/LanguageInfo.cs | 29 +++++++++---------- .../Localization/LanguageInfoExtensions.cs | 4 +-- .../LocalizableStringSerializer.cs | 2 +- .../Abp/Localization/LocalizationResource.cs | 4 +-- .../Localization/LocalizationResourceBase.cs | 7 ++--- .../LocalizationResourceContributorList.cs | 2 +- .../LocalizationResourceDictionary.cs | 8 ++--- .../NonTypedLocalizationResource.cs | 4 +-- .../StaticLocalizationDictionary.cs | 2 +- ...tualFileLocalizationResourceContributor.cs | 2 +- ...FileLocalizationResourceContributorBase.cs | 14 ++++----- 25 files changed, 75 insertions(+), 77 deletions(-) diff --git a/framework/src/Volo.Abp.Localization/Volo.Abp.Localization.csproj b/framework/src/Volo.Abp.Localization/Volo.Abp.Localization.csproj index 8b889e2057..f4c5c4ece2 100644 --- a/framework/src/Volo.Abp.Localization/Volo.Abp.Localization.csproj +++ b/framework/src/Volo.Abp.Localization/Volo.Abp.Localization.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Localization Volo.Abp.Localization $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs index cf5c1ebb82..86133cdf17 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs @@ -118,7 +118,7 @@ public class AbpDictionaryBasedStringLocalizer : IAbpStringLocalizer return value; } - protected virtual LocalizedString GetLocalizedStringOrNull( + protected virtual LocalizedString? GetLocalizedStringOrNull( string name, string cultureName, bool tryDefaults = true) @@ -153,7 +153,7 @@ public class AbpDictionaryBasedStringLocalizer : IAbpStringLocalizer //Try to get from default language if (!Resource.DefaultCultureName.IsNullOrEmpty()) { - var strDefault = Resource.Contributors.GetOrNull(Resource.DefaultCultureName, name); + var strDefault = Resource.Contributors.GetOrNull(Resource.DefaultCultureName!, name); if (strDefault != null) { return strDefault; @@ -208,7 +208,7 @@ public class AbpDictionaryBasedStringLocalizer : IAbpStringLocalizer //Fill all strings from default culture if (!Resource.DefaultCultureName.IsNullOrEmpty()) { - Resource.Contributors.Fill(Resource.DefaultCultureName, allStrings, includeDynamicContributors); + Resource.Contributors.Fill(Resource.DefaultCultureName!, allStrings, includeDynamicContributors); } //Overwrite all strings from the language based on country culture @@ -268,7 +268,7 @@ public class AbpDictionaryBasedStringLocalizer : IAbpStringLocalizer if (!Resource.DefaultCultureName.IsNullOrEmpty()) { await Resource.Contributors.FillAsync( - Resource.DefaultCultureName, + Resource.DefaultCultureName!, allStrings, includeDynamicContributors ); diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpEnumLocalizer.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpEnumLocalizer.cs index 3fc053da6a..b2acb3d072 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpEnumLocalizer.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpEnumLocalizer.cs @@ -19,14 +19,14 @@ public class AbpEnumLocalizer : IAbpEnumLocalizer, ITransientDependency return GetStringInternal(enumType, enumValue, StringLocalizerFactory.CreateDefaultOrNull()); } - public virtual string GetString(Type enumType, object enumValue, params IStringLocalizer[] specifyLocalizers) + public virtual string GetString(Type enumType, object enumValue, params IStringLocalizer?[] specifyLocalizers) { return GetStringInternal(enumType, enumValue, specifyLocalizers); } - protected virtual string GetStringInternal(Type enumType, object enumValue, params IStringLocalizer[] specifyLocalizers) + protected virtual string GetStringInternal(Type enumType, object enumValue, params IStringLocalizer?[] specifyLocalizers) { - var memberName = enumType.GetEnumName(enumValue); + var memberName = enumType.GetEnumName(enumValue)!; var localizedString = GetStringOrNull( specifyLocalizers, new[] @@ -42,7 +42,7 @@ public class AbpEnumLocalizer : IAbpEnumLocalizer, ITransientDependency return localizedString ?? memberName; } - protected virtual string GetStringOrNull(IStringLocalizer[] localizers, IEnumerable keys) + protected virtual string? GetStringOrNull(IStringLocalizer?[] localizers, IEnumerable keys) { foreach (var key in keys) { diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationOptions.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationOptions.cs index 5228f886e9..0fd9d47ac8 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationOptions.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationOptions.cs @@ -11,7 +11,7 @@ public class AbpLocalizationOptions /// /// Used as the default resource when resource was not specified on a localization operation. /// - public Type DefaultResourceType { get; set; } + public Type? DefaultResourceType { get; set; } public ITypeList GlobalContributors { get; } diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerExtensions.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerExtensions.cs index 9b3bb2c201..91c7126a97 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerExtensions.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerExtensions.cs @@ -35,7 +35,7 @@ public static class AbpStringLocalizerExtensions throw new AbpException($"Could not find the _localizer field inside the {typeof(StringLocalizer<>).FullName} class. Probably its name has changed. Please report this issue to the ABP framework."); } - return localizerField.GetValue(stringLocalizer) as IStringLocalizer; + return (localizerField.GetValue(stringLocalizer) as IStringLocalizer)!; } public static IEnumerable GetAllStrings( diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerFactory.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerFactory.cs index b89a54abd9..f40385c128 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerFactory.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerFactory.cs @@ -52,12 +52,12 @@ public class AbpStringLocalizerFactory : IStringLocalizerFactory, IAbpStringLoca return CreateInternal(resource.ResourceName, resource, lockCache); } - public IStringLocalizer CreateByResourceNameOrNull(string resourceName) + public IStringLocalizer? CreateByResourceNameOrNull(string resourceName) { return CreateByResourceNameOrNullInternal(resourceName, lockCache: true); } - private IStringLocalizer CreateByResourceNameOrNullInternal( + private IStringLocalizer? CreateByResourceNameOrNullInternal( string resourceName, bool lockCache) { @@ -74,12 +74,12 @@ public class AbpStringLocalizerFactory : IStringLocalizerFactory, IAbpStringLoca return CreateInternal(resourceName, resource, lockCache); } - public Task CreateByResourceNameOrNullAsync(string resourceName) + public Task CreateByResourceNameOrNullAsync(string resourceName) { return CreateByResourceNameOrNullInternalAsync(resourceName, lockCache: true); } - private async Task CreateByResourceNameOrNullInternalAsync( + private async Task CreateByResourceNameOrNullInternalAsync( string resourceName, bool lockCache) { @@ -175,7 +175,7 @@ public class AbpStringLocalizerFactory : IStringLocalizerFactory, IAbpStringLoca { resource.Contributors.Add( Activator - .CreateInstance(globalContributorType) + .CreateInstance(globalContributorType)! .As() ); } @@ -194,7 +194,7 @@ public class AbpStringLocalizerFactory : IStringLocalizerFactory, IAbpStringLoca .BaseResourceNames .Select(x => CreateByResourceNameOrNullInternal(x, lockCache: false)) .Where(x => x != null) - .ToList(), + .ToList()!, AbpLocalizationOptions ) ); @@ -206,7 +206,7 @@ public class AbpStringLocalizerFactory : IStringLocalizerFactory, IAbpStringLoca { resource.Contributors.Add( Activator - .CreateInstance(globalContributorType) + .CreateInstance(globalContributorType)! .As() ); } @@ -259,7 +259,7 @@ public class AbpStringLocalizerFactory : IStringLocalizerFactory, IAbpStringLoca } } - public IStringLocalizer CreateDefaultOrNull() + public IStringLocalizer? CreateDefaultOrNull() { if (AbpLocalizationOptions.DefaultResourceType == null) { diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/External/IExternalLocalizationStore.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/External/IExternalLocalizationStore.cs index cd48bb1bd9..c2aa55cd2f 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/External/IExternalLocalizationStore.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/External/IExternalLocalizationStore.cs @@ -5,11 +5,9 @@ namespace Volo.Abp.Localization.External; public interface IExternalLocalizationStore { - [CanBeNull] - LocalizationResourceBase GetResourceOrNull([NotNull] string resourceName); + LocalizationResourceBase? GetResourceOrNull([NotNull] string resourceName); - [ItemCanBeNull] - Task GetResourceOrNullAsync([NotNull] string resourceName); + Task GetResourceOrNullAsync([NotNull] string resourceName); Task GetResourceNamesAsync(); diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/External/NullExternalLocalizationStore.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/External/NullExternalLocalizationStore.cs index 508f947981..891beba134 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/External/NullExternalLocalizationStore.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/External/NullExternalLocalizationStore.cs @@ -6,14 +6,14 @@ namespace Volo.Abp.Localization.External; public class NullExternalLocalizationStore : IExternalLocalizationStore, ISingletonDependency { - public LocalizationResourceBase GetResourceOrNull(string resourceName) + public LocalizationResourceBase? GetResourceOrNull(string resourceName) { return null; } - public Task GetResourceOrNullAsync(string resourceName) + public Task GetResourceOrNullAsync(string resourceName) { - return Task.FromResult(null); + return Task.FromResult(null); } public Task GetResourceNamesAsync() diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILanguageInfo.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILanguageInfo.cs index d4e06e9af5..e8ae6935de 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILanguageInfo.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILanguageInfo.cs @@ -8,5 +8,5 @@ public interface ILanguageInfo string DisplayName { get; } - string FlagIcon { get; } + string? FlagIcon { get; } } diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILocalizableStringSerializer.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILocalizableStringSerializer.cs index 6f7a487b6c..7d068b9494 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILocalizableStringSerializer.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILocalizableStringSerializer.cs @@ -2,7 +2,7 @@ public interface ILocalizableStringSerializer { - string Serialize(ILocalizableString localizableString); + string? Serialize(ILocalizableString localizableString); ILocalizableString Deserialize(string value); } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILocalizationDictionary.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILocalizationDictionary.cs index d5fcab206b..e6879c0007 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILocalizationDictionary.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILocalizationDictionary.cs @@ -10,7 +10,7 @@ public interface ILocalizationDictionary { string CultureName { get; } - LocalizedString GetOrNull(string name); + LocalizedString? GetOrNull(string name); void Fill(Dictionary dictionary); } diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILocalizationResourceContributor.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILocalizationResourceContributor.cs index 2a79d20821..2d3ade519f 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILocalizationResourceContributor.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/ILocalizationResourceContributor.cs @@ -10,7 +10,7 @@ public interface ILocalizationResourceContributor void Initialize(LocalizationResourceInitializationContext context); - LocalizedString GetOrNull(string cultureName, string name); + LocalizedString? GetOrNull(string cultureName, string name); void Fill(string cultureName, Dictionary dictionary); diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/Json/JsonLocalizationDictionaryBuilder.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/Json/JsonLocalizationDictionaryBuilder.cs index 04ec79aaf6..e4b66148a5 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/Json/JsonLocalizationDictionaryBuilder.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/Json/JsonLocalizationDictionaryBuilder.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Text.Json; -using JetBrains.Annotations; using Microsoft.Extensions.Localization; namespace Volo.Abp.Localization.Json; @@ -13,8 +12,7 @@ public static class JsonLocalizationDictionaryBuilder /// Builds an from given file. /// /// Path of the file - [CanBeNull] - public static ILocalizationDictionary BuildFromFile(string filePath) + public static ILocalizationDictionary? BuildFromFile(string filePath) { try { @@ -38,10 +36,9 @@ public static class JsonLocalizationDictionaryBuilder /// Builds an from given json string. /// /// Json string - [CanBeNull] - public static ILocalizationDictionary BuildFromJsonString(string jsonString) + public static ILocalizationDictionary? BuildFromJsonString(string jsonString) { - JsonLocalizationFile jsonFile; + JsonLocalizationFile? jsonFile; try { jsonFile = JsonSerializer.Deserialize(jsonString, DeserializeOptions); @@ -50,6 +47,11 @@ public static class JsonLocalizationDictionaryBuilder { throw new AbpException("Can not parse json string. " + ex.Message); } + + if (jsonFile == null) + { + return null; + } var cultureCode = jsonFile.Culture; if (string.IsNullOrEmpty(cultureCode)) diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/Json/JsonLocalizationFile.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/Json/JsonLocalizationFile.cs index 08daf70682..8470e2696f 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/Json/JsonLocalizationFile.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/Json/JsonLocalizationFile.cs @@ -7,7 +7,7 @@ public class JsonLocalizationFile /// /// Culture name; eg : en , en-us, zh-CN /// - public string Culture { get; set; } + public string Culture { get; set; } = default!; public Dictionary Texts { get; set; } diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LanguageInfo.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LanguageInfo.cs index 9183b89c4e..a2274b5a69 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LanguageInfo.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LanguageInfo.cs @@ -8,19 +8,18 @@ namespace Volo.Abp.Localization; public class LanguageInfo : ILanguageInfo { [NotNull] - public virtual string CultureName { get; protected set; } + public virtual string CultureName { get; protected set; } = default!; [NotNull] - public virtual string UiCultureName { get; protected set; } + public virtual string UiCultureName { get; protected set; } = default!; [NotNull] - public virtual string DisplayName { get; protected set; } + public virtual string DisplayName { get; protected set; } = default!; [NotNull] - public virtual string TwoLetterISOLanguageName { get; protected set; } + public virtual string TwoLetterISOLanguageName { get; protected set; } = default!; - [CanBeNull] - public virtual string FlagIcon { get; set; } + public virtual string? FlagIcon { get; set; } protected LanguageInfo() @@ -30,30 +29,30 @@ public class LanguageInfo : ILanguageInfo public LanguageInfo( string cultureName, - string uiCultureName = null, - string displayName = null, - string flagIcon = null) + string? uiCultureName = null, + string? displayName = null, + string? flagIcon = null) { ChangeCultureInternal(cultureName, uiCultureName, displayName); FlagIcon = flagIcon; } - public virtual void ChangeCulture(string cultureName, string uiCultureName = null, string displayName = null) + public virtual void ChangeCulture(string cultureName, string? uiCultureName = null, string? displayName = null) { ChangeCultureInternal(cultureName, uiCultureName, displayName); } - private void ChangeCultureInternal(string cultureName, string uiCultureName, string displayName) + private void ChangeCultureInternal(string cultureName, string? uiCultureName, string? displayName) { CultureName = Check.NotNullOrWhiteSpace(cultureName, nameof(cultureName)); - UiCultureName = !uiCultureName.IsNullOrWhiteSpace() + UiCultureName = (!uiCultureName.IsNullOrWhiteSpace() ? uiCultureName - : cultureName; + : cultureName)!; - DisplayName = !displayName.IsNullOrWhiteSpace() + DisplayName = (!displayName.IsNullOrWhiteSpace() ? displayName - : cultureName; + : cultureName)!; TwoLetterISOLanguageName = new CultureInfo(cultureName) .TwoLetterISOLanguageName; diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LanguageInfoExtensions.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LanguageInfoExtensions.cs index 8909708b67..7b60cce40d 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LanguageInfoExtensions.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LanguageInfoExtensions.cs @@ -6,10 +6,10 @@ namespace Volo.Abp.Localization; public static class LanguageInfoExtensions { - public static T FindByCulture( + public static T? FindByCulture( [NotNull] this IEnumerable languages, [NotNull] string cultureName, - [CanBeNull] string uiCultureName = null) + string? uiCultureName = null) where T : class, ILanguageInfo { if (uiCultureName == null) diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizableStringSerializer.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizableStringSerializer.cs index 5006d62ea8..02b9cc8fac 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizableStringSerializer.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizableStringSerializer.cs @@ -13,7 +13,7 @@ public class LocalizableStringSerializer : ILocalizableStringSerializer, ITransi LocalizationOptions = localizationOptions.Value; } - public virtual string Serialize(ILocalizableString localizableString) + public virtual string? Serialize(ILocalizableString? localizableString) { if (localizableString == null) { diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResource.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResource.cs index 7a55f1f8a3..b6e0da82e4 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResource.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResource.cs @@ -12,8 +12,8 @@ public class LocalizationResource : LocalizationResourceBase public LocalizationResource( [NotNull] Type resourceType, - [CanBeNull] string defaultCultureName = null, - [CanBeNull] ILocalizationResourceContributor initialContributor = null) + string? defaultCultureName = null, + ILocalizationResourceContributor? initialContributor = null) : base( LocalizationResourceNameAttribute.GetName(resourceType), defaultCultureName, diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceBase.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceBase.cs index a7ec4fb93b..6cbbd98188 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceBase.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceBase.cs @@ -10,16 +10,15 @@ public abstract class LocalizationResourceBase public List BaseResourceNames { get; } - [CanBeNull] - public string DefaultCultureName { get; set; } + public string? DefaultCultureName { get; set; } [NotNull] public LocalizationResourceContributorList Contributors { get; } public LocalizationResourceBase( [NotNull] string resourceName, - [CanBeNull] string defaultCultureName = null, - [CanBeNull] ILocalizationResourceContributor initialContributor = null) + string? defaultCultureName = null, + ILocalizationResourceContributor? initialContributor = null) { ResourceName = Check.NotNullOrWhiteSpace(resourceName, nameof(resourceName)); DefaultCultureName = defaultCultureName; diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceContributorList.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceContributorList.cs index 6df15920da..9f11aa4051 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceContributorList.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceContributorList.cs @@ -7,7 +7,7 @@ namespace Volo.Abp.Localization; public class LocalizationResourceContributorList : List { - public LocalizedString GetOrNull( + public LocalizedString? GetOrNull( string cultureName, string name, bool includeDynamicContributors = true) diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceDictionary.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceDictionary.cs index 4a88eac199..f6487a85b7 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceDictionary.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/LocalizationResourceDictionary.cs @@ -8,12 +8,12 @@ public class LocalizationResourceDictionary : Dictionary _resourcesByTypes = new(); - public LocalizationResource Add([CanBeNull] string defaultCultureName = null) + public LocalizationResource Add(string? defaultCultureName = null) { return Add(typeof(TResouce), defaultCultureName); } - public LocalizationResource Add(Type resourceType, [CanBeNull] string defaultCultureName = null) + public LocalizationResource Add(Type resourceType, string? defaultCultureName = null) { var resourceName = LocalizationResourceNameAttribute.GetName(resourceType); if (ContainsKey(resourceName)) @@ -29,7 +29,7 @@ public class LocalizationResourceDictionary : Dictionary - public virtual LocalizedString GetOrNull(string name) + public virtual LocalizedString? GetOrNull(string name) { return Dictionary.GetOrDefault(name); } diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/VirtualFiles/Json/JsonVirtualFileLocalizationResourceContributor.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/VirtualFiles/Json/JsonVirtualFileLocalizationResourceContributor.cs index fcafed49f3..71ca2744a0 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/VirtualFiles/Json/JsonVirtualFileLocalizationResourceContributor.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/VirtualFiles/Json/JsonVirtualFileLocalizationResourceContributor.cs @@ -19,7 +19,7 @@ public class JsonVirtualFileLocalizationResourceContributor : VirtualFileLocaliz return file.Name.EndsWith(".json", StringComparison.OrdinalIgnoreCase); } - protected override ILocalizationDictionary CreateDictionaryFromFileContent(string jsonString) + protected override ILocalizationDictionary? CreateDictionaryFromFileContent(string jsonString) { return JsonLocalizationDictionaryBuilder.BuildFromJsonString(jsonString); } diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/VirtualFiles/VirtualFileLocalizationResourceContributorBase.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/VirtualFiles/VirtualFileLocalizationResourceContributorBase.cs index 40bb9de7c5..d87169ea31 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/VirtualFiles/VirtualFileLocalizationResourceContributorBase.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/VirtualFiles/VirtualFileLocalizationResourceContributorBase.cs @@ -16,11 +16,11 @@ public abstract class VirtualFileLocalizationResourceContributorBase : ILocaliza public bool IsDynamic => false; private readonly string _virtualPath; - private IVirtualFileProvider _virtualFileProvider; - private Dictionary _dictionaries; + private IVirtualFileProvider _virtualFileProvider = default!; + private Dictionary? _dictionaries; private bool _subscribedForChanges; private readonly object _syncObj = new object(); - private LocalizationResourceBase _resource; + private LocalizationResourceBase _resource = default!; protected VirtualFileLocalizationResourceContributorBase(string virtualPath) { @@ -33,7 +33,7 @@ public abstract class VirtualFileLocalizationResourceContributorBase : ILocaliza _virtualFileProvider = context.ServiceProvider.GetRequiredService(); } - public virtual LocalizedString GetOrNull(string cultureName, string name) + public virtual LocalizedString? GetOrNull(string cultureName, string name) { return GetDictionaries().GetOrDefault(cultureName)?.GetOrNull(name); } @@ -118,8 +118,7 @@ public abstract class VirtualFileLocalizationResourceContributorBase : ILocaliza protected abstract bool CanParseFile(IFileInfo file); - [CanBeNull] - protected virtual ILocalizationDictionary CreateDictionaryFromFile(IFileInfo file) + protected virtual ILocalizationDictionary? CreateDictionaryFromFile(IFileInfo file) { using (var stream = file.CreateReadStream()) { @@ -127,6 +126,5 @@ public abstract class VirtualFileLocalizationResourceContributorBase : ILocaliza } } - [CanBeNull] - protected abstract ILocalizationDictionary CreateDictionaryFromFileContent(string fileContent); + protected abstract ILocalizationDictionary? CreateDictionaryFromFileContent(string fileContent); } From e6d161e0b4f430de840acfd95b4829ebb4c81942 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 6 Jun 2023 17:47:00 +0800 Subject: [PATCH 11/32] Enable nullable annotations for Volo.Abp.Threading --- .../Volo.Abp.Threading.csproj | 2 + .../Volo/Abp/Linq/AsyncQueryableExecuter.cs | 122 ++++++++++++------ .../Volo/Abp/Linq/IAsyncQueryableExecuter.cs | 20 +-- .../Volo/Abp/Linq/IAsyncQueryableProvider.cs | 20 +-- .../Volo/Abp/Threading/AbpAsyncTimer.cs | 2 +- .../Volo/Abp/Threading/AbpTimer.cs | 4 +- .../AmbientDataContextAmbientScopeProvider.cs | 13 +- .../Threading/AsyncLocalAmbientDataContext.cs | 10 +- .../AsyncLocalSimpleScopeExtensions.cs | 4 +- .../CancellationTokenProviderBase.cs | 2 +- .../Volo/Abp/Threading/IAmbientDataContext.cs | 4 +- .../Abp/Threading/IAmbientScopeProvider.cs | 2 +- 12 files changed, 126 insertions(+), 79 deletions(-) diff --git a/framework/src/Volo.Abp.Threading/Volo.Abp.Threading.csproj b/framework/src/Volo.Abp.Threading/Volo.Abp.Threading.csproj index 70f9ecb0f8..2197766f6b 100644 --- a/framework/src/Volo.Abp.Threading/Volo.Abp.Threading.csproj +++ b/framework/src/Volo.Abp.Threading/Volo.Abp.Threading.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Threading Volo.Abp.Threading $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs index b6f4600caf..108d3bb595 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs @@ -17,7 +17,7 @@ public class AsyncQueryableExecuter : IAsyncQueryableExecuter, ISingletonDepende Providers = providers; } - protected virtual IAsyncQueryableProvider FindProvider(IQueryable queryable) + protected virtual IAsyncQueryableProvider? FindProvider(IQueryable queryable) { return Providers.FirstOrDefault(p => p.CanExecute(queryable)); } @@ -102,21 +102,29 @@ public class AsyncQueryableExecuter : IAsyncQueryableExecuter, ISingletonDepende : Task.FromResult(queryable.First(predicate)); } - public Task FirstOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) + public Task FirstOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); - return provider != null - ? provider.FirstOrDefaultAsync(queryable, cancellationToken) - : Task.FromResult(queryable.FirstOrDefault()); + + if (provider != null) + { + return provider.FirstOrDefaultAsync(queryable, cancellationToken); + } + + return Task.FromResult(queryable.FirstOrDefault())!; } - public Task FirstOrDefaultAsync(IQueryable queryable, Expression> predicate, + public Task FirstOrDefaultAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); - return provider != null - ? provider.FirstOrDefaultAsync(queryable, predicate, cancellationToken) - : Task.FromResult(queryable.FirstOrDefault(predicate)); + + if (provider != null) + { + return provider.FirstOrDefaultAsync(queryable, predicate, cancellationToken); + } + + return Task.FromResult(queryable.FirstOrDefault(predicate))!; } public Task LastAsync(IQueryable queryable, CancellationToken cancellationToken = default) @@ -135,21 +143,29 @@ public class AsyncQueryableExecuter : IAsyncQueryableExecuter, ISingletonDepende : Task.FromResult(queryable.Last(predicate)); } - public Task LastOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) + public Task LastOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); - return provider != null - ? provider.LastOrDefaultAsync(queryable, cancellationToken) - : Task.FromResult(queryable.LastOrDefault()); + + if (provider != null) + { + return provider.LastOrDefaultAsync(queryable, cancellationToken); + } + + return Task.FromResult(queryable.LastOrDefault())!; } - public Task LastOrDefaultAsync(IQueryable queryable, Expression> predicate, + public Task LastOrDefaultAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); - return provider != null - ? provider.LastOrDefaultAsync(queryable, predicate, cancellationToken) - : Task.FromResult(queryable.LastOrDefault(predicate)); + + if (provider != null) + { + return provider.LastOrDefaultAsync(queryable, predicate, cancellationToken); + } + + return Task.FromResult(queryable.LastOrDefault(predicate))!; } public Task SingleAsync(IQueryable queryable, CancellationToken cancellationToken = default) @@ -168,53 +184,77 @@ public class AsyncQueryableExecuter : IAsyncQueryableExecuter, ISingletonDepende : Task.FromResult(queryable.Single(predicate)); } - public Task SingleOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) + public Task SingleOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); - return provider != null - ? provider.SingleOrDefaultAsync(queryable, cancellationToken) - : Task.FromResult(queryable.SingleOrDefault()); + + if (provider != null) + { + return provider.SingleOrDefaultAsync(queryable, cancellationToken); + } + + return Task.FromResult(queryable.SingleOrDefault())!; } - public Task SingleOrDefaultAsync(IQueryable queryable, Expression> predicate, + public Task SingleOrDefaultAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); - return provider != null - ? provider.SingleOrDefaultAsync(queryable, predicate, cancellationToken) - : Task.FromResult(queryable.SingleOrDefault(predicate)); + + if (provider != null) + { + return provider.SingleOrDefaultAsync(queryable, predicate, cancellationToken); + } + + return Task.FromResult(queryable.SingleOrDefault(predicate))!; } - public Task MinAsync(IQueryable queryable, CancellationToken cancellationToken = default) + public Task MinAsync(IQueryable queryable, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); - return provider != null - ? provider.MinAsync(queryable, cancellationToken) - : Task.FromResult(queryable.Min()); + + if(provider != null) + { + return provider.MinAsync(queryable, cancellationToken); + } + + return Task.FromResult(queryable.Min())!; } - public Task MinAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + public Task MinAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); - return provider != null - ? provider.MinAsync(queryable, selector, cancellationToken) - : Task.FromResult(queryable.Min(selector)); + + if(provider != null) + { + return provider.MinAsync(queryable, selector, cancellationToken); + } + + return Task.FromResult(queryable.Min(selector))!; } - public Task MaxAsync(IQueryable queryable, CancellationToken cancellationToken = default) + public Task MaxAsync(IQueryable queryable, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); - return provider != null - ? provider.MaxAsync(queryable, cancellationToken) - : Task.FromResult(queryable.Max()); + + if(provider != null) + { + return provider.MaxAsync(queryable, cancellationToken); + } + + return Task.FromResult(queryable.Max())!; } - public Task MaxAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + public Task MaxAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); - return provider != null - ? provider.MaxAsync(queryable, selector, cancellationToken) - : Task.FromResult(queryable.Max(selector)); + + if(provider != null) + { + return provider.MaxAsync(queryable, selector, cancellationToken); + } + + return Task.FromResult(queryable.Max(selector))!; } public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs index 5d1e3cf7d1..2bea6c4604 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs @@ -75,12 +75,12 @@ public interface IAsyncQueryableExecuter CancellationToken cancellationToken = default); - Task FirstOrDefaultAsync( + Task FirstOrDefaultAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task FirstOrDefaultAsync( + Task FirstOrDefaultAsync( [NotNull] IQueryable queryable, [NotNull] Expression> predicate, CancellationToken cancellationToken = default); @@ -100,12 +100,12 @@ public interface IAsyncQueryableExecuter CancellationToken cancellationToken = default); - Task LastOrDefaultAsync( + Task LastOrDefaultAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task LastOrDefaultAsync( + Task LastOrDefaultAsync( [NotNull] IQueryable queryable, [NotNull] Expression> predicate, CancellationToken cancellationToken = default); @@ -124,11 +124,11 @@ public interface IAsyncQueryableExecuter [NotNull] Expression> predicate, CancellationToken cancellationToken = default); - Task SingleOrDefaultAsync( + Task SingleOrDefaultAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task SingleOrDefaultAsync( + Task SingleOrDefaultAsync( [NotNull] IQueryable queryable, [NotNull] Expression> predicate, CancellationToken cancellationToken = default); @@ -137,12 +137,12 @@ public interface IAsyncQueryableExecuter #region Min - Task MinAsync( + Task MinAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task MinAsync( + Task MinAsync( [NotNull] IQueryable queryable, [NotNull] Expression> selector, CancellationToken cancellationToken = default); @@ -151,12 +151,12 @@ public interface IAsyncQueryableExecuter #region Max - Task MaxAsync( + Task MaxAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task MaxAsync( + Task MaxAsync( [NotNull] IQueryable queryable, [NotNull] Expression> selector, CancellationToken cancellationToken = default); diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs index f32153d901..3f38553ac5 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs @@ -77,12 +77,12 @@ public interface IAsyncQueryableProvider CancellationToken cancellationToken = default); - Task FirstOrDefaultAsync( + Task FirstOrDefaultAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task FirstOrDefaultAsync( + Task FirstOrDefaultAsync( [NotNull] IQueryable queryable, [NotNull] Expression> predicate, CancellationToken cancellationToken = default); @@ -102,12 +102,12 @@ public interface IAsyncQueryableProvider CancellationToken cancellationToken = default); - Task LastOrDefaultAsync( + Task LastOrDefaultAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task LastOrDefaultAsync( + Task LastOrDefaultAsync( [NotNull] IQueryable queryable, [NotNull] Expression> predicate, CancellationToken cancellationToken = default); @@ -126,11 +126,11 @@ public interface IAsyncQueryableProvider [NotNull] Expression> predicate, CancellationToken cancellationToken = default); - Task SingleOrDefaultAsync( + Task SingleOrDefaultAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task SingleOrDefaultAsync( + Task SingleOrDefaultAsync( [NotNull] IQueryable queryable, [NotNull] Expression> predicate, CancellationToken cancellationToken = default); @@ -139,12 +139,12 @@ public interface IAsyncQueryableProvider #region Min - Task MinAsync( + Task MinAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task MinAsync( + Task MinAsync( [NotNull] IQueryable queryable, [NotNull] Expression> selector, CancellationToken cancellationToken = default); @@ -153,12 +153,12 @@ public interface IAsyncQueryableProvider #region Max - Task MaxAsync( + Task MaxAsync( [NotNull] IQueryable queryable, CancellationToken cancellationToken = default); - Task MaxAsync( + Task MaxAsync( [NotNull] IQueryable queryable, [NotNull] Expression> selector, CancellationToken cancellationToken = default); diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AbpAsyncTimer.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AbpAsyncTimer.cs index 908b3fa09d..c17861ac21 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AbpAsyncTimer.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AbpAsyncTimer.cs @@ -43,7 +43,7 @@ public class AbpAsyncTimer : ITransientDependency Logger = NullLogger.Instance; _taskTimer = new Timer( - TimerCallBack, + TimerCallBack!, null, Timeout.Infinite, Timeout.Infinite diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AbpTimer.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AbpTimer.cs index a5d7a4bdb8..05e4b14daa 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AbpTimer.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AbpTimer.cs @@ -15,7 +15,7 @@ public class AbpTimer : ITransientDependency /// /// This event is raised periodically according to Period of Timer. /// - public event EventHandler Elapsed; + public event EventHandler Elapsed = default!; /// /// Task period of timer (as milliseconds). @@ -42,7 +42,7 @@ public class AbpTimer : ITransientDependency Logger = NullLogger.Instance; _taskTimer = new Timer( - TimerCallBack, + TimerCallBack!, null, Timeout.Infinite, Timeout.Infinite diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AmbientDataContextAmbientScopeProvider.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AmbientDataContextAmbientScopeProvider.cs index 06b71d16f3..3eabab1390 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AmbientDataContextAmbientScopeProvider.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AmbientDataContextAmbientScopeProvider.cs @@ -24,7 +24,7 @@ public class AmbientDataContextAmbientScopeProvider : IAmbientScopeProvider>.Instance; } - public T GetValue(string contextKey) + public T? GetValue(string contextKey) { var item = GetCurrentItem(contextKey); if (item == null) @@ -52,6 +52,11 @@ public class AmbientDataContextAmbientScopeProvider : IAmbientScopeProvider : IAmbientScopeProvider : IAmbientScopeProvider> AsyncLocalDictionary = new ConcurrentDictionary>(); + private static readonly ConcurrentDictionary> AsyncLocalDictionary = new ConcurrentDictionary>(); - public void SetData(string key, object value) + public void SetData(string key, object? value) { - var asyncLocal = AsyncLocalDictionary.GetOrAdd(key, (k) => new AsyncLocal()); + var asyncLocal = AsyncLocalDictionary.GetOrAdd(key, (k) => new AsyncLocal()); asyncLocal.Value = value; } - public object GetData(string key) + public object? GetData(string key) { - var asyncLocal = AsyncLocalDictionary.GetOrAdd(key, (k) => new AsyncLocal()); + var asyncLocal = AsyncLocalDictionary.GetOrAdd(key, (k) => new AsyncLocal()); return asyncLocal.Value; } } diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AsyncLocalSimpleScopeExtensions.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AsyncLocalSimpleScopeExtensions.cs index 3d353921d9..5ad251f30c 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AsyncLocalSimpleScopeExtensions.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/AsyncLocalSimpleScopeExtensions.cs @@ -5,11 +5,11 @@ namespace Volo.Abp.Threading; public static class AsyncLocalSimpleScopeExtensions { - public static IDisposable SetScoped(this AsyncLocal asyncLocal, T value) + public static IDisposable SetScoped(this AsyncLocal asyncLocal, T value) { var previousValue = asyncLocal.Value; asyncLocal.Value = value; - return new DisposeAction, T>>(static (state) => + return new DisposeAction, T?>>(static (state) => { var (asyncLocal, previousValue) = state; asyncLocal.Value = previousValue; diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/CancellationTokenProviderBase.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/CancellationTokenProviderBase.cs index 7de1270ff0..a713d3a7fd 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/CancellationTokenProviderBase.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/CancellationTokenProviderBase.cs @@ -11,7 +11,7 @@ public abstract class CancellationTokenProviderBase : ICancellationTokenProvider protected IAmbientScopeProvider CancellationTokenOverrideScopeProvider { get; } - protected CancellationTokenOverride OverrideValue => CancellationTokenOverrideScopeProvider.GetValue(CancellationTokenOverrideContextKey); + protected CancellationTokenOverride? OverrideValue => CancellationTokenOverrideScopeProvider.GetValue(CancellationTokenOverrideContextKey); protected CancellationTokenProviderBase(IAmbientScopeProvider cancellationTokenOverrideScopeProvider) { diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/IAmbientDataContext.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/IAmbientDataContext.cs index 78482aba53..ae5a2aeb92 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/IAmbientDataContext.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/IAmbientDataContext.cs @@ -2,7 +2,7 @@ public interface IAmbientDataContext { - void SetData(string key, object value); + void SetData(string key, object? value); - object GetData(string key); + object? GetData(string key); } diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/IAmbientScopeProvider.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/IAmbientScopeProvider.cs index 4f2cd7650c..b65edec931 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/IAmbientScopeProvider.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Threading/IAmbientScopeProvider.cs @@ -4,7 +4,7 @@ namespace Volo.Abp.Threading; public interface IAmbientScopeProvider { - T GetValue(string contextKey); + T? GetValue(string contextKey); IDisposable BeginScope(string contextKey, T value); } From fefbd49f36832701e0df06d48da151d9546c97b8 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 7 Jun 2023 16:35:45 +0800 Subject: [PATCH 12/32] Enable nullable annotations for Volo.Abp.Timing --- framework/src/Volo.Abp.Timing/Volo.Abp.Timing.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.Timing/Volo.Abp.Timing.csproj b/framework/src/Volo.Abp.Timing/Volo.Abp.Timing.csproj index 4ba0547035..67875083a6 100644 --- a/framework/src/Volo.Abp.Timing/Volo.Abp.Timing.csproj +++ b/framework/src/Volo.Abp.Timing/Volo.Abp.Timing.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Timing Volo.Abp.Timing $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; From bd3aa78c46b55ea8e4af5f03c711811ae80c4ebc Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 7 Jun 2023 17:04:05 +0800 Subject: [PATCH 13/32] Enable nullable annotations for Volo.Abp.Validation --- .../Volo.Abp.Validation/Volo.Abp.Validation.csproj | 2 ++ .../DataAnnotationObjectValidationContributor.cs | 2 +- .../DefaultAttributeValidationResultProvider.cs | 2 +- .../Validation/IAttributeValidationResultProvider.cs | 2 +- .../Volo/Abp/Validation/IObjectValidator.cs | 4 ++-- .../Volo/Abp/Validation/ObjectValidator.cs | 4 ++-- .../StringValues/AlwaysValidValueValidator.cs | 2 +- .../Validation/StringValues/BooleanValueValidator.cs | 2 +- .../Abp/Validation/StringValues/IStringValueType.cs | 5 ++--- .../Abp/Validation/StringValues/IValueValidator.cs | 7 +++---- .../LocalizableSelectionStringValueItem.cs | 4 ++-- .../Validation/StringValues/NumericValueValidator.cs | 2 +- .../StringValues/SelectionStringValueType.cs | 2 +- .../Validation/StringValues/StringValueTypeBase.cs | 6 +++--- .../Validation/StringValues/StringValueValidator.cs | 12 +++++------- .../Validation/StringValues/ValueValidatorBase.cs | 8 ++++---- 16 files changed, 32 insertions(+), 34 deletions(-) diff --git a/framework/src/Volo.Abp.Validation/Volo.Abp.Validation.csproj b/framework/src/Volo.Abp.Validation/Volo.Abp.Validation.csproj index b8f10667a2..d56374024d 100644 --- a/framework/src/Volo.Abp.Validation/Volo.Abp.Validation.csproj +++ b/framework/src/Volo.Abp.Validation/Volo.Abp.Validation.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Validation Volo.Abp.Validation $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/DataAnnotationObjectValidationContributor.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/DataAnnotationObjectValidationContributor.cs index 8119e71271..90afe4d60e 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/DataAnnotationObjectValidationContributor.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/DataAnnotationObjectValidationContributor.cs @@ -33,7 +33,7 @@ public class DataAnnotationObjectValidationContributor : IObjectValidationContri return Task.CompletedTask; } - protected virtual void ValidateObjectRecursively(List errors, object validatingObject, int currentDepth) + protected virtual void ValidateObjectRecursively(List errors, object? validatingObject, int currentDepth) { if (currentDepth > MaxRecursiveParameterValidationDepth) { diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/DefaultAttributeValidationResultProvider.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/DefaultAttributeValidationResultProvider.cs index feb8db8184..ced3615d04 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/DefaultAttributeValidationResultProvider.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/DefaultAttributeValidationResultProvider.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.Validation; public class DefaultAttributeValidationResultProvider : IAttributeValidationResultProvider, ITransientDependency { - public virtual ValidationResult GetOrDefault(ValidationAttribute validationAttribute, object validatingObject, ValidationContext validationContext) + public virtual ValidationResult? GetOrDefault(ValidationAttribute validationAttribute, object? validatingObject, ValidationContext validationContext) { return validationAttribute.GetValidationResult(validatingObject, validationContext); } diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/IAttributeValidationResultProvider.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/IAttributeValidationResultProvider.cs index 737dbac508..5cc919b967 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/IAttributeValidationResultProvider.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/IAttributeValidationResultProvider.cs @@ -4,5 +4,5 @@ namespace Volo.Abp.Validation; public interface IAttributeValidationResultProvider { - ValidationResult GetOrDefault(ValidationAttribute validationAttribute, object validatingObject, ValidationContext validationContext); + ValidationResult? GetOrDefault(ValidationAttribute validationAttribute, object? validatingObject, ValidationContext validationContext); } diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/IObjectValidator.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/IObjectValidator.cs index 57d60b0f8e..51cff66c10 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/IObjectValidator.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/IObjectValidator.cs @@ -8,13 +8,13 @@ public interface IObjectValidator { Task ValidateAsync( object validatingObject, - string name = null, + string? name = null, bool allowNull = false ); Task> GetErrorsAsync( object validatingObject, - string name = null, + string? name = null, bool allowNull = false ); } diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/ObjectValidator.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/ObjectValidator.cs index 83dd17521f..dd3ff2f395 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/ObjectValidator.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/ObjectValidator.cs @@ -19,7 +19,7 @@ public class ObjectValidator : IObjectValidator, ITransientDependency Options = options.Value; } - public virtual async Task ValidateAsync(object validatingObject, string name = null, bool allowNull = false) + public virtual async Task ValidateAsync(object validatingObject, string? name = null, bool allowNull = false) { var errors = await GetErrorsAsync(validatingObject, name, allowNull); @@ -32,7 +32,7 @@ public class ObjectValidator : IObjectValidator, ITransientDependency } } - public virtual async Task> GetErrorsAsync(object validatingObject, string name = null, bool allowNull = false) + public virtual async Task> GetErrorsAsync(object validatingObject, string? name = null, bool allowNull = false) { if (validatingObject == null) { diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/AlwaysValidValueValidator.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/AlwaysValidValueValidator.cs index e986124fd9..1aad057983 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/AlwaysValidValueValidator.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/AlwaysValidValueValidator.cs @@ -6,7 +6,7 @@ namespace Volo.Abp.Validation.StringValues; [ValueValidator("NULL")] public class AlwaysValidValueValidator : ValueValidatorBase { - public override bool IsValid(object value) + public override bool IsValid(object? value) { return true; } diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/BooleanValueValidator.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/BooleanValueValidator.cs index 3330b2bd49..5328cc8590 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/BooleanValueValidator.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/BooleanValueValidator.cs @@ -6,7 +6,7 @@ namespace Volo.Abp.Validation.StringValues; [ValueValidator("BOOLEAN")] public class BooleanValueValidator : ValueValidatorBase { - public override bool IsValid(object value) + public override bool IsValid(object? value) { if (value == null) { diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/IStringValueType.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/IStringValueType.cs index 6cddb0701c..94493fd2b4 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/IStringValueType.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/IStringValueType.cs @@ -7,11 +7,10 @@ public interface IStringValueType { string Name { get; } - [CanBeNull] - object this[string key] { get; set; } + object? this[string key] { get; set; } [NotNull] - Dictionary Properties { get; } + Dictionary Properties { get; } IValueValidator Validator { get; set; } } diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/IValueValidator.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/IValueValidator.cs index c449ed891e..6095f6ecc4 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/IValueValidator.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/IValueValidator.cs @@ -7,11 +7,10 @@ public interface IValueValidator { string Name { get; } - [CanBeNull] - object this[string key] { get; set; } + object? this[string key] { get; set; } [NotNull] - IDictionary Properties { get; } + IDictionary Properties { get; } - bool IsValid(object value); + bool IsValid(object? value); } diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/LocalizableSelectionStringValueItem.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/LocalizableSelectionStringValueItem.cs index e01b7ee69b..753b4a8df0 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/LocalizableSelectionStringValueItem.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/LocalizableSelectionStringValueItem.cs @@ -2,7 +2,7 @@ public class LocalizableSelectionStringValueItem : ISelectionStringValueItem { - public string Value { get; set; } + public string Value { get; set; } = default!; - public LocalizableStringInfo DisplayText { get; set; } + public LocalizableStringInfo DisplayText { get; set; } = default!; } diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/NumericValueValidator.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/NumericValueValidator.cs index 213327f884..e665301247 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/NumericValueValidator.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/NumericValueValidator.cs @@ -28,7 +28,7 @@ public class NumericValueValidator : ValueValidatorBase MaxValue = maxValue; } - public override bool IsValid(object value) + public override bool IsValid(object? value) { if (value == null) { diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/SelectionStringValueType.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/SelectionStringValueType.cs index 50fd401f00..92145ac764 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/SelectionStringValueType.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/SelectionStringValueType.cs @@ -6,7 +6,7 @@ namespace Volo.Abp.Validation.StringValues; [StringValueType("SELECTION")] public class SelectionStringValueType : StringValueTypeBase { - public ISelectionStringValueItemSource ItemSource { get; set; } + public ISelectionStringValueItemSource ItemSource { get; set; } = default!; public SelectionStringValueType() { diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/StringValueTypeBase.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/StringValueTypeBase.cs index 2700b691f1..4e4f44b1d7 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/StringValueTypeBase.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/StringValueTypeBase.cs @@ -8,12 +8,12 @@ public abstract class StringValueTypeBase : IStringValueType { public virtual string Name => ValueValidatorAttribute.GetName(GetType()); - public object this[string key] { + public object? this[string key] { get => Properties.GetOrDefault(key); set => Properties[key] = value; } - public Dictionary Properties { get; } + public Dictionary Properties { get; } public IValueValidator Validator { get; set; } @@ -26,6 +26,6 @@ public abstract class StringValueTypeBase : IStringValueType protected StringValueTypeBase(IValueValidator validator) { Validator = validator; - Properties = new Dictionary(); + Properties = new Dictionary(); } } diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/StringValueValidator.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/StringValueValidator.cs index 4b2cea9b67..3b3318719a 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/StringValueValidator.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/StringValueValidator.cs @@ -22,7 +22,7 @@ public class StringValueValidator : ValueValidatorBase set => this["MaxLength"] = value; } - public string RegularExpression { + public string? RegularExpression { get => this["RegularExpression"] as string; set => this["RegularExpression"] = value; } @@ -32,7 +32,7 @@ public class StringValueValidator : ValueValidatorBase } - public StringValueValidator(int minLength = 0, int maxLength = 0, string regularExpression = null, bool allowNull = false) + public StringValueValidator(int minLength = 0, int maxLength = 0, string? regularExpression = null, bool allowNull = false) { MinLength = minLength; MaxLength = maxLength; @@ -40,20 +40,18 @@ public class StringValueValidator : ValueValidatorBase AllowNull = allowNull; } - public override bool IsValid(object value) + public override bool IsValid(object? value) { if (value == null) { return AllowNull; } - if (!(value is string)) + if (!(value is string strValue)) { return false; } - var strValue = value as string; - if (MinLength > 0 && strValue.Length < MinLength) { return false; @@ -66,7 +64,7 @@ public class StringValueValidator : ValueValidatorBase if (!RegularExpression.IsNullOrEmpty()) { - return Regex.IsMatch(strValue, RegularExpression); + return Regex.IsMatch(strValue, RegularExpression!); } return true; diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/ValueValidatorBase.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/ValueValidatorBase.cs index 4537562301..5befa8ce7c 100644 --- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/ValueValidatorBase.cs +++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/StringValues/ValueValidatorBase.cs @@ -8,17 +8,17 @@ public abstract class ValueValidatorBase : IValueValidator { public virtual string Name => ValueValidatorAttribute.GetName(GetType()); - public object this[string key] { + public object? this[string key] { get => Properties.GetOrDefault(key); set => Properties[key] = value; } - public IDictionary Properties { get; } + public IDictionary Properties { get; } protected ValueValidatorBase() { - Properties = new Dictionary(); + Properties = new Dictionary(); } - public abstract bool IsValid(object value); + public abstract bool IsValid(object? value); } From 0c09f79116c6199b2538fffc11cc8a7cbc7d993f Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 7 Jun 2023 17:22:29 +0800 Subject: [PATCH 14/32] Enable nullable annotations for Volo.Abp.Guids --- framework/src/Volo.Abp.Guids/Volo.Abp.Guids.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.Guids/Volo.Abp.Guids.csproj b/framework/src/Volo.Abp.Guids/Volo.Abp.Guids.csproj index ed4e0af802..6aae43ce2a 100644 --- a/framework/src/Volo.Abp.Guids/Volo.Abp.Guids.csproj +++ b/framework/src/Volo.Abp.Guids/Volo.Abp.Guids.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Guids Volo.Abp.Guids $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; From 87a3e835dc471c9c8ceb15ac48b6a8d907232256 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 7 Jun 2023 17:47:14 +0800 Subject: [PATCH 15/32] Enable nullable annotations for Volo.Abp.ExceptionHanding --- .../Volo.Abp.ExceptionHandling.csproj | 2 ++ .../DefaultExceptionToErrorInfoConverter.cs | 24 ++++++++----------- .../IExceptionToErrorInfoConverter.cs | 2 +- .../Entities/EntityNotFoundException.cs | 8 +++---- .../Abp/Http/Client/AbpRemoteCallException.cs | 10 ++++---- .../Volo/Abp/Http/RemoteServiceErrorInfo.cs | 12 +++++----- .../Http/RemoteServiceValidationErrorInfo.cs | 4 ++-- 7 files changed, 30 insertions(+), 32 deletions(-) diff --git a/framework/src/Volo.Abp.ExceptionHandling/Volo.Abp.ExceptionHandling.csproj b/framework/src/Volo.Abp.ExceptionHandling/Volo.Abp.ExceptionHandling.csproj index 96c708d6c6..142b143632 100644 --- a/framework/src/Volo.Abp.ExceptionHandling/Volo.Abp.ExceptionHandling.csproj +++ b/framework/src/Volo.Abp.ExceptionHandling/Volo.Abp.ExceptionHandling.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable true diff --git a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs index 1b8742af81..b068890b97 100644 --- a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs +++ b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs @@ -54,7 +54,7 @@ public class DefaultExceptionToErrorInfoConverter : IExceptionToErrorInfoConvert return errorInfo; } - public RemoteServiceErrorInfo Convert(Exception exception, Action options = null) + public RemoteServiceErrorInfo Convert(Exception exception, Action? options = null) { var exceptionHandlingOptions = CreateDefaultOptions(); options?.Invoke(exceptionHandlingOptions); @@ -90,7 +90,7 @@ public class DefaultExceptionToErrorInfoConverter : IExceptionToErrorInfoConvert if (exception is EntityNotFoundException) { - return CreateEntityNotFoundError(exception as EntityNotFoundException); + return CreateEntityNotFoundError((exception as EntityNotFoundException)!); } var errorInfo = new RemoteServiceErrorInfo(); @@ -110,10 +110,10 @@ public class DefaultExceptionToErrorInfoConverter : IExceptionToErrorInfoConvert if (errorInfo.Details.IsNullOrEmpty()) { - errorInfo.Details = GetValidationErrorNarrative(exception as IHasValidationErrors); + errorInfo.Details = GetValidationErrorNarrative((exception as IHasValidationErrors)!); } - errorInfo.ValidationErrors = GetValidationErrorInfos(exception as IHasValidationErrors); + errorInfo.ValidationErrors = GetValidationErrorInfos((exception as IHasValidationErrors)!); } TryToLocalizeExceptionMessage(exception, errorInfo); @@ -146,7 +146,7 @@ public class DefaultExceptionToErrorInfoConverter : IExceptionToErrorInfoConvert } if (exceptionWithErrorCode.Code.IsNullOrWhiteSpace() || - !exceptionWithErrorCode.Code.Contains(":")) + !exceptionWithErrorCode.Code!.Contains(":")) { return; } @@ -197,10 +197,8 @@ public class DefaultExceptionToErrorInfoConverter : IExceptionToErrorInfoConvert protected virtual Exception TryToGetActualException(Exception exception) { - if (exception is AggregateException && exception.InnerException != null) + if (exception is AggregateException aggException && aggException.InnerException != null) { - var aggException = exception as AggregateException; - if (aggException.InnerException is AbpValidationException || aggException.InnerException is AbpAuthorizationException || aggException.InnerException is EntityNotFoundException || @@ -223,7 +221,7 @@ public class DefaultExceptionToErrorInfoConverter : IExceptionToErrorInfoConvert if (exception is AbpValidationException) { - errorInfo.ValidationErrors = GetValidationErrorInfos(exception as AbpValidationException); + errorInfo.ValidationErrors = GetValidationErrorInfos((exception as AbpValidationException)!); } return errorInfo; @@ -246,9 +244,8 @@ public class DefaultExceptionToErrorInfoConverter : IExceptionToErrorInfoConvert } //Additional info for AbpValidationException - if (exception is AbpValidationException) + if (exception is AbpValidationException validationException) { - var validationException = exception as AbpValidationException; if (validationException.ValidationErrors.Count > 0) { detailBuilder.AppendLine(GetValidationErrorNarrative(validationException)); @@ -268,9 +265,8 @@ public class DefaultExceptionToErrorInfoConverter : IExceptionToErrorInfoConvert } //Inner exceptions for AggregateException - if (exception is AggregateException) + if (exception is AggregateException aggException) { - var aggException = exception as AggregateException; if (aggException.InnerExceptions.IsNullOrEmpty()) { return; @@ -289,7 +285,7 @@ public class DefaultExceptionToErrorInfoConverter : IExceptionToErrorInfoConvert foreach (var validationResult in validationException.ValidationErrors) { - var validationError = new RemoteServiceValidationErrorInfo(validationResult.ErrorMessage); + var validationError = new RemoteServiceValidationErrorInfo(validationResult.ErrorMessage!); if (validationResult.MemberNames != null && validationResult.MemberNames.Any()) { diff --git a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/IExceptionToErrorInfoConverter.cs b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/IExceptionToErrorInfoConverter.cs index ebf8993bd6..bd14010db0 100644 --- a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/IExceptionToErrorInfoConverter.cs +++ b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/IExceptionToErrorInfoConverter.cs @@ -24,5 +24,5 @@ public interface IExceptionToErrorInfoConverter /// The exception. /// Additional options. /// Error info or null - RemoteServiceErrorInfo Convert(Exception exception, Action options = null); + RemoteServiceErrorInfo Convert(Exception exception, Action? options = null); } diff --git a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Domain/Entities/EntityNotFoundException.cs b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Domain/Entities/EntityNotFoundException.cs index 1feb8c4cbb..5f524f9578 100644 --- a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Domain/Entities/EntityNotFoundException.cs +++ b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Domain/Entities/EntityNotFoundException.cs @@ -10,12 +10,12 @@ public class EntityNotFoundException : AbpException /// /// Type of the entity. /// - public Type EntityType { get; set; } + public Type? EntityType { get; set; } /// /// Id of the Entity. /// - public object Id { get; set; } + public object? Id { get; set; } /// /// Creates a new object. @@ -37,7 +37,7 @@ public class EntityNotFoundException : AbpException /// /// Creates a new object. /// - public EntityNotFoundException(Type entityType, object id) + public EntityNotFoundException(Type entityType, object? id) : this(entityType, id, null) { @@ -46,7 +46,7 @@ public class EntityNotFoundException : AbpException /// /// Creates a new object. /// - public EntityNotFoundException(Type entityType, object id, Exception innerException) + public EntityNotFoundException(Type entityType, object? id, Exception? innerException) : base( id == null ? $"There is no such an entity given id. Entity type: {entityType.FullName}" diff --git a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/Client/AbpRemoteCallException.cs b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/Client/AbpRemoteCallException.cs index 78c5bff6f9..887c8fb081 100644 --- a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/Client/AbpRemoteCallException.cs +++ b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/Client/AbpRemoteCallException.cs @@ -9,18 +9,18 @@ public class AbpRemoteCallException : AbpException, IHasErrorCode, IHasErrorDeta { public int HttpStatusCode { get; set; } - public string Code => Error?.Code; + public string? Code => Error?.Code; - public string Details => Error?.Details; + public string? Details => Error?.Details; - public RemoteServiceErrorInfo Error { get; set; } + public RemoteServiceErrorInfo? Error { get; set; } public AbpRemoteCallException() { } - public AbpRemoteCallException(string message, Exception innerException = null) + public AbpRemoteCallException(string message, Exception? innerException = null) : base(message, innerException) { @@ -32,7 +32,7 @@ public class AbpRemoteCallException : AbpException, IHasErrorCode, IHasErrorDeta } - public AbpRemoteCallException(RemoteServiceErrorInfo error, Exception innerException = null) + public AbpRemoteCallException(RemoteServiceErrorInfo error, Exception? innerException = null) : base(error.Message, innerException) { Error = error; diff --git a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/RemoteServiceErrorInfo.cs b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/RemoteServiceErrorInfo.cs index 89ed87454a..e61d55e2d3 100644 --- a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/RemoteServiceErrorInfo.cs +++ b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/RemoteServiceErrorInfo.cs @@ -12,27 +12,27 @@ public class RemoteServiceErrorInfo /// /// Error code. /// - public string Code { get; set; } + public string? Code { get; set; } /// /// Error message. /// - public string Message { get; set; } + public string? Message { get; set; } /// /// Error details. /// - public string Details { get; set; } + public string? Details { get; set; } /// /// Error data. /// - public IDictionary Data { get; set; } + public IDictionary? Data { get; set; } /// /// Validation errors if exists. /// - public RemoteServiceValidationErrorInfo[] ValidationErrors { get; set; } + public RemoteServiceValidationErrorInfo[]? ValidationErrors { get; set; } /// /// Creates a new instance of . @@ -49,7 +49,7 @@ public class RemoteServiceErrorInfo /// Error details /// Error message /// Error data - public RemoteServiceErrorInfo(string message, string details = null, string code = null, IDictionary data = null) + public RemoteServiceErrorInfo(string message, string? details = null, string? code = null, IDictionary? data = null) { Message = message; Details = details; diff --git a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/RemoteServiceValidationErrorInfo.cs b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/RemoteServiceValidationErrorInfo.cs index 4b86bbf4e3..64a31d7041 100644 --- a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/RemoteServiceValidationErrorInfo.cs +++ b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/Http/RemoteServiceValidationErrorInfo.cs @@ -11,12 +11,12 @@ public class RemoteServiceValidationErrorInfo /// /// Validation error message. /// - public string Message { get; set; } + public string Message { get; set; } = default!; /// /// Relate invalid members (fields/properties). /// - public string[] Members { get; set; } + public string[] Members { get; set; } = default!; /// /// Creates a new instance of . From 02c74b9660989dccdddab1d79ecf0633288d85dc Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 28 Jun 2023 15:03:51 +0800 Subject: [PATCH 16/32] Enable nullable annotations for Volo.Abp.UI --- .../Volo/Abp/Data/AppliedDatabaseMigrationsEto.cs | 2 +- framework/src/Volo.Abp.UI/Volo.Abp.UI.csproj | 2 ++ .../Volo/Abp/Ui/Branding/DefaultBrandingProvider.cs | 4 ++-- .../src/Volo.Abp.UI/Volo/Abp/Ui/Branding/IBrandingProvider.cs | 4 ++-- .../Volo/Abp/Ui/LayoutHooks/AbpLayoutHookOptions.cs | 2 +- .../src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/LayoutHookInfo.cs | 4 ++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AppliedDatabaseMigrationsEto.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AppliedDatabaseMigrationsEto.cs index 739571e241..53fae25737 100644 --- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AppliedDatabaseMigrationsEto.cs +++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AppliedDatabaseMigrationsEto.cs @@ -7,6 +7,6 @@ namespace Volo.Abp.Data; [EventName("abp.data.applied_database_migrations")] public class AppliedDatabaseMigrationsEto { - public string DatabaseName { get; set; } + public string DatabaseName { get; set; } = default!; public Guid? TenantId { get; set; } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.UI/Volo.Abp.UI.csproj b/framework/src/Volo.Abp.UI/Volo.Abp.UI.csproj index 0cf11fba78..b0bd555c96 100644 --- a/framework/src/Volo.Abp.UI/Volo.Abp.UI.csproj +++ b/framework/src/Volo.Abp.UI/Volo.Abp.UI.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.UI Volo.Abp.UI $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.UI/Volo/Abp/Ui/Branding/DefaultBrandingProvider.cs b/framework/src/Volo.Abp.UI/Volo/Abp/Ui/Branding/DefaultBrandingProvider.cs index 785c03a0e1..fcb1a7545e 100644 --- a/framework/src/Volo.Abp.UI/Volo/Abp/Ui/Branding/DefaultBrandingProvider.cs +++ b/framework/src/Volo.Abp.UI/Volo/Abp/Ui/Branding/DefaultBrandingProvider.cs @@ -6,7 +6,7 @@ public class DefaultBrandingProvider : IBrandingProvider, ITransientDependency { public virtual string AppName => "MyApplication"; - public virtual string LogoUrl => null; + public virtual string? LogoUrl => null; - public virtual string LogoReverseUrl => null; + public virtual string? LogoReverseUrl => null; } diff --git a/framework/src/Volo.Abp.UI/Volo/Abp/Ui/Branding/IBrandingProvider.cs b/framework/src/Volo.Abp.UI/Volo/Abp/Ui/Branding/IBrandingProvider.cs index 95085f56a6..f37ee09df1 100644 --- a/framework/src/Volo.Abp.UI/Volo/Abp/Ui/Branding/IBrandingProvider.cs +++ b/framework/src/Volo.Abp.UI/Volo/Abp/Ui/Branding/IBrandingProvider.cs @@ -7,10 +7,10 @@ public interface IBrandingProvider /// /// Logo on white background /// - string LogoUrl { get; } + string? LogoUrl { get; } /// /// Logo on dark background /// - string LogoReverseUrl { get; } + string? LogoReverseUrl { get; } } diff --git a/framework/src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/AbpLayoutHookOptions.cs b/framework/src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/AbpLayoutHookOptions.cs index d5ba4aa239..b76e713a8e 100644 --- a/framework/src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/AbpLayoutHookOptions.cs +++ b/framework/src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/AbpLayoutHookOptions.cs @@ -12,7 +12,7 @@ public class AbpLayoutHookOptions Hooks = new Dictionary>(); } - public AbpLayoutHookOptions Add(string name, Type componentType, string layout = null) + public AbpLayoutHookOptions Add(string name, Type componentType, string? layout = null) { Hooks .GetOrAdd(name, () => new List()) diff --git a/framework/src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/LayoutHookInfo.cs b/framework/src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/LayoutHookInfo.cs index db4ca39466..bb5c8e4801 100644 --- a/framework/src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/LayoutHookInfo.cs +++ b/framework/src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/LayoutHookInfo.cs @@ -13,9 +13,9 @@ public class LayoutHookInfo /// Specifies the layout name to apply this hook. /// null indicates that this hook will be applied to all layouts. /// - public string Layout { get; } + public string? Layout { get; } - public LayoutHookInfo(Type componentType, string layout = null) + public LayoutHookInfo(Type componentType, string? layout = null) { ComponentType = componentType; Layout = layout; From cee5f22bb8336c860013ffd5884fde2d976a4c3d Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 28 Jun 2023 15:26:43 +0800 Subject: [PATCH 17/32] Enable nullable annotations for Volo.Abp.UI.Navigation --- .../Volo.Abp.UI.Navigation.csproj | 2 + .../Volo/Abp/Ui/Navigation/ApplicationMenu.cs | 4 +- .../Navigation/ApplicationMenuExtensions.cs | 6 +-- .../Abp/Ui/Navigation/ApplicationMenuGroup.cs | 12 +++--- .../Abp/Ui/Navigation/ApplicationMenuItem.cs | 38 +++++++++---------- .../Ui/Navigation/HasMenuItemsExtensions.cs | 3 +- .../Ui/Navigation/MenuConfigurationContext.cs | 3 +- .../Volo/Abp/Ui/Navigation/MenuManager.cs | 2 +- .../Abp/Ui/Navigation/Urls/AppUrlProvider.cs | 14 +++---- .../Ui/Navigation/Urls/ApplicationUrlInfo.cs | 2 +- .../Abp/Ui/Navigation/Urls/IAppUrlProvider.cs | 4 +- 11 files changed, 42 insertions(+), 48 deletions(-) diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo.Abp.UI.Navigation.csproj b/framework/src/Volo.Abp.UI.Navigation/Volo.Abp.UI.Navigation.csproj index 65b07f1579..e23d96950e 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo.Abp.UI.Navigation.csproj +++ b/framework/src/Volo.Abp.UI.Navigation/Volo.Abp.UI.Navigation.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.UI.Navigation Volo.Abp.UI.Navigation $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenu.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenu.cs index 9f48aebf97..d38279b1cd 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenu.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenu.cs @@ -26,7 +26,7 @@ public class ApplicationMenu : IHasMenuItems, IHasMenuGroups _displayName = value; } } - private string _displayName; + private string _displayName = default!; /// [NotNull] @@ -44,7 +44,7 @@ public class ApplicationMenu : IHasMenuItems, IHasMenuGroups public ApplicationMenu( [NotNull] string name, - string displayName = null) + string? displayName = null) { Check.NotNullOrWhiteSpace(name, nameof(name)); diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs index 624abde425..59814ff3be 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs @@ -29,8 +29,7 @@ public static class ApplicationMenuExtensions return menuItem; } - [CanBeNull] - public static ApplicationMenuItem GetMenuItemOrNull( + public static ApplicationMenuItem? GetMenuItemOrNull( [NotNull] this IHasMenuItems menuWithItems, string menuItemName) { @@ -79,8 +78,7 @@ public static class ApplicationMenuExtensions return menuGroup; } - [CanBeNull] - public static ApplicationMenuGroup GetMenuGroupOrNull( + public static ApplicationMenuGroup? GetMenuGroupOrNull( [NotNull] this IHasMenuGroups menuWithGroups, string menuGroupName) { diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuGroup.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuGroup.cs index 8d29e99552..ab76c1c337 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuGroup.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuGroup.cs @@ -4,8 +4,8 @@ namespace Volo.Abp.UI.Navigation; public class ApplicationMenuGroup { - private string _displayName; - private string _elementId; + private string _displayName = default!; + private string? _elementId; /// /// Default value of a group item. @@ -33,7 +33,7 @@ public class ApplicationMenuGroup /// /// Can be used to render the element with a specific Id for DOM selections. /// - public string ElementId { + public string? ElementId { get { return _elementId; } set { _elementId = NormalizeElementId(value); @@ -49,7 +49,7 @@ public class ApplicationMenuGroup public ApplicationMenuGroup( [NotNull] string name, [NotNull] string displayName, - string elementId = null, + string? elementId = null, int order = DefaultOrder) { Check.NotNullOrWhiteSpace(name, nameof(name)); @@ -57,7 +57,7 @@ public class ApplicationMenuGroup Name = name; DisplayName = displayName; - ElementId = elementId; + ElementId = elementId ?? GetDefaultElementId(); Order = order; } @@ -66,7 +66,7 @@ public class ApplicationMenuGroup return "MenuGroup_" + Name; } - private string NormalizeElementId(string elementId) + private string? NormalizeElementId(string? elementId) { return elementId?.Replace(".", "_"); } diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs index 54bd591469..0c42a15c5e 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs @@ -7,8 +7,8 @@ namespace Volo.Abp.UI.Navigation; public class ApplicationMenuItem : IHasMenuItems, IHasSimpleStateCheckers { - private string _displayName; - private string _elementId; + private string _displayName = default!; + private string? _elementId; /// /// Default value of a menu item. @@ -42,14 +42,12 @@ public class ApplicationMenuItem : IHasMenuItems, IHasSimpleStateCheckers /// The URL to navigate when this menu item is selected. /// - [CanBeNull] - public string Url { get; set; } + public string? Url { get; set; } /// /// Icon of the menu item if exists. /// - [CanBeNull] - public string Icon { get; set; } + public string? Icon { get; set; } /// /// Returns true if this menu item has no child . @@ -59,8 +57,7 @@ public class ApplicationMenuItem : IHasMenuItems, IHasSimpleStateCheckers /// Target of the menu item. Can be null, "_blank", "_self", "_parent", "_top" or a frame name for web applications. /// - [CanBeNull] - public string Target { get; set; } + public string? Target { get; set; } /// /// Can be used to disable this menu item. @@ -71,9 +68,8 @@ public class ApplicationMenuItem : IHasMenuItems, IHasSimpleStateCheckers> StateCheckers { get; } @@ -86,7 +82,7 @@ public class ApplicationMenuItem : IHasMenuItems, IHasSimpleStateCheckers /// Can be used to render the element with a specific Id for DOM selections. /// - public string ElementId { + public string? ElementId { get { return _elementId; } set { _elementId = NormalizeElementId(value); @@ -96,24 +92,24 @@ public class ApplicationMenuItem : IHasMenuItems, IHasSimpleStateCheckers /// Can be used to render the element with extra CSS classes. /// - public string CssClass { get; set; } + public string? CssClass { get; set; } /// /// Can be used to group menu items. /// - public string GroupName { get; set; } + public string? GroupName { get; set; } public ApplicationMenuItem( [NotNull] string name, [NotNull] string displayName, - string url = null, - string icon = null, + string? url = null, + string? icon = null, int order = DefaultOrder, - string target = null, - string elementId = null, - string cssClass = null, - string groupName = null, - string requiredPermissionName = null) + string? target = null, + string? elementId = null, + string? cssClass = null, + string? groupName = null, + string? requiredPermissionName = null) { Check.NotNullOrWhiteSpace(name, nameof(name)); Check.NotNullOrWhiteSpace(displayName, nameof(displayName)); @@ -158,7 +154,7 @@ public class ApplicationMenuItem : IHasMenuItems, IHasSimpleStateCheckers !x.GroupName.IsNullOrWhiteSpace()).GroupBy(x => x.GroupName)) { - var group = applicationMenu.GetMenuGroupOrNull(menuGroup.First().GroupName); + var group = applicationMenu.GetMenuGroupOrNull(menuGroup.First().GroupName!); if (group != null) { continue; diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/AppUrlProvider.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/AppUrlProvider.cs index ff1db3a772..17a4e684e9 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/AppUrlProvider.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/AppUrlProvider.cs @@ -33,7 +33,7 @@ public class AppUrlProvider : IAppUrlProvider, ITransientDependency Logger = NullLogger.Instance; } - public virtual async Task GetUrlAsync(string appName, string urlName = null) + public virtual async Task GetUrlAsync(string appName, string? urlName = null) { return await ReplacePlaceHoldersAsync( await GetConfiguredUrl( @@ -53,12 +53,12 @@ public class AppUrlProvider : IAppUrlProvider, ITransientDependency return allow; } - protected virtual async Task GetConfiguredUrl(string appName, string urlName) + protected virtual async Task GetConfiguredUrl(string appName, string? urlName) { var url = await GetUrlOrNullAsync(appName, urlName); if (!url.IsNullOrEmpty()) { - return url; + return url!; } if (!urlName.IsNullOrEmpty()) @@ -115,10 +115,10 @@ public class AppUrlProvider : IAppUrlProvider, ITransientDependency return tenantConfiguration.Name; } - return CurrentTenant.Name; + return CurrentTenant.Name!; } - public Task GetUrlOrNullAsync([NotNull] string appName, [CanBeNull] string urlName = null) + public Task GetUrlOrNullAsync([NotNull] string appName, string? urlName = null) { var app = Options.Applications[appName]; @@ -127,13 +127,13 @@ public class AppUrlProvider : IAppUrlProvider, ITransientDependency return Task.FromResult(app.RootUrl); } - var url = app.Urls.GetOrDefault(urlName); + var url = app.Urls.GetOrDefault(urlName!); if (app.RootUrl == null) { return Task.FromResult(url); } - return Task.FromResult(app.RootUrl.EnsureEndsWith('/') + url); + return Task.FromResult(app.RootUrl.EnsureEndsWith('/') + url); } } diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/ApplicationUrlInfo.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/ApplicationUrlInfo.cs index 3e57fadcae..0e00c8039c 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/ApplicationUrlInfo.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/ApplicationUrlInfo.cs @@ -4,7 +4,7 @@ namespace Volo.Abp.UI.Navigation.Urls; public class ApplicationUrlInfo { - public string RootUrl { get; set; } + public string? RootUrl { get; set; } public IDictionary Urls { get; } diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/IAppUrlProvider.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/IAppUrlProvider.cs index 51f6a56afa..9241c5f428 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/IAppUrlProvider.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Urls/IAppUrlProvider.cs @@ -5,9 +5,9 @@ namespace Volo.Abp.UI.Navigation.Urls; public interface IAppUrlProvider { - Task GetUrlAsync([NotNull] string appName, [CanBeNull] string urlName = null); + Task GetUrlAsync([NotNull] string appName, string? urlName = null); - Task GetUrlOrNullAsync([NotNull] string appName, [CanBeNull] string urlName = null); + Task GetUrlOrNullAsync([NotNull] string appName, string? urlName = null); bool IsRedirectAllowedUrl(string url); } From c67852a197d41affa7f54b7cc6f2ad7ac07f967e Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 28 Jun 2023 16:04:18 +0800 Subject: [PATCH 18/32] Enable nullable annotations for Volo.Abp.Castle.Core --- .../src/Volo.Abp.Castle.Core/Volo.Abp.Castle.Core.csproj | 2 ++ .../DynamicProxy/CastleAbpMethodInvocationAdapterBase.cs | 4 ++-- .../CastleAbpMethodInvocationAdapterWithReturnValue.cs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.Castle.Core/Volo.Abp.Castle.Core.csproj b/framework/src/Volo.Abp.Castle.Core/Volo.Abp.Castle.Core.csproj index 7125519bb0..d840a3bf69 100644 --- a/framework/src/Volo.Abp.Castle.Core/Volo.Abp.Castle.Core.csproj +++ b/framework/src/Volo.Abp.Castle.Core/Volo.Abp.Castle.Core.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Castle.Core Volo.Abp.Castle.Core $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapterBase.cs b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapterBase.cs index 1a96e20320..138a35c8b0 100644 --- a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapterBase.cs +++ b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapterBase.cs @@ -20,7 +20,7 @@ public abstract class CastleAbpMethodInvocationAdapterBase : IAbpMethodInvocatio public MethodInfo Method => Invocation.MethodInvocationTarget ?? Invocation.Method; - public object ReturnValue { get; set; } + public object ReturnValue { get; set; } = default!; protected IInvocation Invocation { get; } @@ -39,7 +39,7 @@ public abstract class CastleAbpMethodInvocationAdapterBase : IAbpMethodInvocatio var methodParameters = Method.GetParameters(); for (int i = 0; i < methodParameters.Length; i++) { - dict[methodParameters[i].Name] = Invocation.Arguments[i]; + dict[methodParameters[i].Name!] = Invocation.Arguments[i]; } return dict; diff --git a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapterWithReturnValue.cs b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapterWithReturnValue.cs index 6bebcf531e..5e6e2b3e3b 100644 --- a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapterWithReturnValue.cs +++ b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapterWithReturnValue.cs @@ -21,6 +21,6 @@ public class CastleAbpMethodInvocationAdapterWithReturnValue : CastleAb public override async Task ProceedAsync() { - ReturnValue = await Proceed(Invocation, ProceedInfo); + ReturnValue = (await Proceed(Invocation, ProceedInfo))!; } } From 3ffd8a10a577ac858fc41d0cfbb00ef3b3e51588 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 28 Jun 2023 16:12:55 +0800 Subject: [PATCH 19/32] Enable nullable annotations for Volo.Abp.Autofac --- .../Extensions/DependencyInjection/AutofacRegistration.cs | 8 ++++---- .../AbpAutofacServiceCollectionExtensions.cs | 2 +- framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj | 2 ++ .../Volo/Abp/Autofac/AbpAutofacServiceProviderFactory.cs | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs b/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs index 241c3dd7a8..56a5d7480c 100644 --- a/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs +++ b/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs @@ -87,7 +87,7 @@ public static class AutofacRegistration public static void Populate( this ContainerBuilder builder, IServiceCollection services, - object lifetimeScopeTagForSingletons) + object? lifetimeScopeTagForSingletons) { if (services == null) { @@ -134,7 +134,7 @@ public static class AutofacRegistration private static IRegistrationBuilder ConfigureLifecycle( this IRegistrationBuilder registrationBuilder, ServiceLifetime lifecycleKind, - object lifetimeScopeTagForSingleton) + object? lifetimeScopeTagForSingleton) { switch (lifecycleKind) { @@ -179,7 +179,7 @@ public static class AutofacRegistration private static void Register( ContainerBuilder builder, IServiceCollection services, - object lifetimeScopeTagForSingletons) + object? lifetimeScopeTagForSingletons) { var moduleContainer = services.GetSingletonInstance(); var registrationActionList = services.GetRegistrationActionList(); @@ -223,7 +223,7 @@ public static class AutofacRegistration else { builder - .RegisterInstance(descriptor.ImplementationInstance) + .RegisterInstance(descriptor.ImplementationInstance!) .As(descriptor.ServiceType) .ConfigureLifecycle(descriptor.Lifetime, null); } diff --git a/framework/src/Volo.Abp.Autofac/Microsoft/Extensions/DependencyInjection/AbpAutofacServiceCollectionExtensions.cs b/framework/src/Volo.Abp.Autofac/Microsoft/Extensions/DependencyInjection/AbpAutofacServiceCollectionExtensions.cs index fe6e57ade8..e249e7e5ac 100644 --- a/framework/src/Volo.Abp.Autofac/Microsoft/Extensions/DependencyInjection/AbpAutofacServiceCollectionExtensions.cs +++ b/framework/src/Volo.Abp.Autofac/Microsoft/Extensions/DependencyInjection/AbpAutofacServiceCollectionExtensions.cs @@ -21,7 +21,7 @@ public static class AbpAutofacServiceCollectionExtensions return builder; } - public static IServiceProvider BuildAutofacServiceProvider([NotNull] this IServiceCollection services, Action builderAction = null) + public static IServiceProvider BuildAutofacServiceProvider([NotNull] this IServiceCollection services, Action? builderAction = null) { return services.BuildServiceProviderFromFactory(builderAction); } diff --git a/framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj b/framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj index 32c4eb4e39..cf1c18994a 100644 --- a/framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj +++ b/framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Autofac Volo.Abp.Autofac $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacServiceProviderFactory.cs b/framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacServiceProviderFactory.cs index 0cc35cbf81..dd8f383c5c 100644 --- a/framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacServiceProviderFactory.cs +++ b/framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacServiceProviderFactory.cs @@ -11,7 +11,7 @@ namespace Volo.Abp.Autofac; public class AbpAutofacServiceProviderFactory : IServiceProviderFactory { private readonly ContainerBuilder _builder; - private IServiceCollection _services; + private IServiceCollection _services = default!; public AbpAutofacServiceProviderFactory(ContainerBuilder builder) { From e3448461154f4a897967743e41f5402cd91852cc Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 28 Jun 2023 16:16:35 +0800 Subject: [PATCH 20/32] Enable nullable annotations for Volo.Abp.Autofac.WebAssembly --- ...AbpWebAssemblyApplicationCreationOptionsAutofacExtensions.cs | 2 +- .../Volo.Abp.Autofac.WebAssembly.csproj | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Autofac.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyApplicationCreationOptionsAutofacExtensions.cs b/framework/src/Volo.Abp.Autofac.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyApplicationCreationOptionsAutofacExtensions.cs index 62c6f92b9a..dd2ec149c5 100644 --- a/framework/src/Volo.Abp.Autofac.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyApplicationCreationOptionsAutofacExtensions.cs +++ b/framework/src/Volo.Abp.Autofac.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyApplicationCreationOptionsAutofacExtensions.cs @@ -11,7 +11,7 @@ public static class AbpWebAssemblyApplicationCreationOptionsAutofacExtensions { public static void UseAutofac( [NotNull] this AbpWebAssemblyApplicationCreationOptions options, - [CanBeNull] Action configure = null) + Action? configure = null) { options.HostBuilder.Services.AddAutofacServiceProviderFactory(); options.HostBuilder.ConfigureContainer( diff --git a/framework/src/Volo.Abp.Autofac.WebAssembly/Volo.Abp.Autofac.WebAssembly.csproj b/framework/src/Volo.Abp.Autofac.WebAssembly/Volo.Abp.Autofac.WebAssembly.csproj index 034c5c1903..1ce2a8154d 100644 --- a/framework/src/Volo.Abp.Autofac.WebAssembly/Volo.Abp.Autofac.WebAssembly.csproj +++ b/framework/src/Volo.Abp.Autofac.WebAssembly/Volo.Abp.Autofac.WebAssembly.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable From 67cf9d5a9fb516e5e8046394230aed853e1def80 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 28 Jun 2023 16:19:38 +0800 Subject: [PATCH 21/32] Enable nullable annotations for Volo.Abp.ApiVersioning.Abstractions --- .../Volo.Abp.ApiVersioning.Abstractions.csproj | 2 ++ .../Volo/Abp/ApiVersioning/IRequestedApiVersion.cs | 2 +- .../Volo/Abp/ApiVersioning/NullRequestedApiVersion.cs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo.Abp.ApiVersioning.Abstractions.csproj b/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo.Abp.ApiVersioning.Abstractions.csproj index 038e852f21..2924448609 100644 --- a/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo.Abp.ApiVersioning.Abstractions.csproj +++ b/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo.Abp.ApiVersioning.Abstractions.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.ApiVersioning.Abstractions Volo.Abp.ApiVersioning.Abstractions $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/IRequestedApiVersion.cs b/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/IRequestedApiVersion.cs index 96c2ef33cd..428f8bb6c0 100644 --- a/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/IRequestedApiVersion.cs +++ b/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/IRequestedApiVersion.cs @@ -2,5 +2,5 @@ public interface IRequestedApiVersion { - string Current { get; } + string? Current { get; } } diff --git a/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/NullRequestedApiVersion.cs b/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/NullRequestedApiVersion.cs index 0589c662ef..6099283cc4 100644 --- a/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/NullRequestedApiVersion.cs +++ b/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/NullRequestedApiVersion.cs @@ -4,7 +4,7 @@ public class NullRequestedApiVersion : IRequestedApiVersion { public static NullRequestedApiVersion Instance = new NullRequestedApiVersion(); - public string Current => null; + public string? Current => null; private NullRequestedApiVersion() { From 92e690fb28e1aa4521d704a46063bcab17eebc52 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 28 Jun 2023 16:33:59 +0800 Subject: [PATCH 22/32] Enable nullable annotations for Volo.Abp.VirtualFileSystem --- .../Extensions/FileProviders/AbpFileInfoExtensions.cs | 2 +- .../Volo.Abp.VirtualFileSystem.csproj | 2 ++ .../VirtualFileSystem/DictionaryBasedFileProvider.cs | 6 +++--- .../Volo/Abp/VirtualFileSystem/DynamicFileProvider.cs | 4 ++-- .../Embedded/AbpEmbeddedFileProvider.cs | 9 ++++----- .../Embedded/EmbeddedResourceFileInfo.cs | 6 +++--- .../Embedded/EmbeddedVirtualFileSetInfo.cs | 4 ++-- .../Volo/Abp/VirtualFileSystem/InMemoryFileInfo.cs | 2 +- .../VirtualFileSystem/VirtualFileSetListExtensions.cs | 10 +++++----- 9 files changed, 23 insertions(+), 22 deletions(-) diff --git a/framework/src/Volo.Abp.VirtualFileSystem/Microsoft/Extensions/FileProviders/AbpFileInfoExtensions.cs b/framework/src/Volo.Abp.VirtualFileSystem/Microsoft/Extensions/FileProviders/AbpFileInfoExtensions.cs index 14db7846f3..8ca3c11c42 100644 --- a/framework/src/Volo.Abp.VirtualFileSystem/Microsoft/Extensions/FileProviders/AbpFileInfoExtensions.cs +++ b/framework/src/Volo.Abp.VirtualFileSystem/Microsoft/Extensions/FileProviders/AbpFileInfoExtensions.cs @@ -84,7 +84,7 @@ public static class AbpFileInfoExtensions } } - public static string GetVirtualOrPhysicalPathOrNull([NotNull] this IFileInfo fileInfo) + public static string? GetVirtualOrPhysicalPathOrNull([NotNull] this IFileInfo fileInfo) { Check.NotNull(fileInfo, nameof(fileInfo)); diff --git a/framework/src/Volo.Abp.VirtualFileSystem/Volo.Abp.VirtualFileSystem.csproj b/framework/src/Volo.Abp.VirtualFileSystem/Volo.Abp.VirtualFileSystem.csproj index 7e4ade4eca..97698351c7 100644 --- a/framework/src/Volo.Abp.VirtualFileSystem/Volo.Abp.VirtualFileSystem.csproj +++ b/framework/src/Volo.Abp.VirtualFileSystem/Volo.Abp.VirtualFileSystem.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.VirtualFileSystem Volo.Abp.VirtualFileSystem $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/DictionaryBasedFileProvider.cs b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/DictionaryBasedFileProvider.cs index fddf2fec76..cb0786393b 100644 --- a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/DictionaryBasedFileProvider.cs +++ b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/DictionaryBasedFileProvider.cs @@ -9,11 +9,11 @@ public abstract class DictionaryBasedFileProvider : IFileProvider { protected abstract IDictionary Files { get; } - public virtual IFileInfo GetFileInfo(string subpath) + public virtual IFileInfo GetFileInfo(string? subpath) { if (subpath == null) { - return new NotFoundFileInfo(subpath); + return new NotFoundFileInfo(subpath!); } var file = Files.GetOrDefault(NormalizePath(subpath)); @@ -40,7 +40,7 @@ public abstract class DictionaryBasedFileProvider : IFileProvider foreach (var fileInfo in Files.Values) { var fullPath = fileInfo.GetVirtualOrPhysicalPathOrNull(); - if (!fullPath.StartsWith(directoryPath)) + if (fullPath == null || !fullPath.StartsWith(directoryPath)) { continue; } diff --git a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/DynamicFileProvider.cs b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/DynamicFileProvider.cs index c10ca90afe..12e5184a97 100644 --- a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/DynamicFileProvider.cs +++ b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/DynamicFileProvider.cs @@ -32,8 +32,8 @@ public class DynamicFileProvider : DictionaryBasedFileProvider, IDynamicFileProv public void AddOrUpdate(IFileInfo fileInfo) { var filePath = fileInfo.GetVirtualOrPhysicalPathOrNull(); - DynamicFiles.AddOrUpdate(filePath, fileInfo, (key, value) => fileInfo); - ReportChange(filePath); + DynamicFiles.AddOrUpdate(filePath!, fileInfo, (key, value) => fileInfo); + ReportChange(filePath!); } public bool Delete(string filePath) diff --git a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/AbpEmbeddedFileProvider.cs b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/AbpEmbeddedFileProvider.cs index e147cfc347..9ea816e0eb 100644 --- a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/AbpEmbeddedFileProvider.cs +++ b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/AbpEmbeddedFileProvider.cs @@ -13,15 +13,14 @@ public class AbpEmbeddedFileProvider : DictionaryBasedFileProvider [NotNull] public Assembly Assembly { get; } - [CanBeNull] - public string BaseNamespace { get; } + public string? BaseNamespace { get; } protected override IDictionary Files => _files.Value; private readonly Lazy> _files; public AbpEmbeddedFileProvider( [NotNull] Assembly assembly, - [CanBeNull] string baseNamespace = null) + string? baseNamespace = null) { Check.NotNull(assembly, nameof(assembly)); @@ -40,7 +39,7 @@ public class AbpEmbeddedFileProvider : DictionaryBasedFileProvider foreach (var resourcePath in Assembly.GetManifestResourceNames()) { - if (!BaseNamespace.IsNullOrEmpty() && !resourcePath.StartsWith(BaseNamespace)) + if (!BaseNamespace.IsNullOrEmpty() && !resourcePath.StartsWith(BaseNamespace!)) { continue; } @@ -106,7 +105,7 @@ public class AbpEmbeddedFileProvider : DictionaryBasedFileProvider { if (!BaseNamespace.IsNullOrEmpty()) { - resourceName = resourceName.Substring(BaseNamespace.Length + 1); + resourceName = resourceName.Substring(BaseNamespace!.Length + 1); } var pathParts = resourceName.Split('.'); diff --git a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/EmbeddedResourceFileInfo.cs b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/EmbeddedResourceFileInfo.cs index 8dfc13f66b..33ddb0bec7 100644 --- a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/EmbeddedResourceFileInfo.cs +++ b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/EmbeddedResourceFileInfo.cs @@ -18,7 +18,7 @@ public class EmbeddedResourceFileInfo : IFileInfo { using (var stream = _assembly.GetManifestResourceStream(_resourcePath)) { - _length = stream.Length; + _length = stream!.Length; } } @@ -27,7 +27,7 @@ public class EmbeddedResourceFileInfo : IFileInfo } private long? _length; - public string PhysicalPath => null; + public string? PhysicalPath => null; public string VirtualPath { get; } @@ -68,7 +68,7 @@ public class EmbeddedResourceFileInfo : IFileInfo _length = stream.Length; } - return stream; + return stream!; } public override string ToString() diff --git a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/EmbeddedVirtualFileSetInfo.cs b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/EmbeddedVirtualFileSetInfo.cs index 37642fc6fe..3515722b77 100644 --- a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/EmbeddedVirtualFileSetInfo.cs +++ b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/Embedded/EmbeddedVirtualFileSetInfo.cs @@ -7,12 +7,12 @@ public class EmbeddedVirtualFileSetInfo : VirtualFileSetInfo { public Assembly Assembly { get; } - public string BaseFolder { get; } + public string? BaseFolder { get; } public EmbeddedVirtualFileSetInfo( IFileProvider fileProvider, Assembly assembly, - string baseFolder = null) + string? baseFolder = null) : base(fileProvider) { Assembly = assembly; diff --git a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/InMemoryFileInfo.cs b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/InMemoryFileInfo.cs index db3932b1ee..f192766aaf 100644 --- a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/InMemoryFileInfo.cs +++ b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/InMemoryFileInfo.cs @@ -10,7 +10,7 @@ public class InMemoryFileInfo : IFileInfo public long Length => _fileContent.Length; - public string PhysicalPath => null; + public string? PhysicalPath => null; public string Name { get; } diff --git a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/VirtualFileSetListExtensions.cs b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/VirtualFileSetListExtensions.cs index 3767645861..e25721f00f 100644 --- a/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/VirtualFileSetListExtensions.cs +++ b/framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/VirtualFileSetListExtensions.cs @@ -13,8 +13,8 @@ public static class VirtualFileSetListExtensions { public static void AddEmbedded( [NotNull] this VirtualFileSetList list, - [CanBeNull] string baseNamespace = null, - [CanBeNull] string baseFolder = null) + string? baseNamespace = null, + string? baseFolder = null) { Check.NotNull(list, nameof(list)); @@ -42,8 +42,8 @@ public static class VirtualFileSetListExtensions private static IFileProvider CreateFileProvider( [NotNull] Assembly assembly, - [CanBeNull] string baseNamespace = null, - [CanBeNull] string baseFolder = null) + string? baseNamespace = null, + string? baseFolder = null) { Check.NotNull(assembly, nameof(assembly)); @@ -80,7 +80,7 @@ public static class VirtualFileSetListExtensions if (!embeddedVirtualFileSet.BaseFolder.IsNullOrEmpty()) { - thisPath = Path.Combine(thisPath, embeddedVirtualFileSet.BaseFolder); + thisPath = Path.Combine(thisPath, embeddedVirtualFileSet.BaseFolder!); } fileSets[i] = new PhysicalVirtualFileSetInfo(new PhysicalFileProvider(thisPath), thisPath); From 56f6f2454ac585b78f8485ccfcce22c0384b0ec1 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 28 Jun 2023 17:02:57 +0800 Subject: [PATCH 23/32] Enable nullable annotations for Volo.Abp.Settings --- .../src/Volo.Abp.Settings/Volo.Abp.Settings.csproj | 2 ++ .../Settings/ConfigurationSettingValueProvider.cs | 2 +- .../Settings/DefaultValueSettingValueProvider.cs | 2 +- .../Abp/Settings/GlobalSettingValueProvider.cs | 2 +- .../Volo/Abp/Settings/ISettingDefinitionContext.cs | 2 +- .../Volo/Abp/Settings/ISettingDefinitionManager.cs | 2 +- .../Volo/Abp/Settings/ISettingEncryptionService.cs | 6 ++---- .../Volo/Abp/Settings/ISettingProvider.cs | 2 +- .../Volo/Abp/Settings/ISettingStore.cs | 10 +++++----- .../Volo/Abp/Settings/ISettingValueProvider.cs | 2 +- .../Volo/Abp/Settings/NullSettingStore.cs | 6 +++--- .../Volo/Abp/Settings/SettingDefinition.cs | 14 ++++++-------- .../Volo/Abp/Settings/SettingDefinitionContext.cs | 2 +- .../Volo/Abp/Settings/SettingDefinitionManager.cs | 4 ++-- .../Volo/Abp/Settings/SettingEncryptionService.cs | 4 ++-- .../Volo/Abp/Settings/SettingProvider.cs | 4 ++-- .../Volo/Abp/Settings/SettingValue.cs | 4 ++-- .../Volo/Abp/Settings/SettingValueProvider.cs | 2 +- .../Abp/Settings/SettingValueProviderManager.cs | 2 +- .../Volo/Abp/Settings/UserSettingValueProvider.cs | 2 +- 20 files changed, 37 insertions(+), 39 deletions(-) diff --git a/framework/src/Volo.Abp.Settings/Volo.Abp.Settings.csproj b/framework/src/Volo.Abp.Settings/Volo.Abp.Settings.csproj index 524f932e9c..efec1d42c5 100644 --- a/framework/src/Volo.Abp.Settings/Volo.Abp.Settings.csproj +++ b/framework/src/Volo.Abp.Settings/Volo.Abp.Settings.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Settings Volo.Abp.Settings $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ConfigurationSettingValueProvider.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ConfigurationSettingValueProvider.cs index 853b510d04..51e0a882b0 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ConfigurationSettingValueProvider.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ConfigurationSettingValueProvider.cs @@ -21,7 +21,7 @@ public class ConfigurationSettingValueProvider : ISettingValueProvider, ITransie Configuration = configuration; } - public virtual Task GetOrNullAsync(SettingDefinition setting) + public virtual Task GetOrNullAsync(SettingDefinition setting) { return Task.FromResult(Configuration[ConfigurationNamePrefix + setting.Name]); } diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/DefaultValueSettingValueProvider.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/DefaultValueSettingValueProvider.cs index e5e7275281..299f9e63bc 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/DefaultValueSettingValueProvider.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/DefaultValueSettingValueProvider.cs @@ -16,7 +16,7 @@ public class DefaultValueSettingValueProvider : SettingValueProvider } - public override Task GetOrNullAsync(SettingDefinition setting) + public override Task GetOrNullAsync(SettingDefinition setting) { return Task.FromResult(setting.DefaultValue); } diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/GlobalSettingValueProvider.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/GlobalSettingValueProvider.cs index 34439c6aef..6c0e8883d7 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/GlobalSettingValueProvider.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/GlobalSettingValueProvider.cs @@ -15,7 +15,7 @@ public class GlobalSettingValueProvider : SettingValueProvider { } - public override Task GetOrNullAsync(SettingDefinition setting) + public override Task GetOrNullAsync(SettingDefinition setting) { return SettingStore.GetOrNullAsync(setting.Name, Name, null); } diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingDefinitionContext.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingDefinitionContext.cs index 8257c73adb..deecea1107 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingDefinitionContext.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingDefinitionContext.cs @@ -4,7 +4,7 @@ namespace Volo.Abp.Settings; public interface ISettingDefinitionContext { - SettingDefinition GetOrNull(string name); + SettingDefinition? GetOrNull(string name); IReadOnlyList GetAll(); diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingDefinitionManager.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingDefinitionManager.cs index 865fe5557a..7939d113c4 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingDefinitionManager.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingDefinitionManager.cs @@ -10,5 +10,5 @@ public interface ISettingDefinitionManager IReadOnlyList GetAll(); - SettingDefinition GetOrNull(string name); + SettingDefinition? GetOrNull(string name); } diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingEncryptionService.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingEncryptionService.cs index f91e8f808a..5c1328e8c3 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingEncryptionService.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingEncryptionService.cs @@ -4,9 +4,7 @@ namespace Volo.Abp.Settings; public interface ISettingEncryptionService { - [CanBeNull] - string Encrypt([NotNull] SettingDefinition settingDefinition, [CanBeNull] string plainValue); + string? Encrypt([NotNull] SettingDefinition settingDefinition, string? plainValue); - [CanBeNull] - string Decrypt([NotNull] SettingDefinition settingDefinition, [CanBeNull] string encryptedValue); + string? Decrypt([NotNull] SettingDefinition settingDefinition, string? encryptedValue); } diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingProvider.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingProvider.cs index d58a21b874..a24060b5ff 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingProvider.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingProvider.cs @@ -6,7 +6,7 @@ namespace Volo.Abp.Settings; public interface ISettingProvider { - Task GetOrNullAsync([NotNull] string name); + Task GetOrNullAsync([NotNull] string name); Task> GetAllAsync([NotNull] string[] names); diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingStore.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingStore.cs index a8be20c7d8..89f933f877 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingStore.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingStore.cs @@ -6,15 +6,15 @@ namespace Volo.Abp.Settings; public interface ISettingStore { - Task GetOrNullAsync( + Task GetOrNullAsync( [NotNull] string name, - [CanBeNull] string providerName, - [CanBeNull] string providerKey + string? providerName, + string? providerKey ); Task> GetAllAsync( [NotNull] string[] names, - [CanBeNull] string providerName, - [CanBeNull] string providerKey + string? providerName, + string? providerKey ); } diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingValueProvider.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingValueProvider.cs index 6878fda17b..1619052cbd 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingValueProvider.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/ISettingValueProvider.cs @@ -8,7 +8,7 @@ public interface ISettingValueProvider { string Name { get; } - Task GetOrNullAsync([NotNull] SettingDefinition setting); + Task GetOrNullAsync([NotNull] SettingDefinition setting); Task> GetAllAsync([NotNull] SettingDefinition[] settings); } diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/NullSettingStore.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/NullSettingStore.cs index 8db9286a14..f6d04e0b4a 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/NullSettingStore.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/NullSettingStore.cs @@ -17,12 +17,12 @@ public class NullSettingStore : ISettingStore, ISingletonDependency Logger = NullLogger.Instance; } - public Task GetOrNullAsync(string name, string providerName, string providerKey) + public Task GetOrNullAsync(string name, string? providerName, string? providerKey) { - return Task.FromResult((string)null); + return Task.FromResult((string?)null); } - public Task> GetAllAsync(string[] names, string providerName, string providerKey) + public Task> GetAllAsync(string[] names, string? providerName, string? providerKey) { return Task.FromResult(names.Select(x => new SettingValue(x, null)).ToList()); } diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinition.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinition.cs index 536a407271..72ccfcd3f3 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinition.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinition.cs @@ -17,16 +17,14 @@ public class SettingDefinition get => _displayName; set => _displayName = Check.NotNull(value, nameof(value)); } - private ILocalizableString _displayName; + private ILocalizableString _displayName = default!; - [CanBeNull] - public ILocalizableString Description { get; set; } + public ILocalizableString? Description { get; set; } /// /// Default value of the setting. /// - [CanBeNull] - public string DefaultValue { get; set; } + public string? DefaultValue { get; set; } /// /// Can clients see this setting and it's value. @@ -61,9 +59,9 @@ public class SettingDefinition public SettingDefinition( string name, - string defaultValue = null, - ILocalizableString displayName = null, - ILocalizableString description = null, + string? defaultValue = null, + ILocalizableString? displayName = null, + ILocalizableString? description = null, bool isVisibleToClients = false, bool isInherited = true, bool isEncrypted = false) diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinitionContext.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinitionContext.cs index e06395f614..a1192c96c9 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinitionContext.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinitionContext.cs @@ -12,7 +12,7 @@ public class SettingDefinitionContext : ISettingDefinitionContext Settings = settings; } - public virtual SettingDefinition GetOrNull(string name) + public virtual SettingDefinition? GetOrNull(string name) { return Settings.GetOrDefault(name); } diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinitionManager.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinitionManager.cs index ed285422b3..87f173d04e 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinitionManager.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinitionManager.cs @@ -45,7 +45,7 @@ public class SettingDefinitionManager : ISettingDefinitionManager, ISingletonDep return SettingDefinitions.Value.Values.ToImmutableList(); } - public virtual SettingDefinition GetOrNull(string name) + public virtual SettingDefinition? GetOrNull(string name) { return SettingDefinitions.Value.GetOrDefault(name); } @@ -63,7 +63,7 @@ public class SettingDefinitionManager : ISettingDefinitionManager, ISingletonDep foreach (var provider in providers) { - provider.Define(new SettingDefinitionContext(settings)); + provider!.Define(new SettingDefinitionContext(settings)); } } diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingEncryptionService.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingEncryptionService.cs index 9f59f57910..45a3362d30 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingEncryptionService.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingEncryptionService.cs @@ -17,7 +17,7 @@ public class SettingEncryptionService : ISettingEncryptionService, ITransientDep Logger = NullLogger.Instance; } - public virtual string Encrypt(SettingDefinition settingDefinition, string plainValue) + public virtual string? Encrypt(SettingDefinition settingDefinition, string? plainValue) { if (plainValue.IsNullOrEmpty()) { @@ -27,7 +27,7 @@ public class SettingEncryptionService : ISettingEncryptionService, ITransientDep return StringEncryptionService.Encrypt(plainValue); } - public virtual string Decrypt(SettingDefinition settingDefinition, string encryptedValue) + public virtual string? Decrypt(SettingDefinition settingDefinition, string? encryptedValue) { if (encryptedValue.IsNullOrEmpty()) { diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs index 01791bef00..31dfecc4c0 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs @@ -21,7 +21,7 @@ public class SettingProvider : ISettingProvider, ITransientDependency SettingValueProviderManager = settingValueProviderManager; } - public virtual async Task GetOrNullAsync(string name) + public virtual async Task GetOrNullAsync(string name) { var setting = SettingDefinitionManager.Get(name); var providers = Enumerable @@ -95,7 +95,7 @@ public class SettingProvider : ISettingProvider, ITransientDependency return settingValues; } - protected virtual async Task GetOrNullValueFromProvidersAsync( + protected virtual async Task GetOrNullValueFromProvidersAsync( IEnumerable providers, SettingDefinition setting) { diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingValue.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingValue.cs index 63f6ab063f..56e972611b 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingValue.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingValue.cs @@ -3,14 +3,14 @@ namespace Volo.Abp.Settings; [Serializable] -public class SettingValue : NameValue +public class SettingValue : NameValue { public SettingValue() { } - public SettingValue(string name, string value) + public SettingValue(string name, string? value) { Name = name; Value = value; diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingValueProvider.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingValueProvider.cs index c8b994986d..57d4b18a51 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingValueProvider.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingValueProvider.cs @@ -15,7 +15,7 @@ public abstract class SettingValueProvider : ISettingValueProvider, ITransientDe SettingStore = settingStore; } - public abstract Task GetOrNullAsync(SettingDefinition setting); + public abstract Task GetOrNullAsync(SettingDefinition setting); public abstract Task> GetAllAsync(SettingDefinition[] settings); } diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingValueProviderManager.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingValueProviderManager.cs index f54b3cfda3..d0300357dc 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingValueProviderManager.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingValueProviderManager.cs @@ -24,7 +24,7 @@ public class SettingValueProviderManager : ISettingValueProviderManager, ISingle () => Options .ValueProviders .Select(type => serviceProvider.GetRequiredService(type) as ISettingValueProvider) - .ToList(), + .ToList()!, true ); } diff --git a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/UserSettingValueProvider.cs b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/UserSettingValueProvider.cs index 791bef3709..7c1d65740a 100644 --- a/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/UserSettingValueProvider.cs +++ b/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/UserSettingValueProvider.cs @@ -19,7 +19,7 @@ public class UserSettingValueProvider : SettingValueProvider CurrentUser = currentUser; } - public override async Task GetOrNullAsync(SettingDefinition setting) + public override async Task GetOrNullAsync(SettingDefinition setting) { if (CurrentUser.Id == null) { From 46dd351f23b69069de26de9b9770ed685f40b92f Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 4 Jul 2023 15:40:07 +0800 Subject: [PATCH 24/32] Enable nullable annotations for Volo.Abp.Serialization --- .../Volo.Abp.Serialization/Volo.Abp.Serialization.csproj | 2 ++ .../Volo/Abp/Serialization/DefaultObjectSerializer.cs | 7 +++---- .../Volo/Abp/Serialization/IObjectSerializer.cs | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/framework/src/Volo.Abp.Serialization/Volo.Abp.Serialization.csproj b/framework/src/Volo.Abp.Serialization/Volo.Abp.Serialization.csproj index f410670e83..c4c751210b 100644 --- a/framework/src/Volo.Abp.Serialization/Volo.Abp.Serialization.csproj +++ b/framework/src/Volo.Abp.Serialization/Volo.Abp.Serialization.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Serialization Volo.Abp.Serialization $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Serialization/Volo/Abp/Serialization/DefaultObjectSerializer.cs b/framework/src/Volo.Abp.Serialization/Volo/Abp/Serialization/DefaultObjectSerializer.cs index 0f95d782b0..99ec929ca8 100644 --- a/framework/src/Volo.Abp.Serialization/Volo/Abp/Serialization/DefaultObjectSerializer.cs +++ b/framework/src/Volo.Abp.Serialization/Volo/Abp/Serialization/DefaultObjectSerializer.cs @@ -15,7 +15,7 @@ public class DefaultObjectSerializer : IObjectSerializer, ITransientDependency _serviceProvider = serviceProvider; } - public virtual byte[] Serialize(T obj) + public virtual byte[]? Serialize(T? obj) { if (obj == null) { @@ -35,8 +35,7 @@ public class DefaultObjectSerializer : IObjectSerializer, ITransientDependency return AutoSerialize(obj); } - [CanBeNull] - public virtual T Deserialize(byte[] bytes) + public virtual T? Deserialize(byte[]? bytes) { if (bytes == null) { @@ -61,7 +60,7 @@ public class DefaultObjectSerializer : IObjectSerializer, ITransientDependency return JsonSerializer.SerializeToUtf8Bytes(obj); } - protected virtual T AutoDeserialize(byte[] bytes) + protected virtual T? AutoDeserialize(byte[] bytes) { return JsonSerializer.Deserialize(bytes); } diff --git a/framework/src/Volo.Abp.Serialization/Volo/Abp/Serialization/IObjectSerializer.cs b/framework/src/Volo.Abp.Serialization/Volo/Abp/Serialization/IObjectSerializer.cs index bb82d410b0..6631cb966d 100644 --- a/framework/src/Volo.Abp.Serialization/Volo/Abp/Serialization/IObjectSerializer.cs +++ b/framework/src/Volo.Abp.Serialization/Volo/Abp/Serialization/IObjectSerializer.cs @@ -2,14 +2,14 @@ public interface IObjectSerializer { - byte[] Serialize(T obj); + byte[]? Serialize(T? obj); - T Deserialize(byte[] bytes); + T? Deserialize(byte[] bytes); } public interface IObjectSerializer { - byte[] Serialize(T obj); + byte[]? Serialize(T? obj); - T Deserialize(byte[] bytes); + T? Deserialize(byte[]? bytes); } From c6cc2f934049fcdbfbfb79816de784acca99ea5e Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 4 Jul 2023 15:45:37 +0800 Subject: [PATCH 25/32] Enable nullable annotations for Volo.Abp.Specifications --- .../src/Volo.Abp.Specifications/Volo.Abp.Specifications.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.Specifications/Volo.Abp.Specifications.csproj b/framework/src/Volo.Abp.Specifications/Volo.Abp.Specifications.csproj index f6a5b54948..98d2f529e3 100644 --- a/framework/src/Volo.Abp.Specifications/Volo.Abp.Specifications.csproj +++ b/framework/src/Volo.Abp.Specifications/Volo.Abp.Specifications.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Specifications Volo.Abp.Specifications $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; From 34dd051d7c5143a1e6870145068af62e8019ff5a Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 4 Jul 2023 16:15:49 +0800 Subject: [PATCH 26/32] Enable nullable annotations for Volo.Abp.TestBase --- framework/src/Volo.Abp.TestBase/Volo.Abp.TestBase.csproj | 2 ++ .../Volo/Abp/AbpTestBaseWithServiceProvider.cs | 8 ++++---- .../Volo/Abp/Testing/AbpAsyncIntegratedTest.cs | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/framework/src/Volo.Abp.TestBase/Volo.Abp.TestBase.csproj b/framework/src/Volo.Abp.TestBase/Volo.Abp.TestBase.csproj index 4b90693b3e..9cf201a287 100644 --- a/framework/src/Volo.Abp.TestBase/Volo.Abp.TestBase.csproj +++ b/framework/src/Volo.Abp.TestBase/Volo.Abp.TestBase.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.TestBase Volo.Abp.TestBase $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.TestBase/Volo/Abp/AbpTestBaseWithServiceProvider.cs b/framework/src/Volo.Abp.TestBase/Volo/Abp/AbpTestBaseWithServiceProvider.cs index 407660e854..04879b4fce 100644 --- a/framework/src/Volo.Abp.TestBase/Volo/Abp/AbpTestBaseWithServiceProvider.cs +++ b/framework/src/Volo.Abp.TestBase/Volo/Abp/AbpTestBaseWithServiceProvider.cs @@ -5,14 +5,14 @@ namespace Volo.Abp; public abstract class AbpTestBaseWithServiceProvider { - protected IServiceProvider ServiceProvider { get; set; } + protected IServiceProvider ServiceProvider { get; set; } = default!; - protected virtual T GetService() + protected virtual T? GetService() { return ServiceProvider.GetService(); } - - protected virtual T GetRequiredService() + + protected virtual T GetRequiredService() where T : notnull { return ServiceProvider.GetRequiredService(); } diff --git a/framework/src/Volo.Abp.TestBase/Volo/Abp/Testing/AbpAsyncIntegratedTest.cs b/framework/src/Volo.Abp.TestBase/Volo/Abp/Testing/AbpAsyncIntegratedTest.cs index 4238a8712b..4004c110a4 100644 --- a/framework/src/Volo.Abp.TestBase/Volo/Abp/Testing/AbpAsyncIntegratedTest.cs +++ b/framework/src/Volo.Abp.TestBase/Volo/Abp/Testing/AbpAsyncIntegratedTest.cs @@ -8,11 +8,11 @@ namespace Volo.Abp.Testing; public class AbpAsyncIntegratedTest : AbpTestBaseWithServiceProvider where TStartupModule : IAbpModule { - protected IAbpApplication Application { get; set; } + protected IAbpApplication Application { get; set; } = default!; - protected IServiceProvider RootServiceProvider { get; set; } + protected IServiceProvider RootServiceProvider { get; set; } = default!; - protected IServiceScope TestServiceScope { get; set; } + protected IServiceScope TestServiceScope { get; set; } = default!; public virtual async Task InitializeAsync() { From 89c3b604f694f120a0720a63a27113c77b36e6fd Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 4 Jul 2023 16:19:40 +0800 Subject: [PATCH 27/32] Enable nullable annotations for Volo.Abp.Ldap and Volo.Abp.Ldap.Abstractions --- .../Volo.Abp.Ldap.Abstractions.csproj | 2 ++ .../Volo/Abp/Ldap/ILdapSettingProvider.cs | 10 +++++----- framework/src/Volo.Abp.Ldap/Volo.Abp.Ldap.csproj | 2 ++ .../Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs | 10 +++++----- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/framework/src/Volo.Abp.Ldap.Abstractions/Volo.Abp.Ldap.Abstractions.csproj b/framework/src/Volo.Abp.Ldap.Abstractions/Volo.Abp.Ldap.Abstractions.csproj index 9a61150096..6e25ebe8e6 100644 --- a/framework/src/Volo.Abp.Ldap.Abstractions/Volo.Abp.Ldap.Abstractions.csproj +++ b/framework/src/Volo.Abp.Ldap.Abstractions/Volo.Abp.Ldap.Abstractions.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Ldap.Abstractions Volo.Abp.Ldap.Abstractions $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Ldap.Abstractions/Volo/Abp/Ldap/ILdapSettingProvider.cs b/framework/src/Volo.Abp.Ldap.Abstractions/Volo/Abp/Ldap/ILdapSettingProvider.cs index efc109a762..c7320a36fa 100644 --- a/framework/src/Volo.Abp.Ldap.Abstractions/Volo/Abp/Ldap/ILdapSettingProvider.cs +++ b/framework/src/Volo.Abp.Ldap.Abstractions/Volo/Abp/Ldap/ILdapSettingProvider.cs @@ -4,15 +4,15 @@ namespace Volo.Abp.Ldap; public interface ILdapSettingProvider { - public Task GetServerHostAsync(); + public Task GetServerHostAsync(); public Task GetServerPortAsync(); - public Task GetBaseDcAsync(); + public Task GetBaseDcAsync(); - public Task GetDomainAsync(); + public Task GetDomainAsync(); - public Task GetUserNameAsync(); + public Task GetUserNameAsync(); - public Task GetPasswordAsync(); + public Task GetPasswordAsync(); } diff --git a/framework/src/Volo.Abp.Ldap/Volo.Abp.Ldap.csproj b/framework/src/Volo.Abp.Ldap/Volo.Abp.Ldap.csproj index 951cbf3be2..aee7d78518 100644 --- a/framework/src/Volo.Abp.Ldap/Volo.Abp.Ldap.csproj +++ b/framework/src/Volo.Abp.Ldap/Volo.Abp.Ldap.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Ldap Volo.Abp.Ldap $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs index ab36c1bf5f..cf43f11d43 100644 --- a/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs +++ b/framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs @@ -14,7 +14,7 @@ public class LdapSettingProvider : ILdapSettingProvider, ITransientDependency SettingProvider = settingProvider; } - public async Task GetServerHostAsync() + public async Task GetServerHostAsync() { return await SettingProvider.GetOrNullAsync(LdapSettingNames.ServerHost); } @@ -24,22 +24,22 @@ public class LdapSettingProvider : ILdapSettingProvider, ITransientDependency return (await SettingProvider.GetOrNullAsync(LdapSettingNames.ServerPort))?.To() ?? default; } - public async Task GetBaseDcAsync() + public async Task GetBaseDcAsync() { return await SettingProvider.GetOrNullAsync(LdapSettingNames.BaseDc); } - public async Task GetDomainAsync() + public async Task GetDomainAsync() { return await SettingProvider.GetOrNullAsync(LdapSettingNames.Domain); } - public async Task GetUserNameAsync() + public async Task GetUserNameAsync() { return await SettingProvider.GetOrNullAsync(LdapSettingNames.UserName); } - public async Task GetPasswordAsync() + public async Task GetPasswordAsync() { return await SettingProvider.GetOrNullAsync(LdapSettingNames.Password); } From 08af959b4a068286974ab0eab6afe237765f41d7 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 4 Jul 2023 16:25:56 +0800 Subject: [PATCH 28/32] Enable nullable annotations for Volo.Abp.Minify --- framework/src/Volo.Abp.Minify/Volo.Abp.Minify.csproj | 2 ++ .../src/Volo.Abp.Minify/Volo/Abp/Minify/IMinifier.cs | 4 ++-- .../Volo/Abp/Minify/NUglify/NUglifyCssMinifier.cs | 2 +- .../Volo/Abp/Minify/NUglify/NUglifyException.cs | 2 +- .../Volo/Abp/Minify/NUglify/NUglifyHtmlMinifier.cs | 2 +- .../Volo/Abp/Minify/NUglify/NUglifyJavascriptMinifier.cs | 2 +- .../Volo/Abp/Minify/NUglify/NUglifyMinifierBase.cs | 8 ++++---- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/framework/src/Volo.Abp.Minify/Volo.Abp.Minify.csproj b/framework/src/Volo.Abp.Minify/Volo.Abp.Minify.csproj index f552541094..9ec0a51e40 100644 --- a/framework/src/Volo.Abp.Minify/Volo.Abp.Minify.csproj +++ b/framework/src/Volo.Abp.Minify/Volo.Abp.Minify.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Minify Volo.Abp.Minify $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/IMinifier.cs b/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/IMinifier.cs index 4f816a2f48..4c4f1881da 100644 --- a/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/IMinifier.cs +++ b/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/IMinifier.cs @@ -6,6 +6,6 @@ public interface IMinifier { string Minify( string source, - [CanBeNull] string fileName = null, - [CanBeNull] string originalFileName = null); + string? fileName = null, + string? originalFileName = null); } diff --git a/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyCssMinifier.cs b/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyCssMinifier.cs index 281f5c6aa3..d2f78d95d6 100644 --- a/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyCssMinifier.cs +++ b/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyCssMinifier.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.Minify.NUglify; public class NUglifyCssMinifier : NUglifyMinifierBase, ICssMinifier { - protected override UglifyResult UglifySource(string source, string fileName) + protected override UglifyResult UglifySource(string source, string? fileName) { return Uglify.Css(source, fileName); } diff --git a/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyException.cs b/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyException.cs index 6b4d68b07e..bf623771d3 100644 --- a/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyException.cs +++ b/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyException.cs @@ -7,7 +7,7 @@ namespace Volo.Abp.Minify.NUglify; public class NUglifyException : AbpException { - public List Errors { get; set; } + public List? Errors { get; set; } public NUglifyException(string message, List errors) : base(message) diff --git a/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyHtmlMinifier.cs b/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyHtmlMinifier.cs index dc8bbe22ea..6698b3cdd0 100644 --- a/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyHtmlMinifier.cs +++ b/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyHtmlMinifier.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.Minify.NUglify; public class NUglifyHtmlMinifier : NUglifyMinifierBase, IHtmlMinifier { - protected override UglifyResult UglifySource(string source, string fileName) + protected override UglifyResult UglifySource(string source, string? fileName) { return Uglify.Html(source, sourceFileName: fileName); } diff --git a/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyJavascriptMinifier.cs b/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyJavascriptMinifier.cs index 5b8fa54ce3..6c13d00129 100644 --- a/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyJavascriptMinifier.cs +++ b/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyJavascriptMinifier.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.Minify.NUglify; public class NUglifyJavascriptMinifier : NUglifyMinifierBase, IJavascriptMinifier { - protected override UglifyResult UglifySource(string source, string fileName) + protected override UglifyResult UglifySource(string source, string? fileName) { return Uglify.Js(source, fileName); } diff --git a/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyMinifierBase.cs b/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyMinifierBase.cs index d5018a1b28..28e0267e17 100644 --- a/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyMinifierBase.cs +++ b/framework/src/Volo.Abp.Minify/Volo/Abp/Minify/NUglify/NUglifyMinifierBase.cs @@ -8,7 +8,7 @@ namespace Volo.Abp.Minify.NUglify; public abstract class NUglifyMinifierBase : IMinifier, ITransientDependency { - private static void CheckErrors(UglifyResult result, string originalFileName) + private static void CheckErrors(UglifyResult result, string? originalFileName) { if (result.HasErrors) { @@ -28,8 +28,8 @@ public abstract class NUglifyMinifierBase : IMinifier, ITransientDependency public string Minify( string source, - string fileName = null, - string originalFileName = null) + string? fileName = null, + string? originalFileName = null) { try { @@ -50,5 +50,5 @@ public abstract class NUglifyMinifierBase : IMinifier, ITransientDependency } } - protected abstract UglifyResult UglifySource(string source, string fileName); + protected abstract UglifyResult UglifySource(string source, string? fileName); } From fbb606a20679c84c0008dd098fbb237b759e0e04 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 4 Jul 2023 16:30:01 +0800 Subject: [PATCH 29/32] Enable nullable annotations for Volo.Abp.RemoteServices --- .../Volo.Abp.RemoteServices.csproj | 2 ++ .../Http/Client/IRemoteServiceConfigurationProvider.cs | 3 +-- .../Volo/Abp/Http/Client/RemoteServiceConfiguration.cs | 8 ++++---- .../Http/Client/RemoteServiceConfigurationDictionary.cs | 7 +++---- .../Abp/Http/Client/RemoteServiceConfigurationProvider.cs | 2 +- .../RemoteServiceConfigurationProviderExtensions.cs | 3 +-- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/framework/src/Volo.Abp.RemoteServices/Volo.Abp.RemoteServices.csproj b/framework/src/Volo.Abp.RemoteServices/Volo.Abp.RemoteServices.csproj index 52d536b51a..bdd0f16c25 100644 --- a/framework/src/Volo.Abp.RemoteServices/Volo.Abp.RemoteServices.csproj +++ b/framework/src/Volo.Abp.RemoteServices/Volo.Abp.RemoteServices.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.RemoteServices Volo.Abp.RemoteServices $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/IRemoteServiceConfigurationProvider.cs b/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/IRemoteServiceConfigurationProvider.cs index 12b779141e..e869b19637 100644 --- a/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/IRemoteServiceConfigurationProvider.cs +++ b/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/IRemoteServiceConfigurationProvider.cs @@ -8,6 +8,5 @@ public interface IRemoteServiceConfigurationProvider [ItemNotNull] Task GetConfigurationOrDefaultAsync(string name); - [ItemCanBeNull] - Task GetConfigurationOrDefaultOrNullAsync(string name); + Task GetConfigurationOrDefaultOrNullAsync(string name); } diff --git a/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs b/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs index 34510be354..89d0b79f48 100644 --- a/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs +++ b/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs @@ -2,12 +2,12 @@ namespace Volo.Abp.Http.Client; -public class RemoteServiceConfiguration : Dictionary +public class RemoteServiceConfiguration : Dictionary { /// /// Base Url. /// - public string BaseUrl { + public string? BaseUrl { get => this.GetOrDefault(nameof(BaseUrl)); set => this[nameof(BaseUrl)] = value; } @@ -15,7 +15,7 @@ public class RemoteServiceConfiguration : Dictionary /// /// Version. /// - public string Version { + public string? Version { get => this.GetOrDefault(nameof(Version)); set => this[nameof(Version)] = value; } @@ -25,7 +25,7 @@ public class RemoteServiceConfiguration : Dictionary } - public RemoteServiceConfiguration(string baseUrl, string version = null) + public RemoteServiceConfiguration(string baseUrl, string? version = null) { this[nameof(BaseUrl)] = baseUrl; this[nameof(Version)] = version; diff --git a/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfigurationDictionary.cs b/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfigurationDictionary.cs index b79cf96414..ef4c5f5b77 100644 --- a/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfigurationDictionary.cs +++ b/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfigurationDictionary.cs @@ -3,11 +3,11 @@ using JetBrains.Annotations; namespace Volo.Abp.Http.Client; -public class RemoteServiceConfigurationDictionary : Dictionary +public class RemoteServiceConfigurationDictionary : Dictionary { public const string DefaultName = "Default"; - public RemoteServiceConfiguration Default { + public RemoteServiceConfiguration? Default { get => this.GetOrDefault(DefaultName); set => this[DefaultName] = value; } @@ -20,8 +20,7 @@ public class RemoteServiceConfigurationDictionary : Dictionary GetConfigurationOrDefaultOrNullAsync(string name) + public Task GetConfigurationOrDefaultOrNullAsync(string name) { return Task.FromResult(Options.RemoteServices.GetConfigurationOrDefaultOrNull(name)); } diff --git a/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfigurationProviderExtensions.cs b/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfigurationProviderExtensions.cs index 1c6aaac21d..6ec0a874da 100644 --- a/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfigurationProviderExtensions.cs +++ b/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfigurationProviderExtensions.cs @@ -10,8 +10,7 @@ public static class RemoteServiceConfigurationProviderExtensions this IRemoteServiceConfigurationProvider provider) => provider.GetConfigurationOrDefaultAsync(RemoteServiceConfigurationDictionary.DefaultName); - [ItemNotNull] - public static Task GetConfigurationOrDefaultOrNullAsync( + public static Task GetConfigurationOrDefaultOrNullAsync( this IRemoteServiceConfigurationProvider provider) => provider.GetConfigurationOrDefaultOrNullAsync(RemoteServiceConfigurationDictionary.DefaultName); } \ No newline at end of file From 3ff5553a9d55b99b6596679bfa212aaf960ef570 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 4 Jul 2023 16:34:57 +0800 Subject: [PATCH 30/32] Enable nullable annotations for Volo.Abp.MultiLingualObject --- .../Volo.Abp.MultiLingualObjects.csproj | 2 + .../MultiLingualObjectManager.cs | 188 +++++++++--------- 2 files changed, 96 insertions(+), 94 deletions(-) diff --git a/framework/src/Volo.Abp.MultiLingualObjects/Volo.Abp.MultiLingualObjects.csproj b/framework/src/Volo.Abp.MultiLingualObjects/Volo.Abp.MultiLingualObjects.csproj index 54c8469153..5b45ea638f 100644 --- a/framework/src/Volo.Abp.MultiLingualObjects/Volo.Abp.MultiLingualObjects.csproj +++ b/framework/src/Volo.Abp.MultiLingualObjects/Volo.Abp.MultiLingualObjects.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.MultiLingualObject $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; false diff --git a/framework/src/Volo.Abp.MultiLingualObjects/Volo/Abp/MultiLingualObjects/MultiLingualObjectManager.cs b/framework/src/Volo.Abp.MultiLingualObjects/Volo/Abp/MultiLingualObjects/MultiLingualObjectManager.cs index 908431e997..c41605ad0e 100644 --- a/framework/src/Volo.Abp.MultiLingualObjects/Volo/Abp/MultiLingualObjects/MultiLingualObjectManager.cs +++ b/framework/src/Volo.Abp.MultiLingualObjects/Volo/Abp/MultiLingualObjects/MultiLingualObjectManager.cs @@ -1,97 +1,97 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Localization; -using Volo.Abp.Settings; - -namespace Volo.Abp.MultiLingualObjects; - -public class MultiLingualObjectManager : IMultiLingualObjectManager, ITransientDependency -{ - protected ISettingProvider SettingProvider { get; } - - protected const int MaxCultureFallbackDepth = 5; - - public MultiLingualObjectManager(ISettingProvider settingProvider) - { - SettingProvider = settingProvider; - } - public virtual async Task GetTranslationAsync( - IEnumerable translations, - string? culture, - bool fallbackToParentCultures) - where TTranslation : class, IObjectTranslation - - { - culture ??= CultureInfo.CurrentUICulture.Name; - - if (translations == null || !translations.Any()) - { - return null; - } - - var translation = translations.FirstOrDefault(pt => pt.Language == culture); - if (translation != null) - { - return translation; - } - - if (fallbackToParentCultures) - { - translation = GetTranslationBasedOnCulturalRecursive( - CultureInfo.CurrentUICulture.Parent, - translations, - 0 - ); - - if (translation != null) - { - return translation; - } - } - - var defaultLanguage = await SettingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); - - translation = translations.FirstOrDefault(pt => pt.Language == defaultLanguage); - if (translation != null) - { - return translation; - } - - translation = translations.FirstOrDefault(); - return translation; - } - - public virtual Task GetTranslationAsync( - TMultiLingual multiLingual, - string? culture = null, - bool fallbackToParentCultures = true) - where TMultiLingual : IMultiLingualObject - where TTranslation : class, IObjectTranslation - { - return GetTranslationAsync(multiLingual.Translations, culture: culture, fallbackToParentCultures: fallbackToParentCultures); - } - - protected virtual TTranslation? GetTranslationBasedOnCulturalRecursive( - CultureInfo culture, IEnumerable translations, int currentDepth) - where TTranslation : class, IObjectTranslation - { - if (culture == null || - culture.Name.IsNullOrWhiteSpace() || - translations == null || !translations.Any() || - currentDepth > MaxCultureFallbackDepth) - { - return null; - } - - var translation = translations.FirstOrDefault(pt => pt.Language.Equals(culture.Name, StringComparison.OrdinalIgnoreCase)); - return translation ?? GetTranslationBasedOnCulturalRecursive(culture.Parent, translations, currentDepth + 1); +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Localization; +using Volo.Abp.Settings; + +namespace Volo.Abp.MultiLingualObjects; + +public class MultiLingualObjectManager : IMultiLingualObjectManager, ITransientDependency +{ + protected ISettingProvider SettingProvider { get; } + + protected const int MaxCultureFallbackDepth = 5; + + public MultiLingualObjectManager(ISettingProvider settingProvider) + { + SettingProvider = settingProvider; + } + public virtual async Task GetTranslationAsync( + IEnumerable? translations, + string? culture, + bool fallbackToParentCultures) + where TTranslation : class, IObjectTranslation + + { + culture ??= CultureInfo.CurrentUICulture.Name; + + if (translations == null || !translations.Any()) + { + return null; + } + + var translation = translations.FirstOrDefault(pt => pt.Language == culture); + if (translation != null) + { + return translation; + } + + if (fallbackToParentCultures) + { + translation = GetTranslationBasedOnCulturalRecursive( + CultureInfo.CurrentUICulture.Parent, + translations, + 0 + ); + + if (translation != null) + { + return translation; + } + } + + var defaultLanguage = await SettingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); + + translation = translations.FirstOrDefault(pt => pt.Language == defaultLanguage); + if (translation != null) + { + return translation; + } + + translation = translations.FirstOrDefault(); + return translation; + } + + public virtual Task GetTranslationAsync( + TMultiLingual multiLingual, + string? culture = null, + bool fallbackToParentCultures = true) + where TMultiLingual : IMultiLingualObject + where TTranslation : class, IObjectTranslation + { + return GetTranslationAsync(multiLingual.Translations, culture: culture, fallbackToParentCultures: fallbackToParentCultures); + } + + protected virtual TTranslation? GetTranslationBasedOnCulturalRecursive( + CultureInfo? culture, IEnumerable? translations, int currentDepth) + where TTranslation : class, IObjectTranslation + { + if (culture == null || + culture.Name.IsNullOrWhiteSpace() || + translations == null || !translations.Any() || + currentDepth > MaxCultureFallbackDepth) + { + return null; + } + + var translation = translations.FirstOrDefault(pt => pt.Language.Equals(culture.Name, StringComparison.OrdinalIgnoreCase)); + return translation ?? GetTranslationBasedOnCulturalRecursive(culture.Parent, translations, currentDepth + 1); } - public virtual async Task> GetBulkTranslationsAsync(IEnumerable> translationsCombined, string? culture, bool fallbackToParentCultures) + public virtual async Task> GetBulkTranslationsAsync(IEnumerable>? translationsCombined, string? culture, bool fallbackToParentCultures) where TTranslation : class, IObjectTranslation { culture ??= CultureInfo.CurrentUICulture.Name; @@ -180,7 +180,7 @@ public class MultiLingualObjectManager : IMultiLingualObjectManager, ITransientD } public virtual async Task> GetBulkTranslationsAsync(IEnumerable multiLinguals, string? culture, bool fallbackToParentCultures) - where TMultiLingual : IMultiLingualObject + where TMultiLingual : IMultiLingualObject where TTranslation : class, IObjectTranslation { var resInitial = await GetBulkTranslationsAsync(multiLinguals.Select(x => x.Translations), culture, fallbackToParentCultures); @@ -193,4 +193,4 @@ public class MultiLingualObjectManager : IMultiLingualObjectManager, ITransientD } return res; } -} +} From 416f75bd2620c835e7b0a76f16b2700f7862ca56 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 4 Jul 2023 16:37:47 +0800 Subject: [PATCH 31/32] Enable nullable annotations for Volo.Abp.Sms --- framework/src/Volo.Abp.Sms/Volo.Abp.Sms.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.Sms/Volo.Abp.Sms.csproj b/framework/src/Volo.Abp.Sms/Volo.Abp.Sms.csproj index becbe00e65..7bba35f34a 100644 --- a/framework/src/Volo.Abp.Sms/Volo.Abp.Sms.csproj +++ b/framework/src/Volo.Abp.Sms/Volo.Abp.Sms.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Sms Volo.Abp.Sms $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; From b598e84a9b69e44c7afab82ac0f549bc3ffdf8d3 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 4 Jul 2023 16:40:21 +0800 Subject: [PATCH 32/32] Enable nullable annotations for Volo.Abp.Sms.Aliyun --- .../src/Volo.Abp.Sms.Aliyun/Volo.Abp.Sms.Aliyun.csproj | 2 ++ .../Volo/Abp/Sms/Aliyun/AbpAliyunSmsOptions.cs | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.Sms.Aliyun/Volo.Abp.Sms.Aliyun.csproj b/framework/src/Volo.Abp.Sms.Aliyun/Volo.Abp.Sms.Aliyun.csproj index 8b007b7a4a..e59ce4be49 100644 --- a/framework/src/Volo.Abp.Sms.Aliyun/Volo.Abp.Sms.Aliyun.csproj +++ b/framework/src/Volo.Abp.Sms.Aliyun/Volo.Abp.Sms.Aliyun.csproj @@ -4,6 +4,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Sms.Aliyun Volo.Abp.Sms.Aliyun $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Sms.Aliyun/Volo/Abp/Sms/Aliyun/AbpAliyunSmsOptions.cs b/framework/src/Volo.Abp.Sms.Aliyun/Volo/Abp/Sms/Aliyun/AbpAliyunSmsOptions.cs index 1b3eac289c..895e03c710 100644 --- a/framework/src/Volo.Abp.Sms.Aliyun/Volo/Abp/Sms/Aliyun/AbpAliyunSmsOptions.cs +++ b/framework/src/Volo.Abp.Sms.Aliyun/Volo/Abp/Sms/Aliyun/AbpAliyunSmsOptions.cs @@ -2,9 +2,9 @@ namespace Volo.Abp.Sms.Aliyun; public class AbpAliyunSmsOptions { - public string AccessKeySecret { get; set; } + public string AccessKeySecret { get; set; } = default!; - public string AccessKeyId { get; set; } + public string AccessKeyId { get; set; } = default!; - public string EndPoint { get; set; } + public string EndPoint { get; set; } = default!; }