From faed48d48bb52605f02b65d500893a4503cfda89 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 6 Jul 2023 17:38:30 +0800 Subject: [PATCH] Enable nullable annotations for Volo.Abp.AspNetCore.Components.MauiBlazor --- ...Abp.AspNetCore.Components.MauiBlazor.csproj | 2 ++ .../AbpAspNetCoreComponentsMauiBlazorModule.cs | 2 +- .../AbpMauiBlazorClientHttpMessageHandler.cs | 2 +- .../ApplicationConfigurationCache.cs | 6 +++--- .../IMauiBlazorSelectedLanguageProvider.cs | 2 +- .../MauiBlazorCurrentTenantAccessor.cs | 2 +- .../MauiBlazor/MauiBlazorRemoteTenantStore.cs | 18 +++++++++--------- .../MauiBlazor/MauiBlazorServerUrlProvider.cs | 4 ++-- .../NullMauiBlazorSelectedLanguageProvider.cs | 4 ++-- .../Components/Messages/UiMessageOptions.cs | 14 +++++++------- .../Notifications/UiNotificationOptions.cs | 4 ++-- 11 files changed, 31 insertions(+), 29 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo.Abp.AspNetCore.Components.MauiBlazor.csproj b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo.Abp.AspNetCore.Components.MauiBlazor.csproj index b1b9dcde81..ff80cd1fba 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo.Abp.AspNetCore.Components.MauiBlazor.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo.Abp.AspNetCore.Components.MauiBlazor.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable Volo.Abp.AspNetCore.Components.MauiBlazor Volo.Abp.AspNetCore.Components.MauiBlazor $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpAspNetCoreComponentsMauiBlazorModule.cs b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpAspNetCoreComponentsMauiBlazorModule.cs index 9772db6a92..010bad5db2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpAspNetCoreComponentsMauiBlazorModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpAspNetCoreComponentsMauiBlazorModule.cs @@ -51,7 +51,7 @@ public class AbpAspNetCoreComponentsMauiBlazorModule : AbpModule var cultureName = configuration.Localization?.CurrentCulture?.CultureName; if (!cultureName.IsNullOrEmpty()) { - var culture = new CultureInfo(cultureName); + var culture = new CultureInfo(cultureName!); CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpMauiBlazorClientHttpMessageHandler.cs b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpMauiBlazorClientHttpMessageHandler.cs index 90471ba6b4..9fb31979ac 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpMauiBlazorClientHttpMessageHandler.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpMauiBlazorClientHttpMessageHandler.cs @@ -48,7 +48,7 @@ public class AbpMauiBlazorClientHttpMessageHandler : DelegatingHandler, ITransie if (!selectedLanguage.IsNullOrWhiteSpace()) { request.Headers.AcceptLanguage.Clear(); - request.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue(selectedLanguage)); + request.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue(selectedLanguage!)); } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/ApplicationConfigurationCache.cs b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/ApplicationConfigurationCache.cs index a50c25824e..f4857165f7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/ApplicationConfigurationCache.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/ApplicationConfigurationCache.cs @@ -7,11 +7,11 @@ namespace Volo.Abp.AspNetCore.Components.MauiBlazor; public class ApplicationConfigurationCache : ISingletonDependency { - protected ApplicationConfigurationDto Configuration { get; set; } + protected ApplicationConfigurationDto? Configuration { get; set; } - public event Action ApplicationConfigurationChanged; + public event Action ApplicationConfigurationChanged = default!; - public virtual ApplicationConfigurationDto Get() + public virtual ApplicationConfigurationDto? Get() { return Configuration; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/IMauiBlazorSelectedLanguageProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/IMauiBlazorSelectedLanguageProvider.cs index c6b4722f58..f995f79a83 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/IMauiBlazorSelectedLanguageProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/IMauiBlazorSelectedLanguageProvider.cs @@ -4,5 +4,5 @@ namespace Volo.Abp.AspNetCore.Components.MauiBlazor; public interface IMauiBlazorSelectedLanguageProvider { - Task GetSelectedLanguageAsync(); + Task GetSelectedLanguageAsync(); } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorCurrentTenantAccessor.cs b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorCurrentTenantAccessor.cs index 9fa7ad03ca..230bd06929 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorCurrentTenantAccessor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorCurrentTenantAccessor.cs @@ -6,5 +6,5 @@ namespace Volo.Abp.AspNetCore.Components.MauiBlazor; [Dependency(ReplaceServices = true)] public class MauiBlazorCurrentTenantAccessor : ICurrentTenantAccessor, ISingletonDependency { - public BasicTenantInfo Current { get; set; } + public BasicTenantInfo? Current { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorRemoteTenantStore.cs b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorRemoteTenantStore.cs index 3cace3f113..235fe74354 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorRemoteTenantStore.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorRemoteTenantStore.cs @@ -23,13 +23,13 @@ public class MauiBlazorRemoteTenantStore : ITenantStore, ITransientDependency Cache = cache; } - public async Task FindAsync(string name) + public async Task FindAsync(string name) { var cacheKey = CreateCacheKey(name); var tenantConfiguration = await Cache.GetOrAddAsync( cacheKey, - async () => CreateTenantConfiguration(await TenantAppService.FindTenantByNameAsync(name)), + async () => CreateTenantConfiguration(await TenantAppService.FindTenantByNameAsync(name))!, () => new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = @@ -40,13 +40,13 @@ public class MauiBlazorRemoteTenantStore : ITenantStore, ITransientDependency return tenantConfiguration; } - public async Task FindAsync(Guid id) + public async Task FindAsync(Guid id) { var cacheKey = CreateCacheKey(id); var tenantConfiguration = await Cache.GetOrAddAsync( cacheKey, - async () => CreateTenantConfiguration(await TenantAppService.FindTenantByIdAsync(id)), + async () => CreateTenantConfiguration(await TenantAppService.FindTenantByIdAsync(id))!, () => new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = @@ -57,13 +57,13 @@ public class MauiBlazorRemoteTenantStore : ITenantStore, ITransientDependency return tenantConfiguration; } - public TenantConfiguration Find(string name) + public TenantConfiguration? Find(string name) { var cacheKey = CreateCacheKey(name); var tenantConfiguration = Cache.GetOrAdd( cacheKey, - () => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await TenantAppService.FindTenantByNameAsync(name))), + () => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await TenantAppService.FindTenantByNameAsync(name)))!, () => new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = @@ -74,13 +74,13 @@ public class MauiBlazorRemoteTenantStore : ITenantStore, ITransientDependency return tenantConfiguration; } - public TenantConfiguration Find(Guid id) + public TenantConfiguration? Find(Guid id) { var cacheKey = CreateCacheKey(id); var tenantConfiguration = Cache.GetOrAdd( cacheKey, - () => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await TenantAppService.FindTenantByIdAsync(id))), + () => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await TenantAppService.FindTenantByIdAsync(id)))!, () => new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = @@ -91,7 +91,7 @@ public class MauiBlazorRemoteTenantStore : ITenantStore, ITransientDependency return tenantConfiguration; } - protected virtual TenantConfiguration CreateTenantConfiguration(FindTenantResultDto tenantResultDto) + protected virtual TenantConfiguration? CreateTenantConfiguration(FindTenantResultDto tenantResultDto) { if (!tenantResultDto.Success || tenantResultDto.TenantId == null) { diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorServerUrlProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorServerUrlProvider.cs index 1204bfb99b..a76d631677 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorServerUrlProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorServerUrlProvider.cs @@ -17,12 +17,12 @@ public class MauiBlazorServerUrlProvider : IServerUrlProvider, ITransientDepende RemoteServiceConfigurationProvider = remoteServiceConfigurationProvider; } - public async Task GetBaseUrlAsync(string remoteServiceName = null) + public async Task GetBaseUrlAsync(string? remoteServiceName = null) { var remoteServiceConfiguration = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync( remoteServiceName ?? RemoteServiceConfigurationDictionary.DefaultName ); - return remoteServiceConfiguration.BaseUrl.EnsureEndsWith('/'); + return remoteServiceConfiguration.BaseUrl!.EnsureEndsWith('/'); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/NullMauiBlazorSelectedLanguageProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/NullMauiBlazorSelectedLanguageProvider.cs index b617b96da4..4f1d0504ca 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/NullMauiBlazorSelectedLanguageProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/NullMauiBlazorSelectedLanguageProvider.cs @@ -5,8 +5,8 @@ namespace Volo.Abp.AspNetCore.Components.MauiBlazor; public class NullMauiBlazorSelectedLanguageProvider : IMauiBlazorSelectedLanguageProvider, ITransientDependency { - public Task GetSelectedLanguageAsync() + public Task GetSelectedLanguageAsync() { - return Task.FromResult((string)null); + return Task.FromResult((string?)null); } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs index 5cb8e56eee..a13029a580 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs @@ -18,35 +18,35 @@ public class UiMessageOptions /// /// Overrides the build-in message icon. /// - public object MessageIcon { get; set; } + public object? MessageIcon { get; set; } /// /// Custom text for the Ok button. /// - public string OkButtonText { get; set; } + public string? OkButtonText { get; set; } /// /// Custom icon for the Ok button. /// - public object OkButtonIcon { get; set; } + public object? OkButtonIcon { get; set; } /// /// Custom text for the Confirmation button. /// - public string ConfirmButtonText { get; set; } + public string? ConfirmButtonText { get; set; } /// /// Custom icon for the Confirmation button. /// - public object ConfirmButtonIcon { get; set; } + public object? ConfirmButtonIcon { get; set; } /// /// Custom text for the Cancel button. /// - public string CancelButtonText { get; set; } + public string? CancelButtonText { get; set; } /// /// Custom icon for the Cancel button. /// - public object CancelButtonIcon { get; set; } + public object? CancelButtonIcon { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationOptions.cs index c3f6a74fa5..0668d32311 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationOptions.cs @@ -10,10 +10,10 @@ public class UiNotificationOptions /// /// Custom text for the Ok button. /// - public ILocalizableString OkButtonText { get; set; } + public ILocalizableString? OkButtonText { get; set; } /// /// Custom icon for the Ok button. /// - public object OkButtonIcon { get; set; } + public object? OkButtonIcon { get; set; } }