From 3a13b1a6d664acea92c19d4b07f1af8a2b35c6ff Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 12 Jul 2023 15:40:46 +0800 Subject: [PATCH] Enable nullable annotations for Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared --- .../PageToolbars/AbpPageToolbarOptions.cs | 2 +- .../PageToolbars/PageToolbarExtensions.cs | 18 +++++++++--------- .../PageToolbars/PageToolbarItem.cs | 5 ++--- .../SimplePageToolbarContributor.cs | 8 ++++---- .../AbpApplicationPathViewComponentModel.cs | 2 +- .../AbpPageToolbarButtonViewComponent.cs | 8 ++++---- .../Toolbars/IToolbarConfigurationContext.cs | 3 +-- .../Toolbars/ToolbarConfigurationContext.cs | 3 +-- .../Toolbars/ToolbarItem.cs | 7 +++---- .../Views/Error/AbpErrorViewModel.cs | 2 +- .../Views/Error/Default.cshtml | 2 +- ...o.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj | 2 ++ 12 files changed, 30 insertions(+), 32 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/AbpPageToolbarOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/AbpPageToolbarOptions.cs index 52dcfd6085..0f4d21c6ac 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/AbpPageToolbarOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/AbpPageToolbarOptions.cs @@ -16,7 +16,7 @@ public class AbpPageToolbarOptions public void Configure([NotNull] Action configureAction) { // ReSharper disable once AssignNullToNotNullAttribute - Configure(typeof(TPage).FullName, configureAction); + Configure(typeof(TPage).FullName!, configureAction); } public void Configure([NotNull] string pageName, [NotNull] Action configureAction) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarExtensions.cs index be64f07bc1..e319354d67 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarExtensions.cs @@ -11,9 +11,9 @@ public static class PageToolbarExtensions { public static PageToolbar AddComponent( this PageToolbar toolbar, - object argument = null, + object? argument = null, int order = 0, - string requiredPolicyName = null) + string? requiredPolicyName = null) { return toolbar.AddComponent( typeof(TComponent), @@ -26,9 +26,9 @@ public static class PageToolbarExtensions public static PageToolbar AddComponent( this PageToolbar toolbar, Type componentType, - object argument = null, + object? argument = null, int order = 0, - string requiredPolicyName = null) + string? requiredPolicyName = null) { toolbar.Contributors.Add( new SimplePageToolbarContributor( @@ -45,16 +45,16 @@ public static class PageToolbarExtensions public static PageToolbar AddButton( this PageToolbar toolbar, ILocalizableString text, - string icon = null, - string name = null, - string id = null, - ILocalizableString busyText = null, + string? icon = null, + string? name = null, + string? id = null, + ILocalizableString? busyText = null, FontIconType iconType = FontIconType.FontAwesome, AbpButtonType type = AbpButtonType.Primary, AbpButtonSize size = AbpButtonSize.Small, bool disabled = false, int order = 0, - string requiredPolicyName = null) + string? requiredPolicyName = null) { if (busyText == null) { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarItem.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarItem.cs index e9cebae8f6..30cfa05664 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarItem.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarItem.cs @@ -8,14 +8,13 @@ public class PageToolbarItem [NotNull] public Type ComponentType { get; } - [CanBeNull] - public object Arguments { get; set; } + public object? Arguments { get; set; } public int Order { get; set; } public PageToolbarItem( [NotNull] Type componentType, - [CanBeNull] object arguments = null, + object? arguments = null, int order = 0) { ComponentType = Check.NotNull(componentType, nameof(componentType)); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/SimplePageToolbarContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/SimplePageToolbarContributor.cs index 713c3c52ca..f049ef2c74 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/SimplePageToolbarContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/SimplePageToolbarContributor.cs @@ -9,17 +9,17 @@ public class SimplePageToolbarContributor : IPageToolbarContributor { public Type ComponentType { get; } - public object Argument { get; set; } + public object? Argument { get; set; } public int Order { get; } - public string RequiredPolicyName { get; } + public string? RequiredPolicyName { get; } public SimplePageToolbarContributor( Type componentType, - object argument = null, + object? argument = null, int order = 0, - string requiredPolicyName = null) + string? requiredPolicyName = null) { ComponentType = componentType; Argument = argument; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpApplicationPath/AbpApplicationPathViewComponentModel.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpApplicationPath/AbpApplicationPathViewComponentModel.cs index 94e8171102..7be33d9761 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpApplicationPath/AbpApplicationPathViewComponentModel.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpApplicationPath/AbpApplicationPathViewComponentModel.cs @@ -2,5 +2,5 @@ public class AbpApplicationPathViewComponentModel { - public string ApplicationPath { get; set; } + public string ApplicationPath { get; set; } = default!; } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Button/AbpPageToolbarButtonViewComponent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Button/AbpPageToolbarButtonViewComponent.cs index 56ae47f0c8..a403155668 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Button/AbpPageToolbarButtonViewComponent.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Button/AbpPageToolbarButtonViewComponent.cs @@ -21,7 +21,7 @@ public class AbpPageToolbarButtonViewComponent : AbpViewComponent string name, string icon, string id, - ILocalizableString busyText, + ILocalizableString? busyText, FontIconType iconType, AbpButtonType type, AbpButtonSize size, @@ -36,7 +36,7 @@ public class AbpPageToolbarButtonViewComponent : AbpViewComponent name, icon, id, - busyText == null ? null : await busyText.LocalizeAsync(StringLocalizerFactory), + busyText == null ? null : (await busyText.LocalizeAsync(StringLocalizerFactory)).ToString(), iconType, type, size, @@ -51,7 +51,7 @@ public class AbpPageToolbarButtonViewComponent : AbpViewComponent public string Name { get; } public string Icon { get; } public string Id { get; } - public string BusyText { get; } + public string? BusyText { get; } public FontIconType IconType { get; } public AbpButtonType Type { get; } public AbpButtonSize Size { get; } @@ -62,7 +62,7 @@ public class AbpPageToolbarButtonViewComponent : AbpViewComponent string name, string icon, string id, - string busyText, + string? busyText, FontIconType iconType, AbpButtonType type, AbpButtonSize size, diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/IToolbarConfigurationContext.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/IToolbarConfigurationContext.cs index bb1365112c..740ca05979 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/IToolbarConfigurationContext.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/IToolbarConfigurationContext.cs @@ -20,8 +20,7 @@ public interface IToolbarConfigurationContext : IServiceProviderAccessor Task IsGrantedAsync(string policyName); - [CanBeNull] - IStringLocalizer GetDefaultLocalizer(); + IStringLocalizer? GetDefaultLocalizer(); [NotNull] public IStringLocalizer GetLocalizer(); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarConfigurationContext.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarConfigurationContext.cs index b1f1ccadf4..fa67fba2b9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarConfigurationContext.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarConfigurationContext.cs @@ -36,8 +36,7 @@ public class ToolbarConfigurationContext : IToolbarConfigurationContext return AuthorizationService.IsGrantedAsync(policyName); } - [CanBeNull] - public IStringLocalizer GetDefaultLocalizer() + public IStringLocalizer? GetDefaultLocalizer() { return StringLocalizerFactory.CreateDefaultOrNull(); } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarItem.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarItem.cs index 89d904c13b..0bf354bde6 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarItem.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarItem.cs @@ -11,17 +11,16 @@ public class ToolbarItem : IHasSimpleStateCheckers get => _componentType; set => _componentType = Check.NotNull(value, nameof(value)); } - private Type _componentType; + private Type _componentType = default!; public int Order { get; set; } - [CanBeNull] [Obsolete("Use RequirePermissions extension method.")] - public string RequiredPermissionName { get; set; } + public string? RequiredPermissionName { get; set; } public List> StateCheckers { get; } - public ToolbarItem([NotNull] Type componentType, int order = 0, string requiredPermissionName = null) + public ToolbarItem([NotNull] Type componentType, int order = 0, string? requiredPermissionName = null) { Order = order; ComponentType = Check.NotNull(componentType, nameof(componentType)); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/AbpErrorViewModel.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/AbpErrorViewModel.cs index 3863604a09..c68b6b3094 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/AbpErrorViewModel.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/AbpErrorViewModel.cs @@ -4,7 +4,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Views.Error; public class AbpErrorViewModel { - public RemoteServiceErrorInfo ErrorInfo { get; set; } + public RemoteServiceErrorInfo ErrorInfo { get; set; } = default!; public int HttpStatusCode { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/Default.cshtml index cfd16a2b8c..f02e487cb2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/Default.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/Default.cshtml @@ -26,7 +26,7 @@

@if (!Model.ErrorInfo.ValidationErrors.IsNullOrEmpty()) { - foreach (var validationError in Model.ErrorInfo.ValidationErrors) + foreach (var validationError in Model.ErrorInfo.ValidationErrors!) { * @(validationError.Message) if (validationError.Members != null && validationError.Members.Any()) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj index 40f95d10c9..4bac31ac83 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable true Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared