Browse Source

Enable nullable annotations for Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared

pull/17094/head
liangshiwei 3 years ago
parent
commit
3a13b1a6d6
  1. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/AbpPageToolbarOptions.cs
  2. 18
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarExtensions.cs
  3. 5
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarItem.cs
  4. 8
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/SimplePageToolbarContributor.cs
  5. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpApplicationPath/AbpApplicationPathViewComponentModel.cs
  6. 8
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageToolbar/Button/AbpPageToolbarButtonViewComponent.cs
  7. 3
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/IToolbarConfigurationContext.cs
  8. 3
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarConfigurationContext.cs
  9. 7
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarItem.cs
  10. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/AbpErrorViewModel.cs
  11. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/Default.cshtml
  12. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/AbpPageToolbarOptions.cs

@ -16,7 +16,7 @@ public class AbpPageToolbarOptions
public void Configure<TPage>([NotNull] Action<PageToolbar> configureAction) public void Configure<TPage>([NotNull] Action<PageToolbar> configureAction)
{ {
// ReSharper disable once AssignNullToNotNullAttribute // ReSharper disable once AssignNullToNotNullAttribute
Configure(typeof(TPage).FullName, configureAction); Configure(typeof(TPage).FullName!, configureAction);
} }
public void Configure([NotNull] string pageName, [NotNull] Action<PageToolbar> configureAction) public void Configure([NotNull] string pageName, [NotNull] Action<PageToolbar> configureAction)

18
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarExtensions.cs

@ -11,9 +11,9 @@ public static class PageToolbarExtensions
{ {
public static PageToolbar AddComponent<TComponent>( public static PageToolbar AddComponent<TComponent>(
this PageToolbar toolbar, this PageToolbar toolbar,
object argument = null, object? argument = null,
int order = 0, int order = 0,
string requiredPolicyName = null) string? requiredPolicyName = null)
{ {
return toolbar.AddComponent( return toolbar.AddComponent(
typeof(TComponent), typeof(TComponent),
@ -26,9 +26,9 @@ public static class PageToolbarExtensions
public static PageToolbar AddComponent( public static PageToolbar AddComponent(
this PageToolbar toolbar, this PageToolbar toolbar,
Type componentType, Type componentType,
object argument = null, object? argument = null,
int order = 0, int order = 0,
string requiredPolicyName = null) string? requiredPolicyName = null)
{ {
toolbar.Contributors.Add( toolbar.Contributors.Add(
new SimplePageToolbarContributor( new SimplePageToolbarContributor(
@ -45,16 +45,16 @@ public static class PageToolbarExtensions
public static PageToolbar AddButton( public static PageToolbar AddButton(
this PageToolbar toolbar, this PageToolbar toolbar,
ILocalizableString text, ILocalizableString text,
string icon = null, string? icon = null,
string name = null, string? name = null,
string id = null, string? id = null,
ILocalizableString busyText = null, ILocalizableString? busyText = null,
FontIconType iconType = FontIconType.FontAwesome, FontIconType iconType = FontIconType.FontAwesome,
AbpButtonType type = AbpButtonType.Primary, AbpButtonType type = AbpButtonType.Primary,
AbpButtonSize size = AbpButtonSize.Small, AbpButtonSize size = AbpButtonSize.Small,
bool disabled = false, bool disabled = false,
int order = 0, int order = 0,
string requiredPolicyName = null) string? requiredPolicyName = null)
{ {
if (busyText == null) if (busyText == null)
{ {

5
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/PageToolbars/PageToolbarItem.cs

@ -8,14 +8,13 @@ public class PageToolbarItem
[NotNull] [NotNull]
public Type ComponentType { get; } public Type ComponentType { get; }
[CanBeNull] public object? Arguments { get; set; }
public object Arguments { get; set; }
public int Order { get; set; } public int Order { get; set; }
public PageToolbarItem( public PageToolbarItem(
[NotNull] Type componentType, [NotNull] Type componentType,
[CanBeNull] object arguments = null, object? arguments = null,
int order = 0) int order = 0)
{ {
ComponentType = Check.NotNull(componentType, nameof(componentType)); ComponentType = Check.NotNull(componentType, nameof(componentType));

8
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 Type ComponentType { get; }
public object Argument { get; set; } public object? Argument { get; set; }
public int Order { get; } public int Order { get; }
public string RequiredPolicyName { get; } public string? RequiredPolicyName { get; }
public SimplePageToolbarContributor( public SimplePageToolbarContributor(
Type componentType, Type componentType,
object argument = null, object? argument = null,
int order = 0, int order = 0,
string requiredPolicyName = null) string? requiredPolicyName = null)
{ {
ComponentType = componentType; ComponentType = componentType;
Argument = argument; Argument = argument;

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpApplicationPath/AbpApplicationPathViewComponentModel.cs

@ -2,5 +2,5 @@
public class AbpApplicationPathViewComponentModel public class AbpApplicationPathViewComponentModel
{ {
public string ApplicationPath { get; set; } public string ApplicationPath { get; set; } = default!;
} }

8
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 name,
string icon, string icon,
string id, string id,
ILocalizableString busyText, ILocalizableString? busyText,
FontIconType iconType, FontIconType iconType,
AbpButtonType type, AbpButtonType type,
AbpButtonSize size, AbpButtonSize size,
@ -36,7 +36,7 @@ public class AbpPageToolbarButtonViewComponent : AbpViewComponent
name, name,
icon, icon,
id, id,
busyText == null ? null : await busyText.LocalizeAsync(StringLocalizerFactory), busyText == null ? null : (await busyText.LocalizeAsync(StringLocalizerFactory)).ToString(),
iconType, iconType,
type, type,
size, size,
@ -51,7 +51,7 @@ public class AbpPageToolbarButtonViewComponent : AbpViewComponent
public string Name { get; } public string Name { get; }
public string Icon { get; } public string Icon { get; }
public string Id { get; } public string Id { get; }
public string BusyText { get; } public string? BusyText { get; }
public FontIconType IconType { get; } public FontIconType IconType { get; }
public AbpButtonType Type { get; } public AbpButtonType Type { get; }
public AbpButtonSize Size { get; } public AbpButtonSize Size { get; }
@ -62,7 +62,7 @@ public class AbpPageToolbarButtonViewComponent : AbpViewComponent
string name, string name,
string icon, string icon,
string id, string id,
string busyText, string? busyText,
FontIconType iconType, FontIconType iconType,
AbpButtonType type, AbpButtonType type,
AbpButtonSize size, AbpButtonSize size,

3
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/IToolbarConfigurationContext.cs

@ -20,8 +20,7 @@ public interface IToolbarConfigurationContext : IServiceProviderAccessor
Task<bool> IsGrantedAsync(string policyName); Task<bool> IsGrantedAsync(string policyName);
[CanBeNull] IStringLocalizer? GetDefaultLocalizer();
IStringLocalizer GetDefaultLocalizer();
[NotNull] [NotNull]
public IStringLocalizer GetLocalizer<T>(); public IStringLocalizer GetLocalizer<T>();

3
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarConfigurationContext.cs

@ -36,8 +36,7 @@ public class ToolbarConfigurationContext : IToolbarConfigurationContext
return AuthorizationService.IsGrantedAsync(policyName); return AuthorizationService.IsGrantedAsync(policyName);
} }
[CanBeNull] public IStringLocalizer? GetDefaultLocalizer()
public IStringLocalizer GetDefaultLocalizer()
{ {
return StringLocalizerFactory.CreateDefaultOrNull(); return StringLocalizerFactory.CreateDefaultOrNull();
} }

7
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarItem.cs

@ -11,17 +11,16 @@ public class ToolbarItem : IHasSimpleStateCheckers<ToolbarItem>
get => _componentType; get => _componentType;
set => _componentType = Check.NotNull(value, nameof(value)); set => _componentType = Check.NotNull(value, nameof(value));
} }
private Type _componentType; private Type _componentType = default!;
public int Order { get; set; } public int Order { get; set; }
[CanBeNull]
[Obsolete("Use RequirePermissions extension method.")] [Obsolete("Use RequirePermissions extension method.")]
public string RequiredPermissionName { get; set; } public string? RequiredPermissionName { get; set; }
public List<ISimpleStateChecker<ToolbarItem>> StateCheckers { get; } public List<ISimpleStateChecker<ToolbarItem>> 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; Order = order;
ComponentType = Check.NotNull(componentType, nameof(componentType)); ComponentType = Check.NotNull(componentType, nameof(componentType));

2
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 class AbpErrorViewModel
{ {
public RemoteServiceErrorInfo ErrorInfo { get; set; } public RemoteServiceErrorInfo ErrorInfo { get; set; } = default!;
public int HttpStatusCode { get; set; } public int HttpStatusCode { get; set; }
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/Default.cshtml

@ -26,7 +26,7 @@
<p> <p>
@if (!Model.ErrorInfo.ValidationErrors.IsNullOrEmpty()) @if (!Model.ErrorInfo.ValidationErrors.IsNullOrEmpty())
{ {
foreach (var validationError in Model.ErrorInfo.ValidationErrors) foreach (var validationError in Model.ErrorInfo.ValidationErrors!)
{ {
<text>* </text>@(validationError.Message) <text>* </text>@(validationError.Message)
if (validationError.Members != null && validationError.Members.Any()) if (validationError.Members != null && validationError.Members.Any())

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj

@ -5,6 +5,8 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc> <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<AssemblyName>Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared</AssemblyName> <AssemblyName>Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared</AssemblyName>
<PackageId>Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared</PackageId> <PackageId>Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared</PackageId>

Loading…
Cancel
Save