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)
{
// ReSharper disable once AssignNullToNotNullAttribute
Configure(typeof(TPage).FullName, configureAction);
Configure(typeof(TPage).FullName!, 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>(
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)
{

5
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));

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 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;

2
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!;
}

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 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,

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);
[CanBeNull]
IStringLocalizer GetDefaultLocalizer();
IStringLocalizer? GetDefaultLocalizer();
[NotNull]
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);
}
[CanBeNull]
public IStringLocalizer GetDefaultLocalizer()
public IStringLocalizer? GetDefaultLocalizer()
{
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;
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<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;
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 RemoteServiceErrorInfo ErrorInfo { get; set; }
public RemoteServiceErrorInfo ErrorInfo { get; set; } = default!;
public int HttpStatusCode { get; set; }
}

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

@ -26,7 +26,7 @@
<p>
@if (!Model.ErrorInfo.ValidationErrors.IsNullOrEmpty())
{
foreach (var validationError in Model.ErrorInfo.ValidationErrors)
foreach (var validationError in Model.ErrorInfo.ValidationErrors!)
{
<text>* </text>@(validationError.Message)
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>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<AssemblyName>Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared</AssemblyName>
<PackageId>Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared</PackageId>

Loading…
Cancel
Save