Browse Source

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

pull/17062/head
liangshiwei 3 years ago
parent
commit
981c709b29
  1. 2
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo.Abp.AspNetCore.Components.Web.csproj
  2. 2
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorClientHttpMessageHandler.cs
  3. 4
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorMessageLocalizerHelper.cs
  4. 2
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieOptions.cs
  5. 4
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieService.cs
  6. 2
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DefaultServerUrlProvider.cs
  7. 2
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DependencyInjection/ComponentsClientScopeServiceProviderAccessor.cs
  8. 6
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLogger.cs
  9. 2
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs
  10. 8
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/UserExceptionInformer.cs
  11. 14
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs
  12. 2
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityActionDictionary.cs
  13. 15
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumn.cs
  14. 2
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumnDictionary.cs
  15. 4
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ICookieService.cs
  16. 2
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IServerUrlProvider.cs
  17. 10
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Messages/SimpleUiMessageService.cs
  18. 5
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs
  19. 2
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/ApplicationConfigurationChangedService.cs

2
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo.Abp.AspNetCore.Components.Web.csproj

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

2
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorClientHttpMessageHandler.cs

@ -82,7 +82,7 @@ public class AbpBlazorClientHttpMessageHandler : DelegatingHandler, ITransientDe
var selfUri = new Uri(_navigationManager.Uri);
if (request.RequestUri.Host != selfUri.Host || request.RequestUri.Port != selfUri.Port)
if (request.RequestUri!.Host != selfUri.Host || request.RequestUri.Port != selfUri.Port)
{
return;
}

4
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorMessageLocalizerHelper.cs

@ -14,12 +14,12 @@ public class AbpBlazorMessageLocalizerHelper<T>
this.stringLocalizer = stringLocalizer;
}
public string Localize(string message, [CanBeNull] IEnumerable<string> arguments)
public string Localize(string message, IEnumerable<string>? arguments)
{
try
{
return arguments?.Count() > 0
? stringLocalizer[message, LocalizeMessageArguments(arguments)?.ToArray()]
? stringLocalizer[message, LocalizeMessageArguments(arguments)?.ToArray()!]
: stringLocalizer[message];
}
catch

2
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieOptions.cs

@ -5,6 +5,6 @@ namespace Volo.Abp.AspNetCore.Components.Web;
public class CookieOptions
{
public DateTimeOffset? ExpireDate { get; set; }
public string Path { get; set; }
public string? Path { get; set; }
public bool Secure { get; set; }
}

4
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieService.cs

@ -14,7 +14,7 @@ public class CookieService : ICookieService, ITransientDependency
JsRuntime = jsRuntime;
}
public async ValueTask SetAsync(string key, string value, CookieOptions options)
public async ValueTask SetAsync(string key, string value, CookieOptions? options)
{
await JsRuntime.InvokeVoidAsync("abp.utils.setCookieValue", key, value, options?.ExpireDate?.ToString("r"), options?.Path, options?.Secure);
}
@ -24,7 +24,7 @@ public class CookieService : ICookieService, ITransientDependency
return await JsRuntime.InvokeAsync<string>("abp.utils.getCookieValue", key);
}
public async ValueTask DeleteAsync(string key, string path = null)
public async ValueTask DeleteAsync(string key, string? path = null)
{
await JsRuntime.InvokeVoidAsync("abp.utils.deleteCookie", key);
}

2
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DefaultServerUrlProvider.cs

@ -5,7 +5,7 @@ namespace Volo.Abp.AspNetCore.Components.Web;
public class DefaultServerUrlProvider : IServerUrlProvider, ISingletonDependency
{
public Task<string> GetBaseUrlAsync(string remoteServiceName = null)
public Task<string> GetBaseUrlAsync(string? remoteServiceName = null)
{
return Task.FromResult("/");
}

2
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DependencyInjection/ComponentsClientScopeServiceProviderAccessor.cs

@ -7,5 +7,5 @@ public class ComponentsClientScopeServiceProviderAccessor :
IClientScopeServiceProviderAccessor,
ISingletonDependency
{
public IServiceProvider ServiceProvider { get; set; }
public IServiceProvider ServiceProvider { get; set; } = default!;
}

6
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLogger.cs

@ -8,7 +8,7 @@ namespace Volo.Abp.AspNetCore.Components.Web.ExceptionHandling;
public class AbpExceptionHandlingLogger : ILogger
{
private readonly IServiceCollection _serviceCollection;
private IUserExceptionInformer _userExceptionInformer;
private IUserExceptionInformer? _userExceptionInformer;
public AbpExceptionHandlingLogger(IServiceCollection serviceCollection)
{
@ -19,7 +19,7 @@ public class AbpExceptionHandlingLogger : ILogger
LogLevel logLevel,
EventId eventId,
TState state,
Exception exception,
Exception? exception,
Func<TState, Exception, string> formatter)
{
if (exception == null)
@ -58,7 +58,7 @@ public class AbpExceptionHandlingLogger : ILogger
return logLevel == LogLevel.Critical || logLevel == LogLevel.Error;
}
public virtual IDisposable BeginScope<TState>(TState state)
public virtual IDisposable? BeginScope<TState>(TState state) where TState : notnull
{
return NullDisposable.Instance;
}

2
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs

@ -5,7 +5,7 @@ namespace Volo.Abp.AspNetCore.Components.Web.ExceptionHandling;
public class AbpExceptionHandlingLoggerProvider : ILoggerProvider
{
private AbpExceptionHandlingLogger _logger;
private AbpExceptionHandlingLogger? _logger;
private static readonly object SyncObj = new object();
private readonly IServiceCollection _serviceCollection;

8
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/UserExceptionInformer.cs

@ -39,11 +39,11 @@ public class UserExceptionInformer : IUserExceptionInformer, IScopedDependency
if (errorInfo.Details.IsNullOrEmpty())
{
MessageService.Error(errorInfo.Message);
MessageService.Error(errorInfo.Message!);
}
else
{
MessageService.Error(errorInfo.Details, errorInfo.Message);
MessageService.Error(errorInfo.Details!, errorInfo.Message);
}
}
@ -53,11 +53,11 @@ public class UserExceptionInformer : IUserExceptionInformer, IScopedDependency
if (errorInfo.Details.IsNullOrEmpty())
{
await MessageService.Error(errorInfo.Message);
await MessageService.Error(errorInfo.Message!);
}
else
{
await MessageService.Error(errorInfo.Details, errorInfo.Message);
await MessageService.Error(errorInfo.Details!, errorInfo.Message);
}
}

14
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs

@ -5,15 +5,15 @@ namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions;
public class EntityAction : IEquatable<EntityAction>
{
public string Text { get; set; }
public Func<object, Task> Clicked { get; set; }
public Func<object, string> ConfirmationMessage { get; set; }
public string Text { get; set; } = default!;
public Func<object, Task> Clicked { get; set; } = default!;
public Func<object, string>? ConfirmationMessage { get; set; }
public bool Primary { get; set; }
public object Color { get; set; }
public string Icon { get; set; }
public Func<object, bool> Visible { get; set; }
public object? Color { get; set; }
public string? Icon { get; set; }
public Func<object, bool>? Visible { get; set; }
public bool Disabled { get; set; }
public bool Equals(EntityAction other)
public bool Equals(EntityAction? other)
{
return string.Equals(Text, other?.Text, StringComparison.OrdinalIgnoreCase);
}

2
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityActionDictionary.cs

@ -6,6 +6,6 @@ public class EntityActionDictionary : Dictionary<string, List<EntityAction>>
{
public List<EntityAction> Get<T>()
{
return this.GetOrAdd(typeof(T).FullName, () => new List<EntityAction>());
return this.GetOrAdd(typeof(T).FullName!, () => new List<EntityAction>());
}
}

15
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumn.cs

@ -8,23 +8,20 @@ namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns;
public class TableColumn
{
public string Title { get; set; }
public string Data { get; set; }
public string Title { get; set; } = default!;
public string Data { get; set; } = default!;
public string PropertyName { get; set; }
public string PropertyName { get; set; } = default!;
[CanBeNull]
public string DisplayFormat { get; set; }
public string? DisplayFormat { get; set; }
public IFormatProvider DisplayFormatProvider { get; set; } = CultureInfo.CurrentCulture;
[CanBeNull]
public Type Component { get; set; }
public Type? Component { get; set; }
public List<EntityAction> Actions { get; set; }
[CanBeNull]
public Func<object, string> ValueConverter { get; set; }
public Func<object, string>? ValueConverter { get; set; }
public bool Sortable { get; set; }

2
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumnDictionary.cs

@ -6,6 +6,6 @@ public class TableColumnDictionary : Dictionary<string, List<TableColumn>>
{
public List<TableColumn> Get<T>()
{
return this.GetOrAdd(typeof(T).FullName, () => new List<TableColumn>());
return this.GetOrAdd(typeof(T).FullName!, () => new List<TableColumn>());
}
}

4
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ICookieService.cs

@ -4,7 +4,7 @@ namespace Volo.Abp.AspNetCore.Components.Web;
public interface ICookieService
{
public ValueTask SetAsync(string key, string value, CookieOptions options = null);
public ValueTask SetAsync(string key, string value, CookieOptions? options = null);
public ValueTask<string> GetAsync(string key);
public ValueTask DeleteAsync(string key, string path = null);
public ValueTask DeleteAsync(string key, string? path = null);
}

2
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IServerUrlProvider.cs

@ -4,5 +4,5 @@ namespace Volo.Abp.AspNetCore.Components.Web;
public interface IServerUrlProvider
{
Task<string> GetBaseUrlAsync(string remoteServiceName = null);
Task<string> GetBaseUrlAsync(string? remoteServiceName = null);
}

10
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Messages/SimpleUiMessageService.cs

@ -15,27 +15,27 @@ public class SimpleUiMessageService : IUiMessageService, ITransientDependency
JsRuntime = jsRuntime;
}
public async Task Info(string message, string title = null, Action<UiMessageOptions> options = null)
public async Task Info(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
await JsRuntime.InvokeVoidAsync("alert", message);
}
public async Task Success(string message, string title = null, Action<UiMessageOptions> options = null)
public async Task Success(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
await JsRuntime.InvokeVoidAsync("alert", message);
}
public async Task Warn(string message, string title = null, Action<UiMessageOptions> options = null)
public async Task Warn(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
await JsRuntime.InvokeVoidAsync("alert", message);
}
public async Task Error(string message, string title = null, Action<UiMessageOptions> options = null)
public async Task Error(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
await JsRuntime.InvokeVoidAsync("alert", message);
}
public async Task<bool> Confirm(string message, string title = null, Action<UiMessageOptions> options = null)
public async Task<bool> Confirm(string message, string? title = null, Action<UiMessageOptions>? options = null)
{
return await JsRuntime.InvokeAsync<bool>("confirm", message);
}

5
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs

@ -9,10 +9,9 @@ namespace Volo.Abp.AspNetCore.Components.Web.Security;
public class AbpComponentsClaimsCache : IScopedDependency
{
public ClaimsPrincipal Principal { get; private set; }
public ClaimsPrincipal Principal { get; private set; } = default!;
[CanBeNull]
private readonly AuthenticationStateProvider _authenticationStateProvider;
private readonly AuthenticationStateProvider? _authenticationStateProvider;
public AbpComponentsClaimsCache(
IClientScopeServiceProviderAccessor serviceProviderAccessor)

2
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/ApplicationConfigurationChangedService.cs

@ -6,7 +6,7 @@ public delegate void ApplicationConfigurationChangedHandler();
public class ApplicationConfigurationChangedService : IScopedDependency
{
public event ApplicationConfigurationChangedHandler Changed;
public event ApplicationConfigurationChangedHandler Changed = default!;
public void NotifyChanged()
{

Loading…
Cancel
Save