Enable nullable annotations for Volo.Abp.AspNetCore.Components.MauiBlazor

pull/17062/head
liangshiwei 2 years ago
parent 287f434a8f
commit faed48d48b

@ -5,6 +5,8 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AssemblyName>Volo.Abp.AspNetCore.Components.MauiBlazor</AssemblyName>
<PackageId>Volo.Abp.AspNetCore.Components.MauiBlazor</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

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

@ -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!));
}
}
}

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

@ -4,5 +4,5 @@ namespace Volo.Abp.AspNetCore.Components.MauiBlazor;
public interface IMauiBlazorSelectedLanguageProvider
{
Task<string> GetSelectedLanguageAsync();
Task<string?> GetSelectedLanguageAsync();
}

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

@ -23,13 +23,13 @@ public class MauiBlazorRemoteTenantStore : ITenantStore, ITransientDependency
Cache = cache;
}
public async Task<TenantConfiguration> FindAsync(string name)
public async Task<TenantConfiguration?> 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<TenantConfiguration> FindAsync(Guid id)
public async Task<TenantConfiguration?> 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)
{

@ -17,12 +17,12 @@ public class MauiBlazorServerUrlProvider : IServerUrlProvider, ITransientDepende
RemoteServiceConfigurationProvider = remoteServiceConfigurationProvider;
}
public async Task<string> GetBaseUrlAsync(string remoteServiceName = null)
public async Task<string> GetBaseUrlAsync(string? remoteServiceName = null)
{
var remoteServiceConfiguration = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync(
remoteServiceName ?? RemoteServiceConfigurationDictionary.DefaultName
);
return remoteServiceConfiguration.BaseUrl.EnsureEndsWith('/');
return remoteServiceConfiguration.BaseUrl!.EnsureEndsWith('/');
}
}

@ -5,8 +5,8 @@ namespace Volo.Abp.AspNetCore.Components.MauiBlazor;
public class NullMauiBlazorSelectedLanguageProvider : IMauiBlazorSelectedLanguageProvider, ITransientDependency
{
public Task<string> GetSelectedLanguageAsync()
public Task<string?> GetSelectedLanguageAsync()
{
return Task.FromResult((string)null);
return Task.FromResult((string?)null);
}
}

@ -18,35 +18,35 @@ public class UiMessageOptions
/// <summary>
/// Overrides the build-in message icon.
/// </summary>
public object MessageIcon { get; set; }
public object? MessageIcon { get; set; }
/// <summary>
/// Custom text for the Ok button.
/// </summary>
public string OkButtonText { get; set; }
public string? OkButtonText { get; set; }
/// <summary>
/// Custom icon for the Ok button.
/// </summary>
public object OkButtonIcon { get; set; }
public object? OkButtonIcon { get; set; }
/// <summary>
/// Custom text for the Confirmation button.
/// </summary>
public string ConfirmButtonText { get; set; }
public string? ConfirmButtonText { get; set; }
/// <summary>
/// Custom icon for the Confirmation button.
/// </summary>
public object ConfirmButtonIcon { get; set; }
public object? ConfirmButtonIcon { get; set; }
/// <summary>
/// Custom text for the Cancel button.
/// </summary>
public string CancelButtonText { get; set; }
public string? CancelButtonText { get; set; }
/// <summary>
/// Custom icon for the Cancel button.
/// </summary>
public object CancelButtonIcon { get; set; }
public object? CancelButtonIcon { get; set; }
}

@ -10,10 +10,10 @@ public class UiNotificationOptions
/// <summary>
/// Custom text for the Ok button.
/// </summary>
public ILocalizableString OkButtonText { get; set; }
public ILocalizableString? OkButtonText { get; set; }
/// <summary>
/// Custom icon for the Ok button.
/// </summary>
public object OkButtonIcon { get; set; }
public object? OkButtonIcon { get; set; }
}

Loading…
Cancel
Save