From af1d8a84bed2ea249ebd0ba59ce4aab1947179bf Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 09:55:17 +0800 Subject: [PATCH 01/15] Enable nullable annotations for Volo.Abp.Auditing --- .../Volo.Abp.Auditing.csproj | 2 ++ .../Volo/Abp/Auditing/AbpAuditingOptions.cs | 2 +- .../Volo/Abp/Auditing/AuditLogActionInfo.cs | 6 ++--- .../Volo/Abp/Auditing/AuditLogInfo.cs | 24 +++++++++---------- .../Volo/Abp/Auditing/AuditingHelper.cs | 22 ++++++++--------- .../Volo/Abp/Auditing/AuditingInterceptor.cs | 8 +++---- .../Volo/Abp/Auditing/AuditingManager.cs | 4 ++-- .../Volo/Abp/Auditing/EntityChangeInfo.cs | 8 +++---- .../Abp/Auditing/EntityPropertyChangeInfo.cs | 8 +++---- .../Volo/Abp/Auditing/IAuditingHelper.cs | 10 ++++---- .../Volo/Abp/Auditing/IAuditingManager.cs | 3 +-- .../EntityHistory/EntityHistoryHelper.cs | 6 ++--- 12 files changed, 52 insertions(+), 51 deletions(-) diff --git a/framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj b/framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj index 6a29572457..00abec3b37 100644 --- a/framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj +++ b/framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Auditing Volo.Abp.Auditing $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingOptions.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingOptions.cs index 623733e8e5..30b32c3587 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingOptions.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingOptions.cs @@ -26,7 +26,7 @@ public class AbpAuditingOptions /// The name of the application or service writing audit logs. /// Default: null. /// - public string ApplicationName { get; set; } + public string? ApplicationName { get; set; } /// /// Default: true. diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogActionInfo.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogActionInfo.cs index e312f947e4..f9f2c66cd0 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogActionInfo.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogActionInfo.cs @@ -7,11 +7,11 @@ namespace Volo.Abp.Auditing; [Serializable] public class AuditLogActionInfo : IHasExtraProperties { - public string ServiceName { get; set; } + public string ServiceName { get; set; } = default!; - public string MethodName { get; set; } + public string MethodName { get; set; } = default!; - public string Parameters { get; set; } + public string Parameters { get; set; } = default!; public DateTime ExecutionTime { get; set; } diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs index 4df472da24..962b143e8c 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs @@ -9,43 +9,43 @@ namespace Volo.Abp.Auditing; [Serializable] public class AuditLogInfo : IHasExtraProperties { - public string ApplicationName { get; set; } + public string? ApplicationName { get; set; } 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 Guid? ImpersonatorUserId { get; set; } public Guid? ImpersonatorTenantId { get; set; } - public string ImpersonatorUserName { get; set; } + public string? ImpersonatorUserName { get; set; } - public string ImpersonatorTenantName { get; set; } + public string? ImpersonatorTenantName { get; set; } public DateTime ExecutionTime { get; set; } public int ExecutionDuration { 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 ClientName { get; set; } + public string? ClientName { get; set; } - public string BrowserInfo { get; set; } + public string? BrowserInfo { get; set; } - public string HttpMethod { get; set; } + public string? HttpMethod { get; set; } public int? HttpStatusCode { get; set; } - public string Url { get; set; } + public string? Url { get; set; } public List Actions { get; set; } diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs index 7468f10986..aadbeccabb 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs @@ -52,7 +52,7 @@ public class AuditingHelper : IAuditingHelper, ITransientDependency CorrelationIdProvider = correlationIdProvider; } - public virtual bool ShouldSaveAudit(MethodInfo methodInfo, bool defaultValue = false, bool ignoreIntegrationServiceAttribute = false) + public virtual bool ShouldSaveAudit(MethodInfo? methodInfo, bool defaultValue = false, bool ignoreIntegrationServiceAttribute = false) { if (methodInfo == null) { @@ -150,23 +150,23 @@ public class AuditingHelper : IAuditingHelper, ITransientDependency public virtual AuditLogActionInfo CreateAuditLogAction( AuditLogInfo auditLog, - Type type, + Type? type, MethodInfo method, - object[] arguments) + object?[] arguments) { return CreateAuditLogAction(auditLog, type, method, CreateArgumentsDictionary(method, arguments)); } public virtual AuditLogActionInfo CreateAuditLogAction( AuditLogInfo auditLog, - Type type, + Type? type, MethodInfo method, - IDictionary arguments) + IDictionary arguments) { var actionInfo = new AuditLogActionInfo { ServiceName = type != null - ? type.FullName + ? type.FullName! : "", MethodName = method.Name, Parameters = SerializeConvertArguments(arguments), @@ -198,7 +198,7 @@ public class AuditingHelper : IAuditingHelper, ITransientDependency } } - protected virtual string SerializeConvertArguments(IDictionary arguments) + protected virtual string SerializeConvertArguments(IDictionary arguments) { try { @@ -207,7 +207,7 @@ public class AuditingHelper : IAuditingHelper, ITransientDependency return "{}"; } - var dictionary = new Dictionary(); + var dictionary = new Dictionary(); foreach (var argument in arguments) { @@ -230,14 +230,14 @@ public class AuditingHelper : IAuditingHelper, ITransientDependency } } - protected virtual Dictionary CreateArgumentsDictionary(MethodInfo method, object[] arguments) + protected virtual Dictionary CreateArgumentsDictionary(MethodInfo method, object?[] arguments) { var parameters = method.GetParameters(); - var dictionary = new Dictionary(); + var dictionary = new Dictionary(); for (var i = 0; i < parameters.Length; i++) { - dictionary[parameters[i].Name] = arguments[i]; + dictionary[parameters[i].Name!] = arguments[i]; } return dictionary; diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs index bee71b723a..6be28d24cf 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs @@ -80,7 +80,7 @@ public class AuditingInterceptor : AbpInterceptor, ITransientDependency { var auditLog = auditLogScope.Log; - AuditLogActionInfo auditLogAction = null; + AuditLogActionInfo? auditLogAction = null; if (!options.DisableLogActionInfo) { auditLogAction = auditingHelper.CreateAuditLogAction( @@ -127,10 +127,10 @@ public class AuditingInterceptor : AbpInterceptor, ITransientDependency { try { - await ProceedByLoggingAsync(invocation, options, auditingHelper, auditingManager.Current); + await ProceedByLoggingAsync(invocation, options, auditingHelper, auditingManager.Current!); Debug.Assert(auditingManager.Current != null); - if (auditingManager.Current.Log.Exceptions.Any()) + if (auditingManager.Current!.Log.Exceptions.Any()) { hasError = true; } @@ -142,7 +142,7 @@ public class AuditingInterceptor : AbpInterceptor, ITransientDependency } finally { - if (await ShouldWriteAuditLogAsync(invocation, auditingManager.Current.Log, options, currentUser, hasError)) + if (await ShouldWriteAuditLogAsync(invocation, auditingManager.Current!.Log, options, currentUser, hasError)) { if (unitOfWorkManager.Current != null) { diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingManager.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingManager.cs index 43d86825ec..df6c435de1 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingManager.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingManager.cs @@ -38,7 +38,7 @@ public class AuditingManager : IAuditingManager, ITransientDependency _auditingStore = auditingStore; } - public IAuditLogScope Current => _ambientScopeProvider.GetValue(AmbientContextKey); + public IAuditLogScope? Current => _ambientScopeProvider.GetValue(AmbientContextKey); public IAuditLogSaveHandle BeginScope() { @@ -49,7 +49,7 @@ public class AuditingManager : IAuditingManager, ITransientDependency Debug.Assert(Current != null, "Current != null"); - return new DisposableSaveHandle(this, ambientScope, Current.Log, Stopwatch.StartNew()); + return new DisposableSaveHandle(this, ambientScope, Current!.Log, Stopwatch.StartNew()); } protected virtual void ExecutePostContributors(AuditLogInfo auditLogInfo) diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityChangeInfo.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityChangeInfo.cs index 9ed4114e48..261809a968 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityChangeInfo.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityChangeInfo.cs @@ -19,15 +19,15 @@ public class EntityChangeInfo : IHasExtraProperties /// public Guid? EntityTenantId { get; set; } - public string EntityId { get; set; } + public string? EntityId { get; set; } - public string EntityTypeFullName { get; set; } + public string? EntityTypeFullName { get; set; } - public List PropertyChanges { get; set; } + public List PropertyChanges { get; set; } = default!; public ExtraPropertyDictionary ExtraProperties { get; } - public virtual object EntityEntry { get; set; } //TODO: Try to remove since it breaks serializability + public virtual object EntityEntry { get; set; } = default!; //TODO: Try to remove since it breaks serializability public EntityChangeInfo() { diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs index 5e92f6622e..e25369d7b2 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs @@ -23,11 +23,11 @@ public class EntityPropertyChangeInfo /// public static int MaxPropertyTypeFullNameLength = 192; - public virtual string NewValue { get; set; } + public virtual string? NewValue { get; set; } - public virtual string OriginalValue { get; set; } + public virtual string? OriginalValue { get; set; } - public virtual string PropertyName { get; set; } + public virtual string PropertyName { get; set; } = default!; - public virtual string PropertyTypeFullName { get; set; } + public virtual string PropertyTypeFullName { get; set; } = default!; } diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingHelper.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingHelper.cs index 5a2878d1b0..e6fa20bc90 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingHelper.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingHelper.cs @@ -7,7 +7,7 @@ namespace Volo.Abp.Auditing; //TODO: Move ShouldSaveAudit & IsEntityHistoryEnabled and rename to IAuditingFactory public interface IAuditingHelper { - bool ShouldSaveAudit(MethodInfo methodInfo, bool defaultValue = false, bool ignoreIntegrationServiceAttribute = false); + bool ShouldSaveAudit(MethodInfo? methodInfo, bool defaultValue = false, bool ignoreIntegrationServiceAttribute = false); bool IsEntityHistoryEnabled(Type entityType, bool defaultValue = false); @@ -15,15 +15,15 @@ public interface IAuditingHelper AuditLogActionInfo CreateAuditLogAction( AuditLogInfo auditLog, - Type type, + Type? type, MethodInfo method, - object[] arguments + object?[] arguments ); AuditLogActionInfo CreateAuditLogAction( AuditLogInfo auditLog, - Type type, + Type? type, MethodInfo method, - IDictionary arguments + IDictionary arguments ); } diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingManager.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingManager.cs index 35a465396d..a1091b8600 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingManager.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAuditingManager.cs @@ -4,8 +4,7 @@ namespace Volo.Abp.Auditing; public interface IAuditingManager { - [CanBeNull] - IAuditLogScope Current { get; } + IAuditLogScope? Current { get; } IAuditLogSaveHandle BeginScope(); } diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs index 801e772e26..d21e4c43c5 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs @@ -177,10 +177,10 @@ public class EntityHistoryHelper : IEntityHistoryHelper, ITransientDependency { propertyChanges.Add(new EntityPropertyChangeInfo { - NewValue = isDeleted ? null : JsonSerializer.Serialize(propertyEntry.CurrentValue).TruncateWithPostfix(EntityPropertyChangeInfo.MaxValueLength), - OriginalValue = isCreated ? null : JsonSerializer.Serialize(propertyEntry.OriginalValue).TruncateWithPostfix(EntityPropertyChangeInfo.MaxValueLength), + NewValue = isDeleted ? null : JsonSerializer.Serialize(propertyEntry.CurrentValue!).TruncateWithPostfix(EntityPropertyChangeInfo.MaxValueLength), + OriginalValue = isCreated ? null : JsonSerializer.Serialize(propertyEntry.OriginalValue!).TruncateWithPostfix(EntityPropertyChangeInfo.MaxValueLength), PropertyName = property.Name, - PropertyTypeFullName = property.ClrType.GetFirstGenericArgumentIfNullable().FullName + PropertyTypeFullName = property.ClrType.GetFirstGenericArgumentIfNullable().FullName! }); } } From c8dfebffad06a0e7b0517f1ec299ae40a8659db2 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 10:00:35 +0800 Subject: [PATCH 02/15] Enable nullable annotations for Volo.Abp.Auditing.Contracts --- .../Volo.Abp.Auditing.Contracts.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.Auditing.Contracts/Volo.Abp.Auditing.Contracts.csproj b/framework/src/Volo.Abp.Auditing.Contracts/Volo.Abp.Auditing.Contracts.csproj index d926ca6365..15e5befcaa 100644 --- a/framework/src/Volo.Abp.Auditing.Contracts/Volo.Abp.Auditing.Contracts.csproj +++ b/framework/src/Volo.Abp.Auditing.Contracts/Volo.Abp.Auditing.Contracts.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Auditing.Contracts Volo.Abp.Auditing.Contracts $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; From bfcc82b9ef3aad1b3bf43fbf29a5bf9891b611f7 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 10:13:49 +0800 Subject: [PATCH 03/15] Enable nullable annotations for Volo.Abp.Authorization --- .../Toolbars/ToolbarManager.cs | 2 +- .../Authorization/AbpAuthorizationServiceExtensions.cs | 4 ++-- .../Authorization/AuthorizationOptionsExtensions.cs | 4 ++-- .../Volo.Abp.Authorization/Volo.Abp.Authorization.csproj | 2 ++ .../Abp/Authorization/AbpAuthorizationPolicyProvider.cs | 2 +- .../AuthenticatedSimpleStateCheckerSerializerContributor.cs | 4 ++-- .../Permissions/IStaticPermissionDefinitionStore.cs | 2 +- .../Permissions/NullDynamicPermissionDefinitionStore.cs | 2 +- .../Permissions/PermissionValueProviderManager.cs | 2 +- .../PermissionsSimpleStateCheckerSerializerContributor.cs | 6 +++--- .../RequirePermissionsSimpleBatchStateChecker.cs | 2 +- .../Permissions/StaticPermissionDefinitionStore.cs | 4 ++-- .../Volo/Abp/Ui/Navigation/MenuManager.cs | 2 +- 13 files changed, 20 insertions(+), 18 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs index 67e584abb6..7822277371 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs @@ -56,7 +56,7 @@ public class ToolbarManager : IToolbarManager, ITransientDependency { foreach (var item in toolbar.Items.Where(x => !x.RequiredPermissionName.IsNullOrWhiteSpace())) { - item.RequirePermissions(item.RequiredPermissionName); + item.RequirePermissions(item.RequiredPermissionName!); } var checkPermissionsToolbarItems = toolbar.Items.Where(x => x.StateCheckers.Any()).ToArray(); diff --git a/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs b/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs index b4ed1b8b31..c66d74b381 100644 --- a/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs +++ b/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs @@ -25,7 +25,7 @@ public static class AbpAuthorizationServiceExtensions ); } - public static async Task AuthorizeAsync(this IAuthorizationService authorizationService, object resource, AuthorizationPolicy policy) + public static async Task AuthorizeAsync(this IAuthorizationService authorizationService, object? resource, AuthorizationPolicy policy) { return await authorizationService.AuthorizeAsync( authorizationService.AsAbpAuthorizationService().CurrentPrincipal, @@ -52,7 +52,7 @@ public static class AbpAuthorizationServiceExtensions ); } - public static async Task AuthorizeAsync(this IAuthorizationService authorizationService, object resource, string policyName) + public static async Task AuthorizeAsync(this IAuthorizationService authorizationService, object? resource, string policyName) { return await authorizationService.AuthorizeAsync( authorizationService.AsAbpAuthorizationService().CurrentPrincipal, diff --git a/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AuthorizationOptionsExtensions.cs b/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AuthorizationOptionsExtensions.cs index 69f7e5d7fe..39ba335cb2 100644 --- a/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AuthorizationOptionsExtensions.cs +++ b/framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AuthorizationOptionsExtensions.cs @@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Authorization; public static class AuthorizationOptionsExtensions { private static readonly PropertyInfo PolicyMapProperty = typeof(AuthorizationOptions) - .GetProperty("PolicyMap", BindingFlags.Instance | BindingFlags.NonPublic); + .GetProperty("PolicyMap", BindingFlags.Instance | BindingFlags.NonPublic)!; /// /// Gets all policies. @@ -20,6 +20,6 @@ public static class AuthorizationOptionsExtensions /// public static List GetPoliciesNames(this AuthorizationOptions options) { - return ((IDictionary)PolicyMapProperty.GetValue(options)).Keys.ToList(); + return ((IDictionary)PolicyMapProperty.GetValue(options)!).Keys.ToList(); } } diff --git a/framework/src/Volo.Abp.Authorization/Volo.Abp.Authorization.csproj b/framework/src/Volo.Abp.Authorization/Volo.Abp.Authorization.csproj index 81077c16f9..d16885cbd0 100644 --- a/framework/src/Volo.Abp.Authorization/Volo.Abp.Authorization.csproj +++ b/framework/src/Volo.Abp.Authorization/Volo.Abp.Authorization.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Authorization Volo.Abp.Authorization $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationPolicyProvider.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationPolicyProvider.cs index fb37427c48..7958f2a979 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationPolicyProvider.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationPolicyProvider.cs @@ -23,7 +23,7 @@ public class AbpAuthorizationPolicyProvider : DefaultAuthorizationPolicyProvider _options = options.Value; } - public override async Task GetPolicyAsync(string policyName) + public override async Task GetPolicyAsync(string policyName) { var policy = await base.GetPolicyAsync(policyName); if (policy != null) diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/AuthenticatedSimpleStateCheckerSerializerContributor.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/AuthenticatedSimpleStateCheckerSerializerContributor.cs index 2a23b5bfcd..d23273e7a2 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/AuthenticatedSimpleStateCheckerSerializerContributor.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/AuthenticatedSimpleStateCheckerSerializerContributor.cs @@ -10,7 +10,7 @@ public class AuthenticatedSimpleStateCheckerSerializerContributor : { public const string CheckerShortName = "A"; - public string SerializeToJson(ISimpleStateChecker checker) + public string? SerializeToJson(ISimpleStateChecker checker) where TState : IHasSimpleStateCheckers { if (checker is not RequireAuthenticatedSimpleStateChecker) @@ -25,7 +25,7 @@ public class AuthenticatedSimpleStateCheckerSerializerContributor : return jsonObject.ToJsonString(); } - public ISimpleStateChecker Deserialize(JsonObject jsonObject, TState state) + public ISimpleStateChecker? Deserialize(JsonObject jsonObject, TState state) where TState : IHasSimpleStateCheckers { if (jsonObject["T"]?.ToString() != CheckerShortName) diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/IStaticPermissionDefinitionStore.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/IStaticPermissionDefinitionStore.cs index 719412e4db..4da8423dd3 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/IStaticPermissionDefinitionStore.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/IStaticPermissionDefinitionStore.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.Authorization.Permissions; public interface IStaticPermissionDefinitionStore { - Task GetOrNullAsync(string name); + Task GetOrNullAsync(string name); Task> GetPermissionsAsync(); diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/NullDynamicPermissionDefinitionStore.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/NullDynamicPermissionDefinitionStore.cs index 61e70b057c..b070b6af96 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/NullDynamicPermissionDefinitionStore.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/NullDynamicPermissionDefinitionStore.cs @@ -8,7 +8,7 @@ namespace Volo.Abp.Authorization.Permissions; public class NullDynamicPermissionDefinitionStore : IDynamicPermissionDefinitionStore, ISingletonDependency { - private readonly static Task CachedPermissionResult = Task.FromResult((PermissionDefinition)null); + private readonly static Task CachedPermissionResult = Task.FromResult((PermissionDefinition)null!); private readonly static Task> CachedPermissionsResult = Task.FromResult((IReadOnlyList)Array.Empty().ToImmutableList()); diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionValueProviderManager.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionValueProviderManager.cs index 36744381a2..84d0ad0b2c 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionValueProviderManager.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionValueProviderManager.cs @@ -24,7 +24,7 @@ public class PermissionValueProviderManager : IPermissionValueProviderManager, I () => Options .ValueProviders .Select(c => serviceProvider.GetRequiredService(c) as IPermissionValueProvider) - .ToList(), + .ToList()!, true ); } diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionsSimpleStateCheckerSerializerContributor.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionsSimpleStateCheckerSerializerContributor.cs index 3b890797f6..1a06b83ed7 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionsSimpleStateCheckerSerializerContributor.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionsSimpleStateCheckerSerializerContributor.cs @@ -12,7 +12,7 @@ public class PermissionsSimpleStateCheckerSerializerContributor : { public const string CheckerShortName = "P"; - public string SerializeToJson(ISimpleStateChecker checker) + public string? SerializeToJson(ISimpleStateChecker checker) where TState : IHasSimpleStateCheckers { if (checker is not RequirePermissionsSimpleStateChecker permissionsSimpleStateChecker) @@ -35,7 +35,7 @@ public class PermissionsSimpleStateCheckerSerializerContributor : return jsonObject.ToJsonString(); } - public ISimpleStateChecker Deserialize( + public ISimpleStateChecker? Deserialize( JsonObject jsonObject, TState state) where TState : IHasSimpleStateCheckers @@ -54,7 +54,7 @@ public class PermissionsSimpleStateCheckerSerializerContributor : return new RequirePermissionsSimpleStateChecker( new RequirePermissionsSimpleBatchStateCheckerModel( state, - nameArray.Select(x => x.ToString()).ToArray(), + nameArray.Select(x => x!.ToString()).ToArray(), (bool?)jsonObject["A"] ?? false ) ); diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateChecker.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateChecker.cs index e4ce666d8a..70e74a6bca 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateChecker.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateChecker.cs @@ -11,7 +11,7 @@ namespace Volo.Abp.Authorization.Permissions; public class RequirePermissionsSimpleBatchStateChecker : SimpleBatchStateCheckerBase where TState : IHasSimpleStateCheckers { - public static RequirePermissionsSimpleBatchStateChecker Current => _current.Value; + public static RequirePermissionsSimpleBatchStateChecker Current => _current.Value!; private static readonly AsyncLocal> _current = new AsyncLocal>(); private readonly List> _models; diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/StaticPermissionDefinitionStore.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/StaticPermissionDefinitionStore.cs index ee4803d61e..2d0a9d668c 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/StaticPermissionDefinitionStore.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/StaticPermissionDefinitionStore.cs @@ -79,7 +79,7 @@ public class StaticPermissionDefinitionStore : IStaticPermissionDefinitionStore, var providers = Options .DefinitionProviders - .Select(p => scope.ServiceProvider.GetRequiredService(p) as IPermissionDefinitionProvider) + .Select(p => (scope.ServiceProvider.GetRequiredService(p) as IPermissionDefinitionProvider)!) .ToList(); foreach (var provider in providers) @@ -101,7 +101,7 @@ public class StaticPermissionDefinitionStore : IStaticPermissionDefinitionStore, } } - public Task GetOrNullAsync(string name) + public Task GetOrNullAsync(string name) { return Task.FromResult(PermissionDefinitions.GetOrDefault(name)); } diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs index 907779c397..bff1abb341 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs @@ -110,7 +110,7 @@ public class MenuManager : IMenuManager, ITransientDependency { if (!item.RequiredPermissionName.IsNullOrWhiteSpace()) { - item.RequirePermissions(item.RequiredPermissionName); + item.RequirePermissions(item.RequiredPermissionName!); } } From 5ab7ebf5d170a1f1bf1e84fca32293a2fd8f924f Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 10:23:24 +0800 Subject: [PATCH 04/15] Enable nullable annotations for Volo.Abp.Authorization.Abstractions --- .../Volo.Abp.Authorization.Abstractions.csproj | 2 ++ .../AlwaysAllowAuthorizationService.cs | 4 ++-- .../Permissions/AlwaysAllowPermissionChecker.cs | 4 ++-- .../Permissions/ICanAddChildPermission.cs | 2 +- .../Permissions/IPermissionChecker.cs | 4 ++-- .../Permissions/IPermissionDefinitionContext.cs | 8 +++----- .../Permissions/PermissionDefinition.cs | 16 ++++++++-------- .../Permissions/PermissionDefinitionContext.cs | 6 +++--- .../Permissions/PermissionGrantInfo.cs | 6 +++--- .../Permissions/PermissionGroupDefinition.cs | 17 ++++++++--------- .../Permissions/PermissionStateContext.cs | 4 ++-- 11 files changed, 36 insertions(+), 37 deletions(-) diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo.Abp.Authorization.Abstractions.csproj b/framework/src/Volo.Abp.Authorization.Abstractions/Volo.Abp.Authorization.Abstractions.csproj index 86f6a8498a..51e05677d4 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo.Abp.Authorization.Abstractions.csproj +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo.Abp.Authorization.Abstractions.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Authorization.Abstractions Volo.Abp.Authorization.Abstractions $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/AlwaysAllowAuthorizationService.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/AlwaysAllowAuthorizationService.cs index 92de7873f8..b65bc7aa84 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/AlwaysAllowAuthorizationService.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/AlwaysAllowAuthorizationService.cs @@ -21,12 +21,12 @@ public class AlwaysAllowAuthorizationService : IAbpAuthorizationService _currentPrincipalAccessor = currentPrincipalAccessor; } - public Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) + public Task AuthorizeAsync(ClaimsPrincipal user, object? resource, IEnumerable requirements) { return Task.FromResult(AuthorizationResult.Success()); } - public Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) + public Task AuthorizeAsync(ClaimsPrincipal user, object? resource, string policyName) { return Task.FromResult(AuthorizationResult.Success()); } diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/AlwaysAllowPermissionChecker.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/AlwaysAllowPermissionChecker.cs index 703ed1c94a..7910750fe7 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/AlwaysAllowPermissionChecker.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/AlwaysAllowPermissionChecker.cs @@ -17,7 +17,7 @@ public class AlwaysAllowPermissionChecker : IPermissionChecker return TaskCache.TrueResult; } - public Task IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string name) + public Task IsGrantedAsync(ClaimsPrincipal? claimsPrincipal, string name) { return TaskCache.TrueResult; } @@ -27,7 +27,7 @@ public class AlwaysAllowPermissionChecker : IPermissionChecker return IsGrantedAsync(null, names); } - public Task IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string[] names) + public Task IsGrantedAsync(ClaimsPrincipal? claimsPrincipal, string[] names) { return Task.FromResult(new MultiplePermissionGrantResult(names, PermissionGrantResult.Granted)); } diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/ICanAddChildPermission.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/ICanAddChildPermission.cs index 57a224699f..828e4cbd01 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/ICanAddChildPermission.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/ICanAddChildPermission.cs @@ -8,7 +8,7 @@ public interface ICanAddChildPermission { PermissionDefinition AddPermission( [NotNull] string name, - ILocalizableString displayName = null, + ILocalizableString? displayName = null, MultiTenancySides multiTenancySide = MultiTenancySides.Both, bool isEnabled = true); } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionChecker.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionChecker.cs index 4dfc3b94c6..15bdeabcca 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionChecker.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionChecker.cs @@ -8,9 +8,9 @@ public interface IPermissionChecker { Task IsGrantedAsync([NotNull] string name); - Task IsGrantedAsync([CanBeNull] ClaimsPrincipal claimsPrincipal, [NotNull] string name); + Task IsGrantedAsync(ClaimsPrincipal? claimsPrincipal, [NotNull] string name); Task IsGrantedAsync([NotNull] string[] names); - Task IsGrantedAsync([CanBeNull] ClaimsPrincipal claimsPrincipal, [NotNull] string[] names); + Task IsGrantedAsync(ClaimsPrincipal? claimsPrincipal, [NotNull] string[] names); } diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionDefinitionContext.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionDefinitionContext.cs index 411b030b6a..4f686a6bae 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionDefinitionContext.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionDefinitionContext.cs @@ -25,8 +25,7 @@ public interface IPermissionDefinitionContext /// /// Name of the group /// - [CanBeNull] - PermissionGroupDefinition GetGroupOrNull(string name); + PermissionGroupDefinition? GetGroupOrNull(string name); /// /// Tries to add a new permission group. @@ -37,7 +36,7 @@ public interface IPermissionDefinitionContext /// PermissionGroupDefinition AddGroup( [NotNull] string name, - ILocalizableString displayName = null); + ILocalizableString? displayName = null); /// /// Tries to remove a permission group. @@ -51,6 +50,5 @@ public interface IPermissionDefinitionContext /// Returns null if can not find the given group. /// Name of the group /// - [CanBeNull] - PermissionDefinition GetPermissionOrNull([NotNull] string name); + PermissionDefinition? GetPermissionOrNull([NotNull] string name); } diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinition.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinition.cs index fb6f07690c..ab49e4aad4 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinition.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinition.cs @@ -20,7 +20,7 @@ public class PermissionDefinition : /// Parent of this permission if one exists. /// If set, this permission can be granted only if parent is granted. /// - public PermissionDefinition Parent { get; private set; } + public PermissionDefinition? Parent { get; private set; } /// /// MultiTenancy side. @@ -40,7 +40,7 @@ public class PermissionDefinition : get => _displayName; set => _displayName = Check.NotNull(value, nameof(value)); } - private ILocalizableString _displayName; + private ILocalizableString _displayName = default!; public IReadOnlyList Children => _children.ToImmutableList(); private readonly List _children; @@ -48,7 +48,7 @@ public class PermissionDefinition : /// /// Can be used to get/set custom properties for this permission definition. /// - public Dictionary Properties { get; } + public Dictionary Properties { get; } /// /// Indicates whether this permission is enabled or disabled. @@ -71,14 +71,14 @@ public class PermissionDefinition : /// Returns the value in the dictionary by given . /// Returns null if given is not present in the dictionary. /// - public object this[string name] { + public object? this[string name] { get => Properties.GetOrDefault(name); set => Properties[name] = value; } protected internal PermissionDefinition( [NotNull] string name, - ILocalizableString displayName = null, + ILocalizableString? displayName = null, MultiTenancySides multiTenancySide = MultiTenancySides.Both, bool isEnabled = true) { @@ -87,7 +87,7 @@ public class PermissionDefinition : MultiTenancySide = multiTenancySide; IsEnabled = isEnabled; - Properties = new Dictionary(); + Properties = new Dictionary(); Providers = new List(); StateCheckers = new List>(); _children = new List(); @@ -95,7 +95,7 @@ public class PermissionDefinition : public virtual PermissionDefinition AddChild( [NotNull] string name, - ILocalizableString displayName = null, + ILocalizableString? displayName = null, MultiTenancySides multiTenancySide = MultiTenancySides.Both, bool isEnabled = true) { @@ -115,7 +115,7 @@ public class PermissionDefinition : PermissionDefinition ICanAddChildPermission.AddPermission( string name, - ILocalizableString displayName = null, + ILocalizableString? displayName = null, MultiTenancySides multiTenancySide = MultiTenancySides.Both, bool isEnabled = true) { diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinitionContext.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinitionContext.cs index 5b5543e868..4372046e15 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinitionContext.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionDefinitionContext.cs @@ -20,7 +20,7 @@ public class PermissionDefinitionContext : IPermissionDefinitionContext public virtual PermissionGroupDefinition AddGroup( string name, - ILocalizableString displayName = null) + ILocalizableString? displayName = null) { Check.NotNull(name, nameof(name)); @@ -45,7 +45,7 @@ public class PermissionDefinitionContext : IPermissionDefinitionContext return group; } - public virtual PermissionGroupDefinition GetGroupOrNull([NotNull] string name) + public virtual PermissionGroupDefinition? GetGroupOrNull([NotNull] string name) { Check.NotNull(name, nameof(name)); @@ -69,7 +69,7 @@ public class PermissionDefinitionContext : IPermissionDefinitionContext Groups.Remove(name); } - public virtual PermissionDefinition GetPermissionOrNull([NotNull] string name) + public virtual PermissionDefinition? GetPermissionOrNull([NotNull] string name) { Check.NotNull(name, nameof(name)); diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionGrantInfo.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionGrantInfo.cs index 80031e5ea2..d348aeef79 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionGrantInfo.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionGrantInfo.cs @@ -8,11 +8,11 @@ public class PermissionGrantInfo public bool IsGranted { get; } - public string ProviderName { get; } + public string? ProviderName { get; } - public string ProviderKey { get; } + public string? ProviderKey { get; } - public PermissionGrantInfo([NotNull] string name, bool isGranted, [CanBeNull] string providerName = null, [CanBeNull] string providerKey = null) + public PermissionGrantInfo([NotNull] string name, bool isGranted, string? providerName = null, string? providerKey = null) { Check.NotNull(name, nameof(name)); diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionGroupDefinition.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionGroupDefinition.cs index 9fd904f54c..bbc6e96cdf 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionGroupDefinition.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionGroupDefinition.cs @@ -13,13 +13,13 @@ public class PermissionGroupDefinition : ICanAddChildPermission /// public string Name { get; } - public Dictionary Properties { get; } + public Dictionary Properties { get; } public ILocalizableString DisplayName { get => _displayName; set => _displayName = Check.NotNull(value, nameof(value)); } - private ILocalizableString _displayName; + private ILocalizableString _displayName = default!; public IReadOnlyList Permissions => _permissions.ToImmutableList(); private readonly List _permissions; @@ -32,25 +32,25 @@ public class PermissionGroupDefinition : ICanAddChildPermission /// Returns the value in the dictionary by given . /// Returns null if given is not present in the dictionary. /// - public object this[string name] { + public object? this[string name] { get => Properties.GetOrDefault(name); set => Properties[name] = value; } protected internal PermissionGroupDefinition( string name, - ILocalizableString displayName = null) + ILocalizableString? displayName = null) { Name = name; DisplayName = displayName ?? new FixedLocalizableString(Name); - Properties = new Dictionary(); + Properties = new Dictionary(); _permissions = new List(); } public virtual PermissionDefinition AddPermission( [NotNull] string name, - ILocalizableString displayName = null, + ILocalizableString? displayName = null, MultiTenancySides multiTenancySide = MultiTenancySides.Both, bool isEnabled = true) { @@ -93,15 +93,14 @@ public class PermissionGroupDefinition : ICanAddChildPermission return $"[{nameof(PermissionGroupDefinition)} {Name}]"; } - [CanBeNull] - public PermissionDefinition GetPermissionOrNull([NotNull] string name) + public PermissionDefinition? GetPermissionOrNull([NotNull] string name) { Check.NotNull(name, nameof(name)); return GetPermissionOrNullRecursively(Permissions, name); } - private PermissionDefinition GetPermissionOrNullRecursively( + private PermissionDefinition? GetPermissionOrNullRecursively( IReadOnlyList permissions, string name) { foreach (var permission in permissions) diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionStateContext.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionStateContext.cs index a18aef117e..3398dd420e 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionStateContext.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionStateContext.cs @@ -4,7 +4,7 @@ namespace Volo.Abp.Authorization.Permissions; public class PermissionStateContext { - public IServiceProvider ServiceProvider { get; set; } + public IServiceProvider ServiceProvider { get; set; } = default!; - public PermissionDefinition Permission { get; set; } + public PermissionDefinition Permission { get; set; } = default!; } From 50bd9ac75b198261e622cfd812f6f7f888e5f058 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 10:25:41 +0800 Subject: [PATCH 05/15] Enable nullable annotations for Volo.Abp.Authorization --- .../Permissions/IPermissionDefinitionManager.cs | 3 +-- .../Authorization/Permissions/PermissionValueCheckContext.cs | 5 ++--- .../Permissions/PermissionValuesCheckContext.cs | 5 ++--- .../Volo/Abp/Authorization/Permissions/PermissionChecker.cs | 4 ++-- .../Authorization/Permissions/PermissionDefinitionManager.cs | 2 +- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionDefinitionManager.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionDefinitionManager.cs index b4628a15bc..ca04b110f7 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionDefinitionManager.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/IPermissionDefinitionManager.cs @@ -9,8 +9,7 @@ public interface IPermissionDefinitionManager [ItemNotNull] Task GetAsync([NotNull] string name); - [ItemCanBeNull] - Task GetOrNullAsync([NotNull] string name); + Task GetOrNullAsync([NotNull] string name); Task> GetPermissionsAsync(); diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionValueCheckContext.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionValueCheckContext.cs index 5e32651263..22995b1dd5 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionValueCheckContext.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionValueCheckContext.cs @@ -8,12 +8,11 @@ public class PermissionValueCheckContext [NotNull] public PermissionDefinition Permission { get; } - [CanBeNull] - public ClaimsPrincipal Principal { get; } + public ClaimsPrincipal? Principal { get; } public PermissionValueCheckContext( [NotNull] PermissionDefinition permission, - [CanBeNull] ClaimsPrincipal principal) + ClaimsPrincipal? principal) { Check.NotNull(permission, nameof(permission)); diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionValuesCheckContext.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionValuesCheckContext.cs index 2406f2ee5f..dc5957e3b4 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionValuesCheckContext.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/PermissionValuesCheckContext.cs @@ -9,12 +9,11 @@ public class PermissionValuesCheckContext [NotNull] public List Permissions { get; } - [CanBeNull] - public ClaimsPrincipal Principal { get; } + public ClaimsPrincipal? Principal { get; } public PermissionValuesCheckContext( [NotNull] List permissions, - [CanBeNull] ClaimsPrincipal principal) + ClaimsPrincipal? principal) { Check.NotNull(permissions, nameof(permissions)); diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs index 168eb3064b..f2c3d39dd7 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs @@ -38,7 +38,7 @@ public class PermissionChecker : IPermissionChecker, ITransientDependency } public virtual async Task IsGrantedAsync( - ClaimsPrincipal claimsPrincipal, + ClaimsPrincipal? claimsPrincipal, string name) { Check.NotNull(name, nameof(name)); @@ -97,7 +97,7 @@ public class PermissionChecker : IPermissionChecker, ITransientDependency return await IsGrantedAsync(PrincipalAccessor.Principal, names); } - public async Task IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string[] names) + public async Task IsGrantedAsync(ClaimsPrincipal? claimsPrincipal, string[] names) { Check.NotNull(names, nameof(names)); diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionDefinitionManager.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionDefinitionManager.cs index de24ff59c5..23f9e7883e 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionDefinitionManager.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionDefinitionManager.cs @@ -30,7 +30,7 @@ public class PermissionDefinitionManager : IPermissionDefinitionManager, ITransi return permission; } - public virtual async Task GetOrNullAsync(string name) + public virtual async Task GetOrNullAsync(string name) { Check.NotNull(name, nameof(name)); From 0611f68d7a4d26abbcf0ca17ac2e3d0bc3471b13 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 10:29:43 +0800 Subject: [PATCH 06/15] Enable nullable annotations for Volo.Abp.AutoMapper --- .../AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs | 2 +- framework/src/Volo.Abp.AutoMapper/Volo.Abp.AutoMapper.csproj | 2 ++ .../Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/MapperAccessor.cs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs b/framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs index 5085eecdc2..a564edf18f 100644 --- a/framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs +++ b/framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs @@ -10,7 +10,7 @@ public static class AbpAutoMapperExtensibleDtoExtensions public static IMappingExpression MapExtraProperties( this IMappingExpression mappingExpression, MappingPropertyDefinitionChecks? definitionChecks = null, - string[] ignoredProperties = null, + string[]? ignoredProperties = null, bool mapToRegularProperties = false) where TDestination : IHasExtraProperties where TSource : IHasExtraProperties diff --git a/framework/src/Volo.Abp.AutoMapper/Volo.Abp.AutoMapper.csproj b/framework/src/Volo.Abp.AutoMapper/Volo.Abp.AutoMapper.csproj index f1408e38e2..e5c78948ba 100644 --- a/framework/src/Volo.Abp.AutoMapper/Volo.Abp.AutoMapper.csproj +++ b/framework/src/Volo.Abp.AutoMapper/Volo.Abp.AutoMapper.csproj @@ -5,6 +5,8 @@ netstandard2.1 + enable + Nullable Volo.Abp.AutoMapper Volo.Abp.AutoMapper $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/MapperAccessor.cs b/framework/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/MapperAccessor.cs index 7e2f94819f..5751180185 100644 --- a/framework/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/MapperAccessor.cs +++ b/framework/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/MapperAccessor.cs @@ -4,5 +4,5 @@ namespace Volo.Abp.AutoMapper; internal class MapperAccessor : IMapperAccessor { - public IMapper Mapper { get; set; } + public IMapper Mapper { get; set; } = default!; } From f0e6f601241650f871bc485b5822fa35d2272209 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 10:49:53 +0800 Subject: [PATCH 07/15] Enable nullable annotations for Volo.Abp.ObjectMapping --- .../Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs | 4 ++-- .../Volo.Abp.ObjectMapping/Volo.Abp.ObjectMapping.csproj | 2 ++ .../Volo/Abp/ObjectMapping/DefaultObjectMapper.cs | 6 +++--- .../Volo/Abp/ObjectMapping/ObjectMapperExtensions.cs | 8 ++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs index 3274c5010c..a2fca1f127 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs @@ -21,7 +21,7 @@ public class RemotePermissionChecker : IPermissionChecker, ITransientDependency return configuration.Auth.GrantedPolicies.ContainsKey(name); } - public async Task IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string name) + public async Task IsGrantedAsync(ClaimsPrincipal? claimsPrincipal, string name) { /* This provider always works for the current principal. */ return await IsGrantedAsync(name); @@ -41,7 +41,7 @@ public class RemotePermissionChecker : IPermissionChecker, ITransientDependency return result; } - public async Task IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string[] names) + public async Task IsGrantedAsync(ClaimsPrincipal? claimsPrincipal, string[] names) { /* This provider always works for the current principal. */ return await IsGrantedAsync(names); diff --git a/framework/src/Volo.Abp.ObjectMapping/Volo.Abp.ObjectMapping.csproj b/framework/src/Volo.Abp.ObjectMapping/Volo.Abp.ObjectMapping.csproj index 14d738ab6c..db27274909 100644 --- a/framework/src/Volo.Abp.ObjectMapping/Volo.Abp.ObjectMapping.csproj +++ b/framework/src/Volo.Abp.ObjectMapping/Volo.Abp.ObjectMapping.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.ObjectMapping Volo.Abp.ObjectMapping $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.ObjectMapping/Volo/Abp/ObjectMapping/DefaultObjectMapper.cs b/framework/src/Volo.Abp.ObjectMapping/Volo/Abp/ObjectMapping/DefaultObjectMapper.cs index 4c57630a44..7048d183c7 100644 --- a/framework/src/Volo.Abp.ObjectMapping/Volo/Abp/ObjectMapping/DefaultObjectMapper.cs +++ b/framework/src/Volo.Abp.ObjectMapping/Volo/Abp/ObjectMapping/DefaultObjectMapper.cs @@ -36,7 +36,7 @@ public class DefaultObjectMapper : IObjectMapper, ITransientDependency { if (source == null) { - return default; + return default!; } using (var scope = ServiceProvider.CreateScope()) @@ -60,7 +60,7 @@ public class DefaultObjectMapper : IObjectMapper, ITransientDependency //TODO: Check if TDestination has a proper constructor which takes TSource //TODO: Check if TDestination has an empty constructor (in this case, use MapFrom) - return (TDestination)Activator.CreateInstance(typeof(TDestination), source); + return (TDestination)Activator.CreateInstance(typeof(TDestination), source)!; } catch { @@ -75,7 +75,7 @@ public class DefaultObjectMapper : IObjectMapper, ITransientDependency { if (source == null) { - return default; + return default!; } using (var scope = ServiceProvider.CreateScope()) diff --git a/framework/src/Volo.Abp.ObjectMapping/Volo/Abp/ObjectMapping/ObjectMapperExtensions.cs b/framework/src/Volo.Abp.ObjectMapping/Volo/Abp/ObjectMapping/ObjectMapperExtensions.cs index a99f977002..9a501fe35e 100644 --- a/framework/src/Volo.Abp.ObjectMapping/Volo/Abp/ObjectMapping/ObjectMapperExtensions.cs +++ b/framework/src/Volo.Abp.ObjectMapping/Volo/Abp/ObjectMapping/ObjectMapperExtensions.cs @@ -5,8 +5,8 @@ namespace Volo.Abp.ObjectMapping; public static class ObjectMapperExtensions { - private static readonly MethodInfo MapToNewObjectMethod; - private static readonly MethodInfo MapToExistingObjectMethod; + private static readonly MethodInfo MapToNewObjectMethod = default!; + private static readonly MethodInfo MapToExistingObjectMethod = default!; static ObjectMapperExtensions() { @@ -32,13 +32,13 @@ public static class ObjectMapperExtensions { return MapToNewObjectMethod .MakeGenericMethod(sourceType, destinationType) - .Invoke(objectMapper, new[] { source }); + .Invoke(objectMapper, new[] { source })!; } public static object Map(this IObjectMapper objectMapper, Type sourceType, Type destinationType, object source, object destination) { return MapToExistingObjectMethod .MakeGenericMethod(sourceType, destinationType) - .Invoke(objectMapper, new[] { source, destination }); + .Invoke(objectMapper, new[] { source, destination })!; } } From 39dd64e96e8347711e91dc5be09686af9b29c80f Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 11:16:13 +0800 Subject: [PATCH 08/15] Enable nullable annotations for Volo.Abp.Features --- .../ApplicationFeatureConfigurationDto.cs | 4 +- .../IDynamicPermissionDefinitionStore.cs | 2 +- .../NullDynamicPermissionDefinitionStore.cs | 4 +- .../Volo.Abp.Features.csproj | 2 + .../DefaultValueFeatureValueProvider.cs | 4 +- .../Features/EditionFeatureValueProvider.cs | 2 +- .../Volo/Abp/Features/FeatureChecker.cs | 6 +-- .../Volo/Abp/Features/FeatureCheckerBase.cs | 4 +- .../Volo/Abp/Features/FeatureDefinition.cs | 45 +++++++++---------- .../Abp/Features/FeatureDefinitionContext.cs | 4 +- .../Abp/Features/FeatureDefinitionManager.cs | 2 +- .../Abp/Features/FeatureGroupDefinition.cs | 26 +++++------ .../Volo/Abp/Features/FeatureValueProvider.cs | 2 +- ...SimpleStateCheckerSerializerContributor.cs | 6 +-- .../Abp/Features/ICanCreateChildFeature.cs | 8 ++-- .../IDynamicFeatureDefinitionStore.cs | 2 +- .../Volo/Abp/Features/IFeatureChecker.cs | 2 +- .../Abp/Features/IFeatureDefinitionContext.cs | 4 +- .../Abp/Features/IFeatureDefinitionManager.cs | 2 +- .../Volo/Abp/Features/IFeatureStore.cs | 6 +-- .../Abp/Features/IFeatureValueProvider.cs | 2 +- .../Features/IStaticFeatureDefinitionStore.cs | 2 +- .../MethodInvocationFeatureCheckerService.cs | 2 +- .../NullDynamicFeatureDefinitionStore.cs | 4 +- .../Volo/Abp/Features/NullFeatureStore.cs | 4 +- .../Features/StaticFeatureDefinitionStore.cs | 4 +- .../Features/TenantFeatureValueProvider.cs | 2 +- 27 files changed, 77 insertions(+), 80 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationFeatureConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationFeatureConfigurationDto.cs index 9215a46616..4aa022b8c5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationFeatureConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationFeatureConfigurationDto.cs @@ -6,10 +6,10 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; [Serializable] public class ApplicationFeatureConfigurationDto { - public Dictionary Values { get; set; } + public Dictionary Values { get; set; } public ApplicationFeatureConfigurationDto() { - Values = new Dictionary(); + Values = new Dictionary(); } } diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/IDynamicPermissionDefinitionStore.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/IDynamicPermissionDefinitionStore.cs index ad74dae46b..366ae2e58a 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/IDynamicPermissionDefinitionStore.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/IDynamicPermissionDefinitionStore.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.Authorization.Permissions; public interface IDynamicPermissionDefinitionStore { - Task GetOrNullAsync(string name); + Task GetOrNullAsync(string name); Task> GetPermissionsAsync(); diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/NullDynamicPermissionDefinitionStore.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/NullDynamicPermissionDefinitionStore.cs index b070b6af96..5b13288153 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/NullDynamicPermissionDefinitionStore.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/NullDynamicPermissionDefinitionStore.cs @@ -8,7 +8,7 @@ namespace Volo.Abp.Authorization.Permissions; public class NullDynamicPermissionDefinitionStore : IDynamicPermissionDefinitionStore, ISingletonDependency { - private readonly static Task CachedPermissionResult = Task.FromResult((PermissionDefinition)null!); + private readonly static Task CachedPermissionResult = Task.FromResult((PermissionDefinition?)null); private readonly static Task> CachedPermissionsResult = Task.FromResult((IReadOnlyList)Array.Empty().ToImmutableList()); @@ -16,7 +16,7 @@ public class NullDynamicPermissionDefinitionStore : IDynamicPermissionDefinition private readonly static Task> CachedGroupsResult = Task.FromResult((IReadOnlyList)Array.Empty().ToImmutableList()); - public Task GetOrNullAsync(string name) + public Task GetOrNullAsync(string name) { return CachedPermissionResult; } diff --git a/framework/src/Volo.Abp.Features/Volo.Abp.Features.csproj b/framework/src/Volo.Abp.Features/Volo.Abp.Features.csproj index 08f5621892..ce7fb86176 100644 --- a/framework/src/Volo.Abp.Features/Volo.Abp.Features.csproj +++ b/framework/src/Volo.Abp.Features/Volo.Abp.Features.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Features Volo.Abp.Features $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/DefaultValueFeatureValueProvider.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/DefaultValueFeatureValueProvider.cs index c2784763b2..1fb35e9605 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/DefaultValueFeatureValueProvider.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/DefaultValueFeatureValueProvider.cs @@ -14,8 +14,8 @@ public class DefaultValueFeatureValueProvider : FeatureValueProvider //TODO: Dir } - public override Task GetOrNullAsync(FeatureDefinition setting) + public override Task GetOrNullAsync(FeatureDefinition setting) { - return Task.FromResult(setting.DefaultValue); + return Task.FromResult(setting.DefaultValue); } } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs index 6d74264637..94822284f5 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs @@ -18,7 +18,7 @@ public class EditionFeatureValueProvider : FeatureValueProvider PrincipalAccessor = principalAccessor; } - public override async Task GetOrNullAsync(FeatureDefinition feature) + public override async Task GetOrNullAsync(FeatureDefinition feature) { var editionId = PrincipalAccessor.Principal?.FindEditionId(); if (editionId == null) diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureChecker.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureChecker.cs index 9554860078..c2a4a71ab3 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureChecker.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureChecker.cs @@ -29,13 +29,13 @@ public class FeatureChecker : FeatureCheckerBase _providers = new Lazy>( () => Options .ValueProviders - .Select(type => ServiceProvider.GetRequiredService(type) as IFeatureValueProvider) + .Select(type => (ServiceProvider.GetRequiredService(type) as IFeatureValueProvider)!) .ToList(), true ); } - public override async Task GetOrNullAsync(string name) + public override async Task GetOrNullAsync(string name) { var featureDefinition = await FeatureDefinitionManager.GetAsync(name); var providers = Enumerable @@ -49,7 +49,7 @@ public class FeatureChecker : FeatureCheckerBase return await GetOrNullValueFromProvidersAsync(providers, featureDefinition); } - protected virtual async Task GetOrNullValueFromProvidersAsync( + protected virtual async Task GetOrNullValueFromProvidersAsync( IEnumerable providers, FeatureDefinition feature) { diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs index 893b5bbc1c..f17213af2a 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs @@ -6,7 +6,7 @@ namespace Volo.Abp.Features; public abstract class FeatureCheckerBase : IFeatureChecker, ITransientDependency { - public abstract Task GetOrNullAsync(string name); + public abstract Task GetOrNullAsync(string name); public virtual async Task IsEnabledAsync(string name) { @@ -18,7 +18,7 @@ public abstract class FeatureCheckerBase : IFeatureChecker, ITransientDependency try { - return bool.Parse(value); + return bool.Parse(value!); } catch (Exception ex) { diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs index 1a1e2ece3b..92f8b8d527 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs @@ -20,17 +20,15 @@ public class FeatureDefinition : ICanCreateChildFeature 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; } /// /// Parent of this feature, if one exists. /// If set, this feature can be enabled only if the parent is enabled. /// - [CanBeNull] - public FeatureDefinition Parent { get; private set; } + public FeatureDefinition? Parent { get; private set; } /// /// List of child features. @@ -41,8 +39,7 @@ public class FeatureDefinition : ICanCreateChildFeature /// /// Default value of the feature. /// - [CanBeNull] - public string DefaultValue { get; set; } + public string? DefaultValue { get; set; } /// /// Can clients see this feature and it's value. @@ -71,8 +68,7 @@ public class FeatureDefinition : ICanCreateChildFeature /// 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; } @@ -81,22 +77,21 @@ public class FeatureDefinition : ICanCreateChildFeature /// Can be used to get/set custom properties for this feature. /// [NotNull] - public Dictionary Properties { get; } + public Dictionary Properties { get; } /// /// Input type. /// This can be used to prepare an input for changing this feature's value. /// Default: . /// - [CanBeNull] - public IStringValueType ValueType { get; set; } + public IStringValueType? ValueType { get; set; } public FeatureDefinition( string name, - string defaultValue = null, - ILocalizableString displayName = null, - ILocalizableString description = null, - IStringValueType valueType = null, + string? defaultValue = null, + ILocalizableString? displayName = null, + ILocalizableString? description = null, + IStringValueType? valueType = null, bool isVisibleToClients = true, bool isAvailableToHost = true) { @@ -108,7 +103,7 @@ public class FeatureDefinition : ICanCreateChildFeature IsVisibleToClients = isVisibleToClients; IsAvailableToHost = isAvailableToHost; - Properties = new Dictionary(); + Properties = new Dictionary(); AllowedProviders = new List(); _children = new List(); } @@ -143,10 +138,10 @@ public class FeatureDefinition : ICanCreateChildFeature /// Returns a newly created child feature public FeatureDefinition CreateChild( string name, - string defaultValue = null, - ILocalizableString displayName = null, - ILocalizableString description = null, - IStringValueType valueType = null, + string? defaultValue = null, + ILocalizableString? displayName = null, + ILocalizableString? description = null, + IStringValueType? valueType = null, bool isVisibleToClients = true, bool isAvailableToHost = true) { @@ -179,10 +174,10 @@ public class FeatureDefinition : ICanCreateChildFeature } public FeatureDefinition CreateChildFeature(string name, - string defaultValue = null, - ILocalizableString displayName = null, - ILocalizableString description = null, - IStringValueType valueType = null, + string? defaultValue = null, + ILocalizableString? displayName = null, + ILocalizableString? description = null, + IStringValueType? valueType = null, bool isVisibleToClients = true, bool isAvailableToHost = true) { diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinitionContext.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinitionContext.cs index 1a64f4a38c..2e9bf4cf63 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinitionContext.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinitionContext.cs @@ -12,7 +12,7 @@ public class FeatureDefinitionContext : IFeatureDefinitionContext Groups = new Dictionary(); } - public FeatureGroupDefinition AddGroup(string name, ILocalizableString displayName = null) + public FeatureGroupDefinition AddGroup(string name, ILocalizableString? displayName = null) { Check.NotNull(name, nameof(name)); @@ -24,7 +24,7 @@ public class FeatureDefinitionContext : IFeatureDefinitionContext return Groups[name] = new FeatureGroupDefinition(name, displayName); } - public FeatureGroupDefinition GetGroupOrNull(string name) + public FeatureGroupDefinition? GetGroupOrNull(string name) { Check.NotNull(name, nameof(name)); diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinitionManager.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinitionManager.cs index d0293d5859..2ddba43eec 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinitionManager.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinitionManager.cs @@ -31,7 +31,7 @@ public class FeatureDefinitionManager : IFeatureDefinitionManager, ISingletonDep return permission; } - public virtual async Task GetOrNullAsync(string name) + public virtual async Task GetOrNullAsync(string name) { Check.NotNull(name, nameof(name)); diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureGroupDefinition.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureGroupDefinition.cs index 8cd6289112..ba9ebc9209 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureGroupDefinition.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureGroupDefinition.cs @@ -12,13 +12,13 @@ public class FeatureGroupDefinition : ICanCreateChildFeature /// public string Name { get; } - public Dictionary Properties { get; } + public Dictionary Properties { get; } public ILocalizableString DisplayName { get => _displayName; set => _displayName = Check.NotNull(value, nameof(value)); } - private ILocalizableString _displayName; + private ILocalizableString _displayName = default!; public IReadOnlyList Features => _features.ToImmutableList(); private readonly List _features; @@ -31,28 +31,28 @@ public class FeatureGroupDefinition : ICanCreateChildFeature /// Returns the value in the dictionary by given . /// Returns null if given is not present in the dictionary. /// - public object this[string name] { + public object? this[string name] { get => Properties.GetOrDefault(name); set => Properties[name] = value; } protected internal FeatureGroupDefinition( string name, - ILocalizableString displayName = null) + ILocalizableString? displayName = null) { Name = name; DisplayName = displayName ?? new FixedLocalizableString(Name); - Properties = new Dictionary(); + Properties = new Dictionary(); _features = new List(); } public virtual FeatureDefinition AddFeature( string name, - string defaultValue = null, - ILocalizableString displayName = null, - ILocalizableString description = null, - IStringValueType valueType = null, + string? defaultValue = null, + ILocalizableString? displayName = null, + ILocalizableString? description = null, + IStringValueType? valueType = null, bool isVisibleToClients = true, bool isAvailableToHost = true) { @@ -72,10 +72,10 @@ public class FeatureGroupDefinition : ICanCreateChildFeature } public FeatureDefinition CreateChildFeature(string name, - string defaultValue = null, - ILocalizableString displayName = null, - ILocalizableString description = null, - IStringValueType valueType = null, + string? defaultValue = null, + ILocalizableString? displayName = null, + ILocalizableString? description = null, + IStringValueType? valueType = null, bool isVisibleToClients = true, bool isAvailableToHost = true) { diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureValueProvider.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureValueProvider.cs index f2fe74db4b..ec7c7d0451 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureValueProvider.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureValueProvider.cs @@ -14,5 +14,5 @@ public abstract class FeatureValueProvider : IFeatureValueProvider, ITransientDe FeatureStore = featureStore; } - public abstract Task GetOrNullAsync(FeatureDefinition feature); + public abstract Task GetOrNullAsync(FeatureDefinition feature); } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeaturesSimpleStateCheckerSerializerContributor.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeaturesSimpleStateCheckerSerializerContributor.cs index 58e2817139..c604cb75b4 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeaturesSimpleStateCheckerSerializerContributor.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeaturesSimpleStateCheckerSerializerContributor.cs @@ -11,7 +11,7 @@ public class FeaturesSimpleStateCheckerSerializerContributor : { public const string CheckerShortName = "F"; - public string SerializeToJson(ISimpleStateChecker checker) + public string? SerializeToJson(ISimpleStateChecker checker) where TState : IHasSimpleStateCheckers { if (checker is not RequireFeaturesSimpleStateChecker featuresSimpleStateChecker) @@ -34,7 +34,7 @@ public class FeaturesSimpleStateCheckerSerializerContributor : return jsonObject.ToJsonString(); } - public ISimpleStateChecker Deserialize(JsonObject jsonObject, TState state) + public ISimpleStateChecker? Deserialize(JsonObject jsonObject, TState state) where TState : IHasSimpleStateCheckers { if (jsonObject["T"]?.ToString() != CheckerShortName) @@ -50,7 +50,7 @@ public class FeaturesSimpleStateCheckerSerializerContributor : return new RequireFeaturesSimpleStateChecker( (bool?)jsonObject["A"] ?? false, - nameArray.Select(x => x.ToString()).ToArray() + nameArray.Select(x => x!.ToString()).ToArray() ); } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/ICanCreateChildFeature.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/ICanCreateChildFeature.cs index ecba11e31e..e81327e45a 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/ICanCreateChildFeature.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/ICanCreateChildFeature.cs @@ -7,10 +7,10 @@ public interface ICanCreateChildFeature { FeatureDefinition CreateChildFeature( string name, - string defaultValue = null, - ILocalizableString displayName = null, - ILocalizableString description = null, - IStringValueType valueType = null, + string? defaultValue = null, + ILocalizableString? displayName = null, + ILocalizableString? description = null, + IStringValueType? valueType = null, bool isVisibleToClients = true, bool isAvailableToHost = true); } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IDynamicFeatureDefinitionStore.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IDynamicFeatureDefinitionStore.cs index 90fe14a5e0..91b7fd9bfd 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IDynamicFeatureDefinitionStore.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IDynamicFeatureDefinitionStore.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.Features; public interface IDynamicFeatureDefinitionStore { - Task GetOrNullAsync(string name); + Task GetOrNullAsync(string name); Task> GetFeaturesAsync(); diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureChecker.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureChecker.cs index ad7106994e..501c5ff8f8 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureChecker.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureChecker.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.Features; public interface IFeatureChecker { - Task GetOrNullAsync([NotNull] string name); + Task GetOrNullAsync([NotNull] string name); Task IsEnabledAsync(string name); } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureDefinitionContext.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureDefinitionContext.cs index 13dcb72cdb..0a8773f903 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureDefinitionContext.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureDefinitionContext.cs @@ -5,9 +5,9 @@ namespace Volo.Abp.Features; public interface IFeatureDefinitionContext { - FeatureGroupDefinition AddGroup([NotNull] string name, ILocalizableString displayName = null); + FeatureGroupDefinition AddGroup([NotNull] string name, ILocalizableString? displayName = null); - FeatureGroupDefinition GetGroupOrNull(string name); + FeatureGroupDefinition? GetGroupOrNull(string name); void RemoveGroup(string name); } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureDefinitionManager.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureDefinitionManager.cs index f0201937df..770d7d6dee 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureDefinitionManager.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureDefinitionManager.cs @@ -11,7 +11,7 @@ public interface IFeatureDefinitionManager Task> GetAllAsync(); - Task GetOrNullAsync(string name); + Task GetOrNullAsync(string name); Task> GetGroupsAsync(); } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureStore.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureStore.cs index e03417791d..c798d0890b 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureStore.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureStore.cs @@ -5,9 +5,9 @@ namespace Volo.Abp.Features; public interface IFeatureStore { - Task GetOrNullAsync( + Task GetOrNullAsync( [NotNull] string name, - [CanBeNull] string providerName, - [CanBeNull] string providerKey + string? providerName, + string? providerKey ); } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureValueProvider.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureValueProvider.cs index 00ca66695f..4a222d3687 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureValueProvider.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IFeatureValueProvider.cs @@ -7,5 +7,5 @@ public interface IFeatureValueProvider { string Name { get; } - Task GetOrNullAsync([NotNull] FeatureDefinition feature); + Task GetOrNullAsync([NotNull] FeatureDefinition feature); } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IStaticFeatureDefinitionStore.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IStaticFeatureDefinitionStore.cs index 586747904e..b5d244376d 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/IStaticFeatureDefinitionStore.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/IStaticFeatureDefinitionStore.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.Features; public interface IStaticFeatureDefinitionStore { - Task GetOrNullAsync(string name); + Task GetOrNullAsync(string name); Task> GetFeaturesAsync(); diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/MethodInvocationFeatureCheckerService.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/MethodInvocationFeatureCheckerService.cs index 2add78965a..5d24f3f60f 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/MethodInvocationFeatureCheckerService.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/MethodInvocationFeatureCheckerService.cs @@ -47,7 +47,7 @@ public class MethodInvocationFeatureCheckerService : IMethodInvocationFeatureChe { attributes = attributes .Union( - methodInfo.DeclaringType + methodInfo.DeclaringType! .GetCustomAttributes(true) .OfType() ); diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/NullDynamicFeatureDefinitionStore.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/NullDynamicFeatureDefinitionStore.cs index 63e7b476c4..4a75e66b7d 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/NullDynamicFeatureDefinitionStore.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/NullDynamicFeatureDefinitionStore.cs @@ -8,7 +8,7 @@ namespace Volo.Abp.Features; public class NullDynamicFeatureDefinitionStore : IDynamicFeatureDefinitionStore, ISingletonDependency { - private static readonly Task CachedFeatureResult = Task.FromResult((FeatureDefinition)null); + private static readonly Task CachedFeatureResult = Task.FromResult((FeatureDefinition?)null); private static readonly Task> CachedFeaturesResult = Task.FromResult((IReadOnlyList)Array.Empty().ToImmutableList()); @@ -16,7 +16,7 @@ public class NullDynamicFeatureDefinitionStore : IDynamicFeatureDefinitionStore, private static readonly Task> CachedGroupsResult = Task.FromResult((IReadOnlyList)Array.Empty().ToImmutableList()); - public Task GetOrNullAsync(string name) + public Task GetOrNullAsync(string name) { return CachedFeatureResult; } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/NullFeatureStore.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/NullFeatureStore.cs index 011ae0861d..1a43fca6c1 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/NullFeatureStore.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/NullFeatureStore.cs @@ -15,8 +15,8 @@ public class NullFeatureStore : IFeatureStore, 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); } } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/StaticFeatureDefinitionStore.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/StaticFeatureDefinitionStore.cs index 7d683d6caf..d0647168d3 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/StaticFeatureDefinitionStore.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/StaticFeatureDefinitionStore.cs @@ -92,7 +92,7 @@ public class StaticFeatureDefinitionStore: IStaticFeatureDefinitionStore, ISingl { var providers = Options .DefinitionProviders - .Select(p => scope.ServiceProvider.GetRequiredService(p) as IFeatureDefinitionProvider) + .Select(p => (scope.ServiceProvider.GetRequiredService(p) as IFeatureDefinitionProvider)!) .ToList(); foreach (var provider in providers) @@ -104,7 +104,7 @@ public class StaticFeatureDefinitionStore: IStaticFeatureDefinitionStore, ISingl return context.Groups; } - public virtual Task GetOrNullAsync(string name) + public virtual Task GetOrNullAsync(string name) { return Task.FromResult(FeatureDefinitions.GetOrDefault(name)); } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/TenantFeatureValueProvider.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/TenantFeatureValueProvider.cs index 669814307d..416ce54112 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/TenantFeatureValueProvider.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/TenantFeatureValueProvider.cs @@ -17,7 +17,7 @@ public class TenantFeatureValueProvider : FeatureValueProvider CurrentTenant = currentTenant; } - public override async Task GetOrNullAsync(FeatureDefinition feature) + public override async Task GetOrNullAsync(FeatureDefinition feature) { return await FeatureStore.GetOrNullAsync(feature.Name, Name, CurrentTenant.Id?.ToString()); } From a8ad895c6f6dea93f0dd69670439dd640751c8f1 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 11:23:28 +0800 Subject: [PATCH 09/15] Enable nullable annotations for Volo.Abp.FluentValidation --- .../Volo.Abp.FluentValidation.csproj | 2 ++ .../AbpFluentValidationConventionalRegistrar.cs | 6 +++--- .../FluentValidation/FluentObjectValidationContributor.cs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.FluentValidation/Volo.Abp.FluentValidation.csproj b/framework/src/Volo.Abp.FluentValidation/Volo.Abp.FluentValidation.csproj index af4f5c21c0..2ad46ae78a 100644 --- a/framework/src/Volo.Abp.FluentValidation/Volo.Abp.FluentValidation.csproj +++ b/framework/src/Volo.Abp.FluentValidation/Volo.Abp.FluentValidation.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.FluentValidation Volo.Abp.FluentValidation $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.FluentValidation/Volo/Abp/FluentValidation/AbpFluentValidationConventionalRegistrar.cs b/framework/src/Volo.Abp.FluentValidation/Volo/Abp/FluentValidation/AbpFluentValidationConventionalRegistrar.cs index e8d11d0416..5923949b0e 100644 --- a/framework/src/Volo.Abp.FluentValidation/Volo/Abp/FluentValidation/AbpFluentValidationConventionalRegistrar.cs +++ b/framework/src/Volo.Abp.FluentValidation/Volo/Abp/FluentValidation/AbpFluentValidationConventionalRegistrar.cs @@ -24,11 +24,11 @@ public class AbpFluentValidationConventionalRegistrar : DefaultConventionalRegis { return new List() { - typeof(IValidator<>).MakeGenericType(GetFirstGenericArgumentOrNull(type, 1)) + typeof(IValidator<>).MakeGenericType(GetFirstGenericArgumentOrNull(type, 1)!) }; } - private static Type GetFirstGenericArgumentOrNull(Type type, int depth) + private static Type? GetFirstGenericArgumentOrNull(Type type, int depth) { const int maxFindDepth = 8; @@ -42,6 +42,6 @@ public class AbpFluentValidationConventionalRegistrar : DefaultConventionalRegis return type.GetGenericArguments()[0]; } - return GetFirstGenericArgumentOrNull(type.BaseType, depth + 1); + return GetFirstGenericArgumentOrNull(type.BaseType!, depth + 1); } } diff --git a/framework/src/Volo.Abp.FluentValidation/Volo/Abp/FluentValidation/FluentObjectValidationContributor.cs b/framework/src/Volo.Abp.FluentValidation/Volo/Abp/FluentValidation/FluentObjectValidationContributor.cs index 596860cffc..b13b393218 100644 --- a/framework/src/Volo.Abp.FluentValidation/Volo/Abp/FluentValidation/FluentObjectValidationContributor.cs +++ b/framework/src/Volo.Abp.FluentValidation/Volo/Abp/FluentValidation/FluentObjectValidationContributor.cs @@ -29,7 +29,7 @@ public class FluentObjectValidationContributor : IObjectValidationContributor, I var result = await validator.ValidateAsync((IValidationContext)Activator.CreateInstance( typeof(ValidationContext<>).MakeGenericType(context.ValidatingObject.GetType()), - context.ValidatingObject)); + context.ValidatingObject)!); if (!result.IsValid) { From 8e41bd4c99d0da4e39708a9490a313f3ad7d47ee Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 11:29:09 +0800 Subject: [PATCH 10/15] Enable nullable annotations for Volo.Abp.Gdpr.Abstractions --- .../Volo.Abp.Gdpr.Abstractions.csproj | 2 ++ .../Volo/Abp/Gdpr/GdprUserDataPreparedEto.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Gdpr.Abstractions/Volo.Abp.Gdpr.Abstractions.csproj b/framework/src/Volo.Abp.Gdpr.Abstractions/Volo.Abp.Gdpr.Abstractions.csproj index 412f2f38e4..5bc6664db0 100644 --- a/framework/src/Volo.Abp.Gdpr.Abstractions/Volo.Abp.Gdpr.Abstractions.csproj +++ b/framework/src/Volo.Abp.Gdpr.Abstractions/Volo.Abp.Gdpr.Abstractions.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable diff --git a/framework/src/Volo.Abp.Gdpr.Abstractions/Volo/Abp/Gdpr/GdprUserDataPreparedEto.cs b/framework/src/Volo.Abp.Gdpr.Abstractions/Volo/Abp/Gdpr/GdprUserDataPreparedEto.cs index 3a2c440f97..d52e12783c 100644 --- a/framework/src/Volo.Abp.Gdpr.Abstractions/Volo/Abp/Gdpr/GdprUserDataPreparedEto.cs +++ b/framework/src/Volo.Abp.Gdpr.Abstractions/Volo/Abp/Gdpr/GdprUserDataPreparedEto.cs @@ -7,7 +7,7 @@ public class GdprUserDataPreparedEto { public Guid RequestId { get; set; } - public string Provider { get; set; } + public string Provider { get; set; } = default!; - public GdprDataInfo Data { get; set; } + public GdprDataInfo Data { get; set; } = default!; } \ No newline at end of file From aeadf8bb09196b1391e7b0b5f4f3b35178be6988 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 14:02:56 +0800 Subject: [PATCH 11/15] Enable nullable annotations for Volo.Abp.GlobalFeatures --- .../Volo.Abp.GlobalFeatures/Volo.Abp.GlobalFeatures.csproj | 2 ++ .../GlobalFeatures/AbpGlobalFeatureNotEnabledException.cs | 4 ++-- .../Volo/Abp/GlobalFeatures/GlobalFeatureHelper.cs | 2 +- .../Volo/Abp/GlobalFeatures/GlobalFeatureInterceptor.cs | 4 ++-- ...GlobalFeaturesSimpleStateCheckerSerializerContributor.cs | 6 +++--- .../Abp/GlobalFeatures/RequiresGlobalFeatureAttribute.cs | 6 +++--- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/framework/src/Volo.Abp.GlobalFeatures/Volo.Abp.GlobalFeatures.csproj b/framework/src/Volo.Abp.GlobalFeatures/Volo.Abp.GlobalFeatures.csproj index 7862b829c7..5f6200d037 100644 --- a/framework/src/Volo.Abp.GlobalFeatures/Volo.Abp.GlobalFeatures.csproj +++ b/framework/src/Volo.Abp.GlobalFeatures/Volo.Abp.GlobalFeatures.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.GlobalFeatures Volo.Abp.GlobalFeatures $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/AbpGlobalFeatureNotEnabledException.cs b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/AbpGlobalFeatureNotEnabledException.cs index d089602ba8..8a5c01f635 100644 --- a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/AbpGlobalFeatureNotEnabledException.cs +++ b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/AbpGlobalFeatureNotEnabledException.cs @@ -6,9 +6,9 @@ namespace Volo.Abp.GlobalFeatures; [Serializable] public class AbpGlobalFeatureNotEnabledException : AbpException, IHasErrorCode { - public string Code { get; } + public string? Code { get; } - public AbpGlobalFeatureNotEnabledException(string message = null, string code = null, Exception innerException = null) + public AbpGlobalFeatureNotEnabledException(string? message = null, string? code = null, Exception? innerException = null) : base(message, innerException) { Code = code; diff --git a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureHelper.cs b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureHelper.cs index 1ec847fba2..3e7b56a030 100644 --- a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureHelper.cs +++ b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureHelper.cs @@ -5,7 +5,7 @@ namespace Volo.Abp.GlobalFeatures; public static class GlobalFeatureHelper { - public static bool IsGlobalFeatureEnabled(Type type, out RequiresGlobalFeatureAttribute attribute) + public static bool IsGlobalFeatureEnabled(Type type, out RequiresGlobalFeatureAttribute? attribute) { attribute = ReflectionHelper.GetSingleAttributeOrDefault(type); return attribute == null || GlobalFeatureManager.Instance.IsEnabled(attribute.GetFeatureName()); diff --git a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureInterceptor.cs b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureInterceptor.cs index 275d2299ea..f2a5d65b2c 100644 --- a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureInterceptor.cs +++ b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeatureInterceptor.cs @@ -18,8 +18,8 @@ public class GlobalFeatureInterceptor : AbpInterceptor, ITransientDependency if (!GlobalFeatureHelper.IsGlobalFeatureEnabled(invocation.TargetObject.GetType(), out var attribute)) { throw new AbpGlobalFeatureNotEnabledException(code: AbpGlobalFeatureErrorCodes.GlobalFeatureIsNotEnabled) - .WithData("ServiceName", invocation.TargetObject.GetType().FullName) - .WithData("GlobalFeatureName", attribute.Name); + .WithData("ServiceName", invocation.TargetObject.GetType().FullName!) + .WithData("GlobalFeatureName", attribute!.Name!); } await invocation.ProceedAsync(); diff --git a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeaturesSimpleStateCheckerSerializerContributor.cs b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeaturesSimpleStateCheckerSerializerContributor.cs index d4abc25403..fe8530435b 100644 --- a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeaturesSimpleStateCheckerSerializerContributor.cs +++ b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/GlobalFeaturesSimpleStateCheckerSerializerContributor.cs @@ -11,7 +11,7 @@ public class GlobalFeaturesSimpleStateCheckerSerializerContributor : { public const string CheckerShortName = "G"; - public string SerializeToJson(ISimpleStateChecker checker) + public string? SerializeToJson(ISimpleStateChecker checker) where TState : IHasSimpleStateCheckers { if (checker is not RequireGlobalFeaturesSimpleStateChecker globalFeaturesSimpleStateChecker) @@ -34,7 +34,7 @@ public class GlobalFeaturesSimpleStateCheckerSerializerContributor : return jsonObject.ToJsonString(); } - public ISimpleStateChecker Deserialize(JsonObject jsonObject, TState state) + public ISimpleStateChecker? Deserialize(JsonObject jsonObject, TState state) where TState : IHasSimpleStateCheckers { if (jsonObject["T"]?.ToString() != CheckerShortName) @@ -50,7 +50,7 @@ public class GlobalFeaturesSimpleStateCheckerSerializerContributor : return new RequireGlobalFeaturesSimpleStateChecker( (bool?)jsonObject["A"] ?? false, - nameArray.Select(x => x.ToString()).ToArray() + nameArray.Select(x => x!.ToString()).ToArray() ); } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequiresGlobalFeatureAttribute.cs b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequiresGlobalFeatureAttribute.cs index 788d0642aa..f9fc5d00ba 100644 --- a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequiresGlobalFeatureAttribute.cs +++ b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequiresGlobalFeatureAttribute.cs @@ -6,9 +6,9 @@ namespace Volo.Abp.GlobalFeatures; [AttributeUsage(AttributeTargets.Class)] public class RequiresGlobalFeatureAttribute : Attribute { - public Type Type { get; } + public Type? Type { get; } - public string Name { get; } + public string? Name { get; } public RequiresGlobalFeatureAttribute([NotNull] Type type) { @@ -22,6 +22,6 @@ public class RequiresGlobalFeatureAttribute : Attribute public virtual string GetFeatureName() { - return Name ?? GlobalFeatureNameAttribute.GetName(Type); + return Name ?? GlobalFeatureNameAttribute.GetName(Type!); } } From fb90f747134b3c51c5f59943eacacb6e31c82d3e Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 14:09:55 +0800 Subject: [PATCH 12/15] Enable nullable annotations for Volo.Abp.Emailing --- .../AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs | 2 +- .../AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs | 2 +- framework/src/Volo.Abp.Emailing/Volo.Abp.Emailing.csproj | 2 ++ .../Volo/Abp/Emailing/EmailSenderConfiguration.cs | 2 +- .../Volo/Abp/Emailing/Smtp/ISmtpEmailSenderConfiguration.cs | 2 +- .../Volo/Abp/Emailing/Smtp/SmtpEmailSenderConfiguration.cs | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs index 7b7ccf7db7..aae85e4d25 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs @@ -24,7 +24,7 @@ public class GlobalFeatureActionFilter : IAsyncActionFilter, ITransientDependenc if (!GlobalFeatureHelper.IsGlobalFeatureEnabled(context.Controller.GetType(), out var attribute)) { var logger = context.GetService>(NullLogger.Instance)!; - logger.LogWarning($"The '{context.Controller.GetType().FullName}' controller needs to enable '{attribute.Name}' feature."); + logger.LogWarning($"The '{context.Controller.GetType().FullName}' controller needs to enable '{attribute!.Name}' feature."); context.Result = new NotFoundResult(); return; } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs index c557b6c5bd..46455730a4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs @@ -29,7 +29,7 @@ public class GlobalFeaturePageFilter : IAsyncPageFilter, ITransientDependency if (!GlobalFeatureHelper.IsGlobalFeatureEnabled(context.HandlerInstance.GetType(), out var attribute)) { var logger = context.GetService>(NullLogger.Instance)!; - logger.LogWarning($"The '{context.HandlerInstance.GetType().FullName}' page needs to enable '{attribute.Name}' feature."); + logger.LogWarning($"The '{context.HandlerInstance.GetType().FullName}' page needs to enable '{attribute!.Name}' feature."); context.Result = new NotFoundResult(); return; } diff --git a/framework/src/Volo.Abp.Emailing/Volo.Abp.Emailing.csproj b/framework/src/Volo.Abp.Emailing/Volo.Abp.Emailing.csproj index e2c55f2bb6..92d670d114 100644 --- a/framework/src/Volo.Abp.Emailing/Volo.Abp.Emailing.csproj +++ b/framework/src/Volo.Abp.Emailing/Volo.Abp.Emailing.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Emailing Volo.Abp.Emailing $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderConfiguration.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderConfiguration.cs index 97b16f1083..6d15929ce4 100644 --- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderConfiguration.cs +++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderConfiguration.cs @@ -44,6 +44,6 @@ public abstract class EmailSenderConfiguration : IEmailSenderConfiguration throw new AbpException($"Setting value for '{name}' is null or empty!"); } - return value; + return value!; } } diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/ISmtpEmailSenderConfiguration.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/ISmtpEmailSenderConfiguration.cs index 803ca01f61..627ec4dc20 100644 --- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/ISmtpEmailSenderConfiguration.cs +++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/ISmtpEmailSenderConfiguration.cs @@ -30,7 +30,7 @@ public interface ISmtpEmailSenderConfiguration : IEmailSenderConfiguration /// /// Domain name to login to SMTP server. /// - Task GetDomainAsync(); + Task GetDomainAsync(); /// /// Is SSL enabled? diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/SmtpEmailSenderConfiguration.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/SmtpEmailSenderConfiguration.cs index 5f1e9538d6..03df69d614 100644 --- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/SmtpEmailSenderConfiguration.cs +++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/Smtp/SmtpEmailSenderConfiguration.cs @@ -37,7 +37,7 @@ public class SmtpEmailSenderConfiguration : EmailSenderConfiguration, ISmtpEmail return GetNotEmptySettingValueAsync(EmailSettingNames.Smtp.Password); } - public Task GetDomainAsync() + public Task GetDomainAsync() { return SettingProvider.GetOrNullAsync(EmailSettingNames.Smtp.Domain); } From a305d9d503db551828ae5bf9a80d2c65554feaad Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 14:16:53 +0800 Subject: [PATCH 13/15] Enable nullable annotations for Volo.Abp.MailKit --- .../Volo/Abp/Emailing/BackgroundEmailSendingJob.cs | 2 +- .../Volo/Abp/Emailing/BackgroundEmailSendingJobArgs.cs | 8 ++++---- .../Volo/Abp/Emailing/EmailSenderBase.cs | 4 ++-- .../Volo.Abp.Emailing/Volo/Abp/Emailing/IEmailSender.cs | 8 ++++---- framework/src/Volo.Abp.MailKit/Volo.Abp.MailKit.csproj | 2 ++ 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/BackgroundEmailSendingJob.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/BackgroundEmailSendingJob.cs index 9a70469df8..07b4ca9bcd 100644 --- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/BackgroundEmailSendingJob.cs +++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/BackgroundEmailSendingJob.cs @@ -23,7 +23,7 @@ public class BackgroundEmailSendingJob : AsyncBackgroundJob /// Default: true. diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs index 81a381c975..d8a46ca4b9 100644 --- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs +++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs @@ -24,7 +24,7 @@ public abstract class EmailSenderBase : IEmailSender BackgroundJobManager = backgroundJobManager; } - public virtual async Task SendAsync(string to, string subject, string body, bool isBodyHtml = true) + public virtual async Task SendAsync(string to, string? subject, string? body, bool isBodyHtml = true) { await SendAsync(new MailMessage { @@ -35,7 +35,7 @@ public abstract class EmailSenderBase : IEmailSender }); } - public virtual async Task SendAsync(string from, string to, string subject, string body, bool isBodyHtml = true) + public virtual async Task SendAsync(string from, string to, string? subject, string? body, bool isBodyHtml = true) { await SendAsync(new MailMessage(from, to, subject, body) { IsBodyHtml = isBodyHtml }); } diff --git a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/IEmailSender.cs b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/IEmailSender.cs index 016f4f6be4..55456783c4 100644 --- a/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/IEmailSender.cs +++ b/framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/IEmailSender.cs @@ -13,8 +13,8 @@ public interface IEmailSender /// Task SendAsync( string to, - string subject, - string body, + string? subject, + string? body, bool isBodyHtml = true ); @@ -24,8 +24,8 @@ public interface IEmailSender Task SendAsync( string from, string to, - string subject, - string body, + string? subject, + string? body, bool isBodyHtml = true ); diff --git a/framework/src/Volo.Abp.MailKit/Volo.Abp.MailKit.csproj b/framework/src/Volo.Abp.MailKit/Volo.Abp.MailKit.csproj index bec6f35355..5d3d7d660c 100644 --- a/framework/src/Volo.Abp.MailKit/Volo.Abp.MailKit.csproj +++ b/framework/src/Volo.Abp.MailKit/Volo.Abp.MailKit.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.MailKit Volo.Abp.MailKit $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; From 09681147ec8f9e559dd8853dc3f7465d2645a6b7 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 14:24:43 +0800 Subject: [PATCH 14/15] Enable nullable annotations for Volo.Abp.Swashbuckle --- .../Builder/AbpSwaggerUIBuilderExtensions.cs | 4 ++-- .../AbpSwaggerGenServiceCollectionExtensions.cs | 12 ++++++------ .../Volo.Abp.Swashbuckle/Volo.Abp.Swashbuckle.csproj | 2 ++ .../Abp/Swashbuckle/AbpSwashbuckleDocumentFilter.cs | 2 +- .../Volo/Abp/Swashbuckle/SwaggerHtmlResolver.cs | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/framework/src/Volo.Abp.Swashbuckle/Microsoft/AspNetCore/Builder/AbpSwaggerUIBuilderExtensions.cs b/framework/src/Volo.Abp.Swashbuckle/Microsoft/AspNetCore/Builder/AbpSwaggerUIBuilderExtensions.cs index 79153cd487..f7d85e3256 100644 --- a/framework/src/Volo.Abp.Swashbuckle/Microsoft/AspNetCore/Builder/AbpSwaggerUIBuilderExtensions.cs +++ b/framework/src/Volo.Abp.Swashbuckle/Microsoft/AspNetCore/Builder/AbpSwaggerUIBuilderExtensions.cs @@ -9,7 +9,7 @@ public static class AbpSwaggerUIBuilderExtensions { public static IApplicationBuilder UseAbpSwaggerUI( this IApplicationBuilder app, - Action setupAction = null) + Action? setupAction = null) { var resolver = app.ApplicationServices.GetService(); @@ -17,7 +17,7 @@ public static class AbpSwaggerUIBuilderExtensions { options.InjectJavascript("ui/abp.js"); options.InjectJavascript("ui/abp.swagger.js"); - options.IndexStream = () => resolver.Resolver(); + options.IndexStream = () => resolver?.Resolver(); setupAction?.Invoke(options); }); diff --git a/framework/src/Volo.Abp.Swashbuckle/Microsoft/Extensions/DependencyInjection/AbpSwaggerGenServiceCollectionExtensions.cs b/framework/src/Volo.Abp.Swashbuckle/Microsoft/Extensions/DependencyInjection/AbpSwaggerGenServiceCollectionExtensions.cs index 0f5698ab08..13f1f2a296 100644 --- a/framework/src/Volo.Abp.Swashbuckle/Microsoft/Extensions/DependencyInjection/AbpSwaggerGenServiceCollectionExtensions.cs +++ b/framework/src/Volo.Abp.Swashbuckle/Microsoft/Extensions/DependencyInjection/AbpSwaggerGenServiceCollectionExtensions.cs @@ -12,7 +12,7 @@ public static class AbpSwaggerGenServiceCollectionExtensions { public static IServiceCollection AddAbpSwaggerGen( this IServiceCollection services, - Action setupAction = null) + Action? setupAction = null) { return services.AddSwaggerGen( options => @@ -34,7 +34,7 @@ public static class AbpSwaggerGenServiceCollectionExtensions this IServiceCollection services, [NotNull] string authority, [NotNull] Dictionary scopes, - Action setupAction = null, + Action? setupAction = null, string authorizationEndpoint = "/connect/authorize", string tokenEndpoint = "/connect/token") { @@ -82,10 +82,10 @@ public static class AbpSwaggerGenServiceCollectionExtensions public static IServiceCollection AddAbpSwaggerGenWithOidc( this IServiceCollection services, [NotNull] string authority, - string[] scopes = null, - string[] flows = null, - string discoveryEndpoint = null, - Action setupAction = null) + string[]? scopes = null, + string[]? flows = null, + string? discoveryEndpoint = null, + Action? setupAction = null) { var discoveryUrl = discoveryEndpoint != null ? new Uri(discoveryEndpoint) : diff --git a/framework/src/Volo.Abp.Swashbuckle/Volo.Abp.Swashbuckle.csproj b/framework/src/Volo.Abp.Swashbuckle/Volo.Abp.Swashbuckle.csproj index bbfce19981..83c25f3e23 100644 --- a/framework/src/Volo.Abp.Swashbuckle/Volo.Abp.Swashbuckle.csproj +++ b/framework/src/Volo.Abp.Swashbuckle/Volo.Abp.Swashbuckle.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable Volo.Abp.Swashbuckle Volo.Abp.Swashbuckle $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleDocumentFilter.cs b/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleDocumentFilter.cs index dd1b9705b8..d35443f98b 100644 --- a/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleDocumentFilter.cs +++ b/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleDocumentFilter.cs @@ -30,7 +30,7 @@ public class AbpSwashbuckleDocumentFilter : IDocumentFilter .RemoveAll(path => !actionUrls.Contains(path.Key)); } - protected virtual string RemoveRouteParameterConstraints(ActionDescriptor actionDescriptor) + protected virtual string? RemoveRouteParameterConstraints(ActionDescriptor actionDescriptor) { var route = actionDescriptor.AttributeRouteInfo?.Template?.EnsureStartsWith('/').Replace("?", ""); if (string.IsNullOrWhiteSpace(route)) diff --git a/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/SwaggerHtmlResolver.cs b/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/SwaggerHtmlResolver.cs index 1826fd9336..628a361826 100644 --- a/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/SwaggerHtmlResolver.cs +++ b/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/SwaggerHtmlResolver.cs @@ -13,7 +13,7 @@ public class SwaggerHtmlResolver : ISwaggerHtmlResolver, ITransientDependency var stream = typeof(SwaggerUIOptions).GetTypeInfo().Assembly .GetManifestResourceStream("Swashbuckle.AspNetCore.SwaggerUI.index.html"); - var html = new StreamReader(stream) + var html = new StreamReader(stream!) .ReadToEnd() .Replace("SwaggerUIBundle(configObject)", "abp.SwaggerUIBundle(configObject)"); From fa9949b484858034549a1b6629236c48786b345d Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 13 Jul 2023 14:30:06 +0800 Subject: [PATCH 15/15] Enable nullable annotations for Volo.Abp.Cli --- framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj b/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj index 897899f9ad..d7a181025a 100644 --- a/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj +++ b/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj @@ -5,6 +5,8 @@ Exe + enable + Nullable net7.0 true abp