Browse Source

Enable nullable annotations for Volo.Abp.BlazoriseUI

pull/17120/head
liangshiwei 3 years ago
parent
commit
b8c9e8ed04
  1. 6
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageEventArgs.cs
  2. 4
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationEventArgs.cs
  3. 4
      framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs
  4. 40
      framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs
  5. 12
      framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiMessageService.cs
  6. 10
      framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiNotificationService.cs
  7. 10
      framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiObjectExtensionPropertyInfoExtensions.cs
  8. 4
      framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs
  9. 6
      framework/src/Volo.Abp.BlazoriseUI/BreadcrumbItem.cs
  10. 2
      framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor
  11. 12
      framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor.cs
  12. 2
      framework/src/Volo.Abp.BlazoriseUI/Components/AlertWrapper.cs
  13. 2
      framework/src/Volo.Abp.BlazoriseUI/Components/DataGridEntityActionsColumn.razor.cs
  14. 18
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs
  15. 2
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor
  16. 12
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs
  17. 16
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/EnumHelper.cs
  18. 6
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs
  19. 12
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyComponentBase.cs
  20. 12
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/LookupExtensionProperty.razor.cs
  21. 6
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/SelectExtensionProperty.razor.cs
  22. 2
      framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TextExtensionProperty.razor.cs
  23. 10
      framework/src/Volo.Abp.BlazoriseUI/Components/PageAlert.razor.cs
  24. 6
      framework/src/Volo.Abp.BlazoriseUI/Components/SubmitButton.razor.cs
  25. 8
      framework/src/Volo.Abp.BlazoriseUI/Components/ToolbarButton.razor.cs
  26. 23
      framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor.cs
  27. 21
      framework/src/Volo.Abp.BlazoriseUI/Components/UiNotificationAlert.razor.cs
  28. 13
      framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor.cs
  29. 2
      framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj
  30. 2
      framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpInternalLocalizationHelper.cs
  31. 2
      framework/src/Volo.Abp.Localization/Volo/Abp/Localization/IAbpEnumLocalizer.cs
  32. 4
      framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/ExtraPropertyDictionary.cs
  33. 16
      framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/ExtraPropertyDictionaryExtensions.cs
  34. 6
      framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/HasExtraPropertiesExtensions.cs
  35. 8
      framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensibleObjectMapper.cs

6
framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageEventArgs.cs

@ -5,7 +5,7 @@ namespace Volo.Abp.AspNetCore.Components.Messages;
public class UiMessageEventArgs : EventArgs
{
public UiMessageEventArgs(UiMessageType messageType, string message, string title, UiMessageOptions options)
public UiMessageEventArgs(UiMessageType messageType, string message, string? title, UiMessageOptions options)
{
MessageType = messageType;
Message = message;
@ -13,7 +13,7 @@ public class UiMessageEventArgs : EventArgs
Options = options;
}
public UiMessageEventArgs(UiMessageType messageType, string message, string title, UiMessageOptions options, TaskCompletionSource<bool> callback)
public UiMessageEventArgs(UiMessageType messageType, string message, string? title, UiMessageOptions options, TaskCompletionSource<bool> callback)
{
MessageType = messageType;
Message = message;
@ -26,7 +26,7 @@ public class UiMessageEventArgs : EventArgs
public string Message { get; }
public string Title { get; }
public string? Title { get; }
public UiMessageOptions Options { get; }

4
framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationEventArgs.cs

@ -4,7 +4,7 @@ namespace Volo.Abp.AspNetCore.Components.Notifications;
public class UiNotificationEventArgs : EventArgs
{
public UiNotificationEventArgs(UiNotificationType notificationType, string message, string title, UiNotificationOptions options)
public UiNotificationEventArgs(UiNotificationType notificationType, string message, string? title, UiNotificationOptions options)
{
NotificationType = notificationType;
Message = message;
@ -16,7 +16,7 @@ public class UiNotificationEventArgs : EventArgs
public string Message { get; }
public string Title { get; }
public string? Title { get; }
public UiNotificationOptions Options { get; }
}

4
framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs

@ -22,8 +22,8 @@ public static class AbpAutoMapperExtensibleDtoExtensions
(source, destination, extraProps) =>
{
var result = extraProps.IsNullOrEmpty()
? new Dictionary<string, object>()
: new Dictionary<string, object>(extraProps);
? new Dictionary<string, object?>()
: new Dictionary<string, object?>(extraProps);
ExtensibleObjectMapper
.MapExtraPropertiesTo<TSource, TDestination>(

40
framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs

@ -174,32 +174,32 @@ public abstract class AbpCrudPageBase<
where TCreateViewModel : class, new()
where TUpdateViewModel : class, new()
{
[Inject] protected TAppService AppService { get; set; }
[Inject] protected IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
[Inject] public IAbpEnumLocalizer AbpEnumLocalizer { get; set; }
[Inject] protected TAppService AppService { get; set; } = default!;
[Inject] protected IStringLocalizer<AbpUiResource> UiLocalizer { get; set; } = default!;
[Inject] public IAbpEnumLocalizer AbpEnumLocalizer { get; set; } = default!;
protected virtual int PageSize { get; } = LimitedResultRequestDto.DefaultMaxResultCount;
protected int CurrentPage = 1;
protected string CurrentSorting;
protected string CurrentSorting = default!;
protected int? TotalCount;
protected TGetListInput GetListInput = new TGetListInput();
protected IReadOnlyList<TListViewModel> Entities = Array.Empty<TListViewModel>();
protected TCreateViewModel NewEntity;
protected TKey EditingEntityId;
protected TKey EditingEntityId = default!;
protected TUpdateViewModel EditingEntity;
protected Modal CreateModal;
protected Modal EditModal;
protected Validations CreateValidationsRef;
protected Validations EditValidationsRef;
protected Modal? CreateModal;
protected Modal? EditModal;
protected Validations? CreateValidationsRef;
protected Validations? EditValidationsRef;
protected List<BreadcrumbItem> BreadcrumbItems = new List<BreadcrumbItem>(2);
protected DataGridEntityActionsColumn<TListViewModel> EntityActionsColumn;
protected DataGridEntityActionsColumn<TListViewModel> EntityActionsColumn = default!;
protected EntityActionDictionary EntityActions { get; set; }
protected TableColumnDictionary TableColumns { get; set; }
protected string CreatePolicyName { get; set; }
protected string UpdatePolicyName { get; set; }
protected string DeletePolicyName { get; set; }
protected string? CreatePolicyName { get; set; }
protected string? UpdatePolicyName { get; set; }
protected string? DeletePolicyName { get; set; }
public bool HasCreatePermission { get; set; }
public bool HasUpdatePermission { get; set; }
@ -360,7 +360,7 @@ public abstract class AbpCrudPageBase<
protected virtual Task CloseCreateModalAsync()
{
NewEntity = new TCreateViewModel();
return InvokeAsync(CreateModal.Hide);
return InvokeAsync(CreateModal!.Hide);
}
protected virtual Task ClosingCreateModal(ModalClosingEventArgs eventArgs)
@ -429,7 +429,7 @@ public abstract class AbpCrudPageBase<
protected virtual Task CloseEditModalAsync()
{
InvokeAsync(EditModal.Hide);
InvokeAsync(EditModal!.Hide);
return Task.CompletedTask;
}
@ -477,7 +477,7 @@ public abstract class AbpCrudPageBase<
NewEntity = new TCreateViewModel();
await GetEntitiesAsync();
await InvokeAsync(CreateModal.Hide);
await InvokeAsync(CreateModal!.Hide);
}
protected virtual async Task UpdateEntityAsync()
@ -515,7 +515,7 @@ public abstract class AbpCrudPageBase<
{
await GetEntitiesAsync();
await InvokeAsync(EditModal.Hide);
await InvokeAsync(EditModal!.Hide);
}
protected virtual async Task DeleteEntityAsync(TListViewModel entity)
@ -572,7 +572,7 @@ public abstract class AbpCrudPageBase<
/// Does nothing if <paramref name="policyName"/> is null or empty.
/// </summary>
/// <param name="policyName">A policy name to check</param>
protected virtual async Task CheckPolicyAsync([CanBeNull] string policyName)
protected virtual async Task CheckPolicyAsync(string? policyName)
{
if (string.IsNullOrEmpty(policyName))
{
@ -633,7 +633,7 @@ public abstract class AbpCrudPageBase<
if (propertyInfo.Name.EndsWith("_Text"))
{
var lookupPropertyName = propertyInfo.Name.RemovePostFix("_Text");
var lookupPropertyDefinition = properties.SingleOrDefault(t => t.Name == lookupPropertyName);
var lookupPropertyDefinition = properties.SingleOrDefault(t => t.Name == lookupPropertyName)!;
yield return new TableColumn
{
Title = lookupPropertyDefinition.GetLocalizedDisplayName(StringLocalizerFactory),
@ -658,7 +658,7 @@ public abstract class AbpCrudPageBase<
if (propertyInfo.Type.IsEnum)
{
column.ValueConverter = (val) =>
AbpEnumLocalizer.GetString(propertyInfo.Type, val.As<ExtensibleObject>().ExtraProperties[propertyInfo.Name], new IStringLocalizer[]{ StringLocalizerFactory.CreateDefaultOrNull() });
AbpEnumLocalizer.GetString(propertyInfo.Type, val.As<ExtensibleObject>().ExtraProperties[propertyInfo.Name]!, new IStringLocalizer?[]{ StringLocalizerFactory.CreateDefaultOrNull() });
}
yield return column;

12
framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiMessageService.cs

@ -15,7 +15,7 @@ public class BlazoriseUiMessageService : IUiMessageService, IScopedDependency
/// <summary>
/// An event raised after the message is received. Used to notify the message dialog.
/// </summary>
public event EventHandler<UiMessageEventArgs> MessageReceived;
public event EventHandler<UiMessageEventArgs>? MessageReceived ;
private readonly IStringLocalizer<AbpUiResource> localizer;
@ -29,7 +29,7 @@ public class BlazoriseUiMessageService : IUiMessageService, IScopedDependency
Logger = NullLogger<BlazoriseUiMessageService>.Instance;
}
public Task Info(string message, string title = null, Action<UiMessageOptions> options = null)
public Task Info(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
var uiMessageOptions = CreateDefaultOptions();
options?.Invoke(uiMessageOptions);
@ -39,7 +39,7 @@ public class BlazoriseUiMessageService : IUiMessageService, IScopedDependency
return Task.CompletedTask;
}
public Task Success(string message, string title = null, Action<UiMessageOptions> options = null)
public Task Success(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
var uiMessageOptions = CreateDefaultOptions();
options?.Invoke(uiMessageOptions);
@ -49,7 +49,7 @@ public class BlazoriseUiMessageService : IUiMessageService, IScopedDependency
return Task.CompletedTask;
}
public Task Warn(string message, string title = null, Action<UiMessageOptions> options = null)
public Task Warn(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
var uiMessageOptions = CreateDefaultOptions();
options?.Invoke(uiMessageOptions);
@ -59,7 +59,7 @@ public class BlazoriseUiMessageService : IUiMessageService, IScopedDependency
return Task.CompletedTask;
}
public Task Error(string message, string title = null, Action<UiMessageOptions> options = null)
public Task Error(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
var uiMessageOptions = CreateDefaultOptions();
options?.Invoke(uiMessageOptions);
@ -69,7 +69,7 @@ public class BlazoriseUiMessageService : IUiMessageService, IScopedDependency
return Task.CompletedTask;
}
public Task<bool> Confirm(string message, string title = null, Action<UiMessageOptions> options = null)
public Task<bool> Confirm(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
var uiMessageOptions = CreateDefaultOptions();
options?.Invoke(uiMessageOptions);

10
framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiNotificationService.cs

@ -11,9 +11,9 @@ public class BlazoriseUiNotificationService : IUiNotificationService, IScopedDep
/// <summary>
/// An event raised after the notification is received.
/// </summary>
public event EventHandler<UiNotificationEventArgs> NotificationReceived;
public event EventHandler<UiNotificationEventArgs>? NotificationReceived;
public Task Info(string message, string title = null, Action<UiNotificationOptions> options = null)
public Task Info(string message, string? title = null, Action<UiNotificationOptions>? options = null)
{
var uiNotificationOptions = CreateDefaultOptions();
options?.Invoke(uiNotificationOptions);
@ -23,7 +23,7 @@ public class BlazoriseUiNotificationService : IUiNotificationService, IScopedDep
return Task.CompletedTask;
}
public Task Success(string message, string title = null, Action<UiNotificationOptions> options = null)
public Task Success(string message, string? title = null, Action<UiNotificationOptions>? options = null)
{
var uiNotificationOptions = CreateDefaultOptions();
options?.Invoke(uiNotificationOptions);
@ -33,7 +33,7 @@ public class BlazoriseUiNotificationService : IUiNotificationService, IScopedDep
return Task.CompletedTask;
}
public Task Warn(string message, string title = null, Action<UiNotificationOptions> options = null)
public Task Warn(string message, string? title = null, Action<UiNotificationOptions>? options = null)
{
var uiNotificationOptions = CreateDefaultOptions();
options?.Invoke(uiNotificationOptions);
@ -43,7 +43,7 @@ public class BlazoriseUiNotificationService : IUiNotificationService, IScopedDep
return Task.CompletedTask;
}
public Task Error(string message, string title = null, Action<UiNotificationOptions> options = null)
public Task Error(string message, string? title = null, Action<UiNotificationOptions>? options = null)
{
var uiNotificationOptions = CreateDefaultOptions();
options?.Invoke(uiNotificationOptions);

10
framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiObjectExtensionPropertyInfoExtensions.cs

@ -44,7 +44,7 @@ public static class BlazoriseUiObjectExtensionPropertyInfoExtensions
typeof(PhoneAttribute)
};
public static string GetDateEditInputFormatOrNull(this IBasicObjectExtensionPropertyInfo property)
public static string? GetDateEditInputFormatOrNull(this IBasicObjectExtensionPropertyInfo property)
{
if (property.IsDate())
{
@ -59,7 +59,7 @@ public static class BlazoriseUiObjectExtensionPropertyInfoExtensions
return null;
}
public static string GetTextInputValueOrNull(this IBasicObjectExtensionPropertyInfo property, object value)
public static string? GetTextInputValueOrNull(this IBasicObjectExtensionPropertyInfo property, object? value)
{
if (value == null)
{
@ -74,7 +74,7 @@ public static class BlazoriseUiObjectExtensionPropertyInfoExtensions
return value.ToString();
}
public static T GetInputValueOrDefault<T>(this IBasicObjectExtensionPropertyInfo property, object value)
public static T? GetInputValueOrDefault<T>(this IBasicObjectExtensionPropertyInfo property, object? value)
{
if (value == null)
{
@ -204,7 +204,7 @@ public static class BlazoriseUiObjectExtensionPropertyInfoExtensions
?? typeof(TextExtensionProperty<,>); //default
}
private static Type GetInputTypeFromAttributeOrNull(Attribute attribute)
private static Type? GetInputTypeFromAttributeOrNull(Attribute attribute)
{
var hasTextEditSupport = TextEditSupportedAttributeTypes.Any(t => t == attribute.GetType());
@ -238,7 +238,7 @@ public static class BlazoriseUiObjectExtensionPropertyInfoExtensions
return null;
}
private static Type GetInputTypeFromTypeOrNull(Type type)
private static Type? GetInputTypeFromTypeOrNull(Type type)
{
if (type == typeof(bool))
{

4
framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiPageProgressService.cs

@ -12,9 +12,9 @@ public class BlazoriseUiPageProgressService : IUiPageProgressService,
/// <summary>
/// An event raised after the notification is received.
/// </summary>
public event EventHandler<UiPageProgressEventArgs> ProgressChanged;
public event EventHandler<UiPageProgressEventArgs>? ProgressChanged;
public Task Go(int? percentage, Action<UiPageProgressOptions> options = null)
public Task Go(int? percentage, Action<UiPageProgressOptions>? options = null)
{
var uiPageProgressOptions = CreateDefaultOptions();
options?.Invoke(uiPageProgressOptions);

6
framework/src/Volo.Abp.BlazoriseUI/BreadcrumbItem.cs

@ -6,11 +6,11 @@ public class BreadcrumbItem
{
public string Text { get; set; }
public object Icon { get; set; }
public object? Icon { get; set; }
public string Url { get; set; }
public string? Url { get; set; }
public BreadcrumbItem(string text, string url = null, object icon = null)
public BreadcrumbItem(string text, string? url = null, object? icon = null)
{
Text = text;
Url = url;

2
framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor

@ -121,7 +121,7 @@
@{
var entity = context as IHasExtraProperties;
var propertyName = ExtensionPropertiesRegex.Match(column.Data).Groups[1].Value;
var propertyValue = entity.GetProperty(propertyName);
var propertyValue = entity?.GetProperty(propertyName);
if (propertyValue != null && propertyValue.GetType() == typeof(bool))
{
if ((bool) propertyValue)

12
framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor.cs

@ -18,7 +18,7 @@ public partial class AbpExtensibleDataGrid<TItem> : ComponentBase
protected Regex ExtensionPropertiesRegex = new Regex(@"ExtraProperties\[(.*?)\]");
[Parameter] public IEnumerable<TItem> Data { get; set; }
[Parameter] public IEnumerable<TItem> Data { get; set; } = default!;
[Parameter] public EventCallback<DataGridReadDataEventArgs<TItem>> ReadData { get; set; }
@ -28,16 +28,16 @@ public partial class AbpExtensibleDataGrid<TItem> : ComponentBase
[Parameter] public int PageSize { get; set; }
[Parameter] public IEnumerable<TableColumn> Columns { get; set; }
[Parameter] public IEnumerable<TableColumn> Columns { get; set; } = default!;
[Parameter] public int CurrentPage { get; set; } = 1;
[Parameter] public string Class { get; set; }
[Parameter] public string? Class { get; set; }
[Parameter] public bool Responsive { get; set; }
[Inject]
public IStringLocalizerFactory StringLocalizerFactory { get; set; }
public IStringLocalizerFactory StringLocalizerFactory { get; set; } = default!;
protected virtual RenderFragment RenderCustomTableColumnComponent(Type type, object data)
{
@ -51,10 +51,10 @@ public partial class AbpExtensibleDataGrid<TItem> : ComponentBase
protected virtual string GetConvertedFieldValue(TItem item, TableColumn columnDefinition)
{
var convertedValue = columnDefinition.ValueConverter.Invoke(item);
var convertedValue = columnDefinition.ValueConverter!.Invoke(item!);
if (!columnDefinition.DisplayFormat.IsNullOrEmpty())
{
return string.Format(columnDefinition.DisplayFormatProvider, columnDefinition.DisplayFormat,
return string.Format(columnDefinition.DisplayFormatProvider, columnDefinition.DisplayFormat!,
convertedValue);
}

2
framework/src/Volo.Abp.BlazoriseUI/Components/AlertWrapper.cs

@ -4,6 +4,6 @@ namespace Volo.Abp.BlazoriseUI.Components;
internal class AlertWrapper
{
public AlertMessage AlertMessage { get; set; }
public AlertMessage AlertMessage { get; set; } = default!;
public bool IsVisible { get; set; }
}

2
framework/src/Volo.Abp.BlazoriseUI/Components/DataGridEntityActionsColumn.razor.cs

@ -10,7 +10,7 @@ namespace Volo.Abp.BlazoriseUI.Components;
public partial class DataGridEntityActionsColumn<TItem> : DataGridColumn<TItem>
{
[Inject]
public IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
public IStringLocalizer<AbpUiResource> UiLocalizer { get; set; } = default!;
protected override async Task OnInitializedAsync()
{

18
framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs

@ -18,7 +18,7 @@ public partial class EntityAction<TItem> : ComponentBase
internal bool HasPermission { get; set; } = true;
[Parameter]
public string Text { get; set; }
public string Text { get; set; } = default!;
[Parameter]
public bool Primary { get; set; }
@ -28,25 +28,25 @@ public partial class EntityAction<TItem> : ComponentBase
[Parameter]
[Obsolete("Use Visible to hide actions based on permissions. Check the permission yourself. It is more performant. This option might be removed in future versions.")]
public string RequiredPolicy { get; set; }
public string? RequiredPolicy { get; set; }
[Parameter]
public Color Color { get; set; }
public Color? Color { get; set; }
[Parameter]
public Func<string> ConfirmationMessage { get; set; }
public Func<string>? ConfirmationMessage { get; set; }
[Parameter]
public string Icon { get; set; }
public string? Icon { get; set; }
[CascadingParameter]
public EntityActions<TItem> ParentActions { get; set; }
public EntityActions<TItem> ParentActions { get; set; } = default!;
[Inject]
protected IAuthorizationService AuthorizationService { get; set; }
protected IAuthorizationService AuthorizationService { get; set; } = default!;
[Inject]
protected IUiMessageService UiMessageService { get; set; }
protected IUiMessageService UiMessageService { get; set; } = default!;
protected async override Task OnInitializedAsync()
{
@ -55,7 +55,7 @@ public partial class EntityAction<TItem> : ComponentBase
if (!RequiredPolicy.IsNullOrEmpty())
{
HasPermission = await AuthorizationService.IsGrantedAsync(RequiredPolicy);
HasPermission = await AuthorizationService.IsGrantedAsync(RequiredPolicy!);
}
ParentActions.AddAction(this);
}

2
framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor

@ -6,7 +6,7 @@
@if ( HasPrimaryAction )
{
<Button Block="true"
Color="@PrimaryAction.Color"
Color="@PrimaryAction!.Color"
Clicked="async ()=> await PrimaryAction.ActionClickedAsync()"
Disabled=@PrimaryAction.Disabled>
@PrimaryAction.Text

12
framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs

@ -12,19 +12,19 @@ public partial class EntityActions<TItem> : ComponentBase
{
protected readonly List<EntityAction<TItem>> Actions = new List<EntityAction<TItem>>();
protected bool HasPrimaryAction => Actions.Any(t => t.Primary);
protected EntityAction<TItem> PrimaryAction => Actions.FirstOrDefault(t => t.Primary);
protected EntityAction<TItem>? PrimaryAction => Actions.FirstOrDefault(t => t.Primary);
[Parameter]
public Color ToggleColor { get; set; } = Color.Primary;
[Parameter]
public string ToggleText { get; set; }
public string? ToggleText { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
public RenderFragment ChildContent { get; set; } = default!;
[Parameter]
public DataGridEntityActionsColumn<TItem> EntityActionsColumn { get; set; }
public DataGridEntityActionsColumn<TItem> EntityActionsColumn { get; set; } = default!;
[Parameter]
public ActionType Type { get; set; } = ActionType.Dropdown;
@ -33,10 +33,10 @@ public partial class EntityActions<TItem> : ComponentBase
public bool Disabled { get; set; } = false;
[CascadingParameter]
public DataGridEntityActionsColumn<TItem> ParentEntityActionsColumn { get; set; }
public DataGridEntityActionsColumn<TItem>? ParentEntityActionsColumn { get; set; }
[Inject]
public IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
public IStringLocalizer<AbpUiResource> UiLocalizer { get; set; } = default!;
internal void AddAction(EntityAction<TItem> action)
{

16
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/EnumHelper.cs

@ -17,17 +17,17 @@ public static class EnumHelper
var localizedMemberName = AbpInternalLocalizationHelper.LocalizeWithFallback(
new[]
{
stringLocalizerFactory.CreateDefaultOrNull()
stringLocalizerFactory.CreateDefaultOrNull()
},
new[]
{
$"Enum:{enumType.Name}.{value}",
$"Enum:{enumType.Name}.{memberName}",
$"{enumType.Name}.{value}",
$"{enumType.Name}.{memberName}",
memberName
},
memberName
$"Enum:{enumType.Name}.{value}",
$"Enum:{enumType.Name}.{memberName}",
$"{enumType.Name}.{value}",
$"{enumType.Name}.{memberName}",
memberName
}!,
memberName!
);
return localizedMemberName;

6
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs

@ -10,13 +10,13 @@ public partial class ExtensionProperties<TEntityType, TResourceType> : Component
where TEntityType : IHasExtraProperties
{
[Inject]
public IStringLocalizerFactory StringLocalizerFactory { get; set; }
public IStringLocalizerFactory StringLocalizerFactory { get; set; } = default!;
[Parameter]
public AbpBlazorMessageLocalizerHelper<TResourceType> LH { get; set; }
public AbpBlazorMessageLocalizerHelper<TResourceType> LH { get; set; } = default!;
[Parameter]
public TEntityType Entity { get; set; }
public TEntityType Entity { get; set; } = default!;
[Parameter]
public ExtensionPropertyModalType? ModalType { get; set; }

12
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionPropertyComponentBase.cs

@ -16,22 +16,22 @@ public abstract class ExtensionPropertyComponentBase<TEntity, TResourceType> : O
where TEntity : IHasExtraProperties
{
[Inject]
public IStringLocalizerFactory StringLocalizerFactory { get; set; }
public IStringLocalizerFactory StringLocalizerFactory { get; set; } = default!;
[Inject]
public IAbpEnumLocalizer AbpEnumLocalizer { get; set; }
public IAbpEnumLocalizer AbpEnumLocalizer { get; set; } = default!;
[Inject]
public IValidationMessageLocalizerAttributeFinder ValidationMessageLocalizerAttributeFinder { get; set; }
public IValidationMessageLocalizerAttributeFinder ValidationMessageLocalizerAttributeFinder { get; set; } = default!;
[Parameter]
public TEntity Entity { get; set; }
public TEntity Entity { get; set; } = default!;
[Parameter]
public ObjectExtensionPropertyInfo PropertyInfo { get; set; }
public ObjectExtensionPropertyInfo PropertyInfo { get; set; } = default!;
[Parameter]
public AbpBlazorMessageLocalizerHelper<TResourceType> LH { get; set; }
public AbpBlazorMessageLocalizerHelper<TResourceType> LH { get; set; } = default!;
[Parameter]
public ExtensionPropertyModalType? ModalType { get; set; }

12
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/LookupExtensionProperty.razor.cs

@ -25,11 +25,11 @@ public partial class LookupExtensionProperty<TEntity, TResourceType>
{
protected List<SelectItem<object>> lookupItems = new();
[Inject] public ILookupApiRequestService LookupApiService { get; set; }
[Inject] public ILookupApiRequestService LookupApiService { get; set; } = default!;
public string TextPropertyName => PropertyInfo.Name + "_Text";
public object SelectedValue {
public object? SelectedValue {
get { return Entity.GetProperty(PropertyInfo.Name); }
set {
Entity.SetProperty(PropertyInfo.Name, value, false);
@ -45,7 +45,7 @@ public partial class LookupExtensionProperty<TEntity, TResourceType>
{
lookupItems.Add(new SelectItem<object>
{
Text = Entity.GetProperty(TextPropertyName).ToString(),
Text = Entity.GetProperty(TextPropertyName)!.ToString()!,
Value = value
});
}
@ -61,7 +61,7 @@ public partial class LookupExtensionProperty<TEntity, TResourceType>
}
}
protected virtual void UpdateLookupTextProperty(object value)
protected virtual void UpdateLookupTextProperty(object? value)
{
var selectedItemText = lookupItems.SingleOrDefault(t => t.Value.Equals(value))?.Text;
Entity.SetProperty(TextPropertyName, selectedItemText);
@ -85,8 +85,8 @@ public partial class LookupExtensionProperty<TEntity, TResourceType>
{
selectItems.Add(new SelectItem<object>
{
Text = item.GetProperty(PropertyInfo.Lookup.DisplayPropertyName).GetString(),
Value = JsonSerializer.Deserialize(item.GetProperty(PropertyInfo.Lookup.ValuePropertyName).GetRawText(), PropertyInfo.Type)
Text = item.GetProperty(PropertyInfo.Lookup.DisplayPropertyName).GetString()!,
Value = JsonSerializer.Deserialize(item.GetProperty(PropertyInfo.Lookup.ValuePropertyName).GetRawText(), PropertyInfo.Type)!
});
}

6
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/SelectExtensionProperty.razor.cs

@ -44,13 +44,13 @@ public partial class SelectExtensionProperty<TEntity, TResourceType>
if (!Entity.HasProperty(PropertyInfo.Name))
{
SelectedValue = (int)PropertyInfo.Type.GetEnumValues().GetValue(0);
SelectedValue = (int)PropertyInfo.Type.GetEnumValues().GetValue(0)!;
}
}
}
public class SelectItem<TValue>
{
public string Text { get; set; }
public TValue Value { get; set; }
public string Text { get; set; } = default!;
public TValue Value { get; set; } = default!;
}

2
framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/TextExtensionProperty.razor.cs

@ -5,7 +5,7 @@ namespace Volo.Abp.BlazoriseUI.Components.ObjectExtending;
public partial class TextExtensionProperty<TEntity, TResourceType>
where TEntity : IHasExtraProperties
{
protected string Value {
protected string? Value {
get {
return PropertyInfo.GetTextInputValueOrNull(Entity.GetProperty(PropertyInfo.Name));
}

10
framework/src/Volo.Abp.BlazoriseUI/Components/PageAlert.razor.cs

@ -14,10 +14,10 @@ public partial class PageAlert : ComponentBase, IDisposable
private List<AlertWrapper> Alerts = new List<AlertWrapper>();
[Inject]
protected IAlertManager AlertManager { get; set; }
protected IAlertManager AlertManager { get; set; } = default!;
[Inject]
protected NavigationManager NavigationManager { get; set; }
protected NavigationManager NavigationManager { get; set; } = default!;
protected override void OnInitialized()
{
@ -33,17 +33,17 @@ public partial class PageAlert : ComponentBase, IDisposable
}
//Since Blazor WASM doesn't support scoped dependency, we need to clear alerts on each location changed event.
private void NavigationManager_LocationChanged(object sender, LocationChangedEventArgs e)
private void NavigationManager_LocationChanged(object? sender, LocationChangedEventArgs e)
{
AlertManager.Alerts.Clear();
Alerts.Clear();
}
private void Alerts_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
private void Alerts_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (var item in e.NewItems)
foreach (var item in e.NewItems!)
{
Alerts.Add(new AlertWrapper
{

6
framework/src/Volo.Abp.BlazoriseUI/Components/SubmitButton.razor.cs

@ -12,7 +12,7 @@ public partial class SubmitButton : ComponentBase
protected bool Submiting { get; set; }
[Parameter]
public string Form { get; set; }
public string Form { get; set; } = default!;
[Parameter]
public ButtonType Type { get; set; } = ButtonType.Submit;
@ -36,10 +36,10 @@ public partial class SubmitButton : ComponentBase
public EventCallback Clicked { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
public RenderFragment? ChildContent { get; set; }
[Inject]
protected IStringLocalizer<AbpUiResource> StringLocalizer { get; set; }
protected IStringLocalizer<AbpUiResource> StringLocalizer { get; set; } = default!;
protected bool IsDisabled
=> Disabled == true || Submiting;

8
framework/src/Volo.Abp.BlazoriseUI/Components/ToolbarButton.razor.cs

@ -8,16 +8,16 @@ namespace Volo.Abp.BlazoriseUI.Components;
public partial class ToolbarButton : ComponentBase
{
[Parameter]
public Color Color { get; set; }
public Color? Color { get; set; }
[Parameter]
public object Icon { get; set; }
public object? Icon { get; set; }
[Parameter]
public string Text { get; set; }
public string Text { get; set; } = default!;
[Parameter]
public Func<Task> Clicked { get; set; }
public Func<Task> Clicked { get; set; } = default!;
[Parameter]
public bool Disabled { get; set; }

23
framework/src/Volo.Abp.BlazoriseUI/Components/UiMessageAlert.razor.cs

@ -10,7 +10,7 @@ namespace Volo.Abp.BlazoriseUI.Components;
public partial class UiMessageAlert : ComponentBase, IDisposable
{
protected Modal ModalRef { get; set; }
protected Modal ModalRef { get; set; } = default!;
protected virtual bool IsConfirmation
=> MessageType == UiMessageType.Confirmation;
@ -21,7 +21,7 @@ public partial class UiMessageAlert : ComponentBase, IDisposable
protected virtual bool ShowMessageIcon
=> Options?.ShowMessageIcon ?? true;
protected virtual object MessageIcon => Options?.MessageIcon ?? MessageType switch
protected virtual object? MessageIcon => Options?.MessageIcon ?? MessageType switch
{
UiMessageType.Info => IconName.Info,
UiMessageType.Success => IconName.Check,
@ -31,7 +31,7 @@ public partial class UiMessageAlert : ComponentBase, IDisposable
_ => null,
};
protected virtual string MessageIconColor => MessageType switch
protected virtual string? MessageIconColor => MessageType switch
{
// gets the color in the order of importance: Blazorise > Bootstrap > fallback color
UiMessageType.Info => "var(--b-theme-info, var(--info, #17a2b8))",
@ -63,13 +63,13 @@ public partial class UiMessageAlert : ComponentBase, IDisposable
[Parameter] public UiMessageType MessageType { get; set; }
[Parameter] public string Title { get; set; }
[Parameter] public string? Title { get; set; }
[Parameter] public string Message { get; set; }
[Parameter] public string Message { get; set; } = default!;
[Parameter] public TaskCompletionSource<bool> Callback { get; set; }
[Parameter] public TaskCompletionSource<bool>? Callback { get; set; }
[Parameter] public UiMessageOptions Options { get; set; }
[Parameter] public UiMessageOptions? Options { get; set; }
[Parameter] public EventCallback Okayed { get; set; }
@ -77,16 +77,19 @@ public partial class UiMessageAlert : ComponentBase, IDisposable
[Parameter] public EventCallback Canceled { get; set; }
[Inject] protected BlazoriseUiMessageService UiMessageService { get; set; }
[Inject] protected BlazoriseUiMessageService? UiMessageService { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
UiMessageService.MessageReceived += OnMessageReceived;
if (UiMessageService != null)
{
UiMessageService.MessageReceived += OnMessageReceived;
}
}
private async void OnMessageReceived(object sender, UiMessageEventArgs e)
private async void OnMessageReceived(object? sender, UiMessageEventArgs e)
{
MessageType = e.MessageType;
Message = e.Message;

21
framework/src/Volo.Abp.BlazoriseUI/Components/UiNotificationAlert.razor.cs

@ -11,23 +11,23 @@ namespace Volo.Abp.BlazoriseUI.Components;
public partial class UiNotificationAlert : ComponentBase, IDisposable
{
protected SnackbarStack SnackbarStack { get; set; }
protected SnackbarStack SnackbarStack { get; set; } = default!;
[Parameter] public UiNotificationType NotificationType { get; set; }
[Parameter] public string Message { get; set; }
[Parameter] public string Message { get; set; } = default!;
[Parameter] public string Title { get; set; }
[Parameter] public string? Title { get; set; }
[Parameter] public UiNotificationOptions Options { get; set; }
[Parameter] public UiNotificationOptions? Options { get; set; }
[Parameter] public EventCallback Okayed { get; set; }
[Parameter] public EventCallback Closed { get; set; }
[Inject] protected BlazoriseUiNotificationService UiNotificationService { get; set; }
[Inject] protected BlazoriseUiNotificationService? UiNotificationService { get; set; }
[Inject] protected IStringLocalizerFactory StringLocalizerFactory { get; set; }
[Inject] protected IStringLocalizerFactory StringLocalizerFactory { get; set; } = default!;
protected virtual SnackbarColor GetSnackbarColor(UiNotificationType notificationType)
{
@ -45,10 +45,13 @@ public partial class UiNotificationAlert : ComponentBase, IDisposable
{
base.OnInitialized();
UiNotificationService.NotificationReceived += OnNotificationReceived;
if (UiNotificationService != null)
{
UiNotificationService.NotificationReceived += OnNotificationReceived;
}
}
protected virtual async void OnNotificationReceived(object sender, UiNotificationEventArgs e)
protected virtual async void OnNotificationReceived(object? sender, UiNotificationEventArgs e)
{
NotificationType = e.NotificationType;
Message = e.Message;
@ -62,7 +65,7 @@ public partial class UiNotificationAlert : ComponentBase, IDisposable
await SnackbarStack.PushAsync(Message, Title, GetSnackbarColor(e.NotificationType), (options) =>
{
options.CloseButtonIcon = IconName.Times;
options.ActionButtonText = okButtonText;
options.ActionButtonText = okButtonText!;
});
}

13
framework/src/Volo.Abp.BlazoriseUI/Components/UiPageProgress.razor.cs

@ -7,24 +7,27 @@ namespace Volo.Abp.BlazoriseUI.Components;
public partial class UiPageProgress : ComponentBase, IDisposable
{
protected PageProgress PageProgressRef { get; set; }
protected PageProgress PageProgressRef { get; set; } = default!;
protected int? Percentage { get; set; }
protected bool Visible { get; set; }
protected Color Color { get; set; }
protected Color Color { get; set; } = default!;
[Inject] protected IUiPageProgressService UiPageProgressService { get; set; }
[Inject] protected IUiPageProgressService? UiPageProgressService { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
UiPageProgressService.ProgressChanged += OnProgressChanged;
if (UiPageProgressService != null)
{
UiPageProgressService.ProgressChanged += OnProgressChanged;
}
}
private async void OnProgressChanged(object sender, UiPageProgressEventArgs e)
private async void OnProgressChanged(object? sender, UiPageProgressEventArgs e)
{
Percentage = e.Percentage;
Visible = e.Percentage == null || (e.Percentage >= 0 && e.Percentage <= 100);

2
framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>

2
framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpInternalLocalizationHelper.cs

@ -25,7 +25,7 @@ public static class AbpInternalLocalizationHelper
/// <returns></returns>
[Obsolete("Use IAbpEnumLocalizer instead.")]
public static string LocalizeWithFallback(
IStringLocalizer[] localizers,
IStringLocalizer?[] localizers,
string[] keys,
string defaultValue)
{

2
framework/src/Volo.Abp.Localization/Volo/Abp/Localization/IAbpEnumLocalizer.cs

@ -7,5 +7,5 @@ public interface IAbpEnumLocalizer
{
string GetString(Type enumType, object enumValue);
string GetString(Type enumType, object enumValue, IStringLocalizer[] specifyLocalizers);
string GetString(Type enumType, object enumValue, IStringLocalizer?[] specifyLocalizers);
}

4
framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/ExtraPropertyDictionary.cs

@ -4,14 +4,14 @@ using System.Collections.Generic;
namespace Volo.Abp.Data;
[Serializable]
public class ExtraPropertyDictionary : Dictionary<string, object>
public class ExtraPropertyDictionary : Dictionary<string, object?>
{
public ExtraPropertyDictionary()
{
}
public ExtraPropertyDictionary(IDictionary<string, object> dictionary)
public ExtraPropertyDictionary(IDictionary<string, object?> dictionary)
: base(dictionary)
{
}

16
framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/ExtraPropertyDictionaryExtensions.cs

@ -8,24 +8,24 @@ public static class ExtraPropertyDictionaryExtensions
public static T ToEnum<T>(this ExtraPropertyDictionary extraPropertyDictionary, string key)
where T : Enum
{
if (extraPropertyDictionary[key].GetType() == typeof(T))
if (extraPropertyDictionary[key]!.GetType() == typeof(T))
{
return (T)extraPropertyDictionary[key];
return (T)extraPropertyDictionary[key]!;
}
extraPropertyDictionary[key] = Enum.Parse(typeof(T), extraPropertyDictionary[key].ToString()!, ignoreCase: true);
return (T)extraPropertyDictionary[key];
extraPropertyDictionary[key] = Enum.Parse(typeof(T), extraPropertyDictionary[key]!.ToString()!, ignoreCase: true);
return (T)extraPropertyDictionary[key]!;
}
public static object ToEnum(this ExtraPropertyDictionary extraPropertyDictionary, string key, Type enumType)
{
if (!enumType.IsEnum || extraPropertyDictionary[key].GetType() == enumType)
if (!enumType.IsEnum || extraPropertyDictionary[key]!.GetType() == enumType)
{
return extraPropertyDictionary[key];
return extraPropertyDictionary[key]!;
}
extraPropertyDictionary[key] = Enum.Parse(enumType, extraPropertyDictionary[key].ToString()!, ignoreCase: true);
return extraPropertyDictionary[key];
extraPropertyDictionary[key] = Enum.Parse(enumType, extraPropertyDictionary[key]!.ToString()!, ignoreCase: true);
return extraPropertyDictionary[key]!;
}
public static bool HasSameItems(

6
framework/src/Volo.Abp.ObjectExtending/Volo/Abp/Data/HasExtraPropertiesExtensions.cs

@ -20,7 +20,7 @@ public static class HasExtraPropertiesExtensions
public static object? GetProperty(this IHasExtraProperties source, string name, object? defaultValue = null)
{
return source.ExtraProperties?.GetOrDefault(name)
return source.ExtraProperties.GetOrDefault(name)
?? defaultValue;
}
@ -59,7 +59,7 @@ public static class HasExtraPropertiesExtensions
public static TSource SetProperty<TSource>(
this TSource source,
string name,
object value,
object? value,
bool validate = true)
where TSource : IHasExtraProperties
{
@ -98,7 +98,7 @@ public static class HasExtraPropertiesExtensions
continue;
}
source.ExtraProperties[property.Name] = property.GetDefaultValue()!;
source.ExtraProperties[property.Name] = property.GetDefaultValue();
}
return source;

8
framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ExtensibleObjectMapper.cs

@ -75,8 +75,8 @@ public static class ExtensibleObjectMapper
/// </param>
/// <param name="ignoredProperties">Used to ignore some properties</param>
public static void MapExtraPropertiesTo<TSource, TDestination>(
[NotNull] Dictionary<string, object> sourceDictionary,
[NotNull] Dictionary<string, object> destinationDictionary,
[NotNull] Dictionary<string, object?> sourceDictionary,
[NotNull] Dictionary<string, object?> destinationDictionary,
MappingPropertyDefinitionChecks? definitionChecks = null,
string[]? ignoredProperties = null)
where TSource : IHasExtraProperties
@ -110,8 +110,8 @@ public static class ExtensibleObjectMapper
public static void MapExtraPropertiesTo(
[NotNull] Type sourceType,
[NotNull] Type destinationType,
[NotNull] Dictionary<string, object> sourceDictionary,
[NotNull] Dictionary<string, object> destinationDictionary,
[NotNull] Dictionary<string, object?> sourceDictionary,
[NotNull] Dictionary<string, object?> destinationDictionary,
MappingPropertyDefinitionChecks? definitionChecks = null,
string[]? ignoredProperties = null)
{

Loading…
Cancel
Save