From 741461e6c201fdfe2e40a55e5df8ad86ec5717a9 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 6 Jul 2023 16:17:28 +0800 Subject: [PATCH 01/11] Enable nullable annotations for Volo.Abp.AspNetCore --- .../Builder/AbpApplicationBuilderExtensions.cs | 2 +- .../AbpAspNetCoreApplicationBuilderExtensions.cs | 2 +- .../VirtualFileSystemApplicationBuilderExtensions.cs | 2 +- .../Hosting/AbpHostingEnvironmentExtensions.cs | 2 +- .../AspNetCore/Internal/ResponseContentTypeHelper.cs | 4 ++-- .../AbpRequestLocalizationOptionsManager.cs | 4 ++-- .../DefaultAbpRequestLocalizationOptionsProvider.cs | 8 ++++---- .../IAbpRequestLocalizationOptionsProvider.cs | 2 +- .../CookieAuthenticationOptionsExtensions.cs | 2 +- .../DependencyInjection/EmptyHostingEnvironment.cs | 12 ++++++------ .../WebApplicationBuilderExtensions.cs | 4 ++-- .../Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj | 2 ++ .../ApplicationInitializationContextExtensions.cs | 5 ++--- .../AbpAuthorizationExceptionHandlerOptions.cs | 2 +- .../DefaultAbpAuthorizationExceptionHandler.cs | 4 ++-- .../DefaultHttpExceptionStatusCodeFinder.cs | 4 ++-- .../Security/AbpSecurityHeadersMiddleware.cs | 6 +++--- .../AspNetCore/Security/AbpSecurityHeadersOptions.cs | 2 +- .../AspNetCore/Tracing/AbpCorrelationIdMiddleware.cs | 4 ++-- .../AbpFileExtensionContentTypeProvider.cs | 6 +++--- .../RazorViewEngineVirtualFileProvider.cs | 2 +- .../HttpContextWebClientInfoProvider.cs | 8 ++++---- .../WebClientInfo/IWebClientInfoProvider.cs | 4 ++-- .../Volo/Abp/ServiceProviderAccessorExtensions.cs | 3 +-- 24 files changed, 48 insertions(+), 48 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs index 8ef3ec8d99..8628c2c803 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs @@ -82,7 +82,7 @@ public static class AbpApplicationBuilderExtensions } public static IApplicationBuilder UseAbpRequestLocalization(this IApplicationBuilder app, - Action optionsAction = null) + Action? optionsAction = null) { app.ApplicationServices .GetRequiredService() diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpAspNetCoreApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpAspNetCoreApplicationBuilderExtensions.cs index 684c948975..20da8d47ce 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpAspNetCoreApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpAspNetCoreApplicationBuilderExtensions.cs @@ -17,7 +17,7 @@ public static class AbpAspNetCoreApplicationBuilderExtensions /// public static IApplicationBuilder UseConfiguredEndpoints( this IApplicationBuilder app, - Action additionalConfigurationAction = null) + Action? additionalConfigurationAction = null) { var options = app.ApplicationServices .GetRequiredService>() diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/VirtualFileSystemApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/VirtualFileSystemApplicationBuilderExtensions.cs index 9fc3603f2e..171747c100 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/VirtualFileSystemApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/VirtualFileSystemApplicationBuilderExtensions.cs @@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Builder; public static class VirtualFileSystemApplicationBuilderExtensions { [Obsolete("Use UseStaticFiles() instead. UseVirtualFiles is not needed anymore.")] - public static IApplicationBuilder UseVirtualFiles(this IApplicationBuilder app, Action configure = null) + public static IApplicationBuilder UseVirtualFiles(this IApplicationBuilder app, Action? configure = null) { if (configure != null) { diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Hosting/AbpHostingEnvironmentExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Hosting/AbpHostingEnvironmentExtensions.cs index 15c1d74ccb..8f6b32ba9a 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Hosting/AbpHostingEnvironmentExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Hosting/AbpHostingEnvironmentExtensions.cs @@ -7,7 +7,7 @@ public static class AbpHostingEnvironmentExtensions { public static IConfigurationRoot BuildConfiguration( this IWebHostEnvironment env, - AbpConfigurationBuilderOptions options = null) + AbpConfigurationBuilderOptions? options = null) { options ??= new AbpConfigurationBuilderOptions(); diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Internal/ResponseContentTypeHelper.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Internal/ResponseContentTypeHelper.cs index bff1290835..7a492371b9 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Internal/ResponseContentTypeHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Internal/ResponseContentTypeHelper.cs @@ -28,7 +28,7 @@ public static class ResponseContentTypeHelper string? actionResultContentType, string? httpResponseContentType, (string defaultContentType, Encoding defaultEncoding) @default, - Func getEncoding, + Func getEncoding, out string resolvedContentType, out Encoding resolvedContentTypeEncoding) { @@ -66,7 +66,7 @@ public static class ResponseContentTypeHelper resolvedContentTypeEncoding = defaultContentTypeEncoding; } - public static Encoding GetEncoding(string mediaType) + public static Encoding? GetEncoding(string mediaType) { if (MediaTypeHeaderValue.TryParse(mediaType, out var parsed)) { diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationOptionsManager.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationOptionsManager.cs index 61ec6e2fa3..098a7ef433 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationOptionsManager.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationOptionsManager.cs @@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.RequestLocalization; public class AbpRequestLocalizationOptionsManager : AbpDynamicOptionsManager { - private RequestLocalizationOptions _options; + private RequestLocalizationOptions? _options; private readonly IAbpRequestLocalizationOptionsProvider _abpRequestLocalizationOptionsProvider; @@ -19,7 +19,7 @@ public class AbpRequestLocalizationOptionsManager : AbpDynamicOptionsManager _optionsAction; - private RequestLocalizationOptions _requestLocalizationOptions; + private Action? _optionsAction; + private RequestLocalizationOptions? _requestLocalizationOptions; public DefaultAbpRequestLocalizationOptionsProvider(IServiceScopeFactory serviceProviderFactory) { @@ -28,7 +28,7 @@ public class DefaultAbpRequestLocalizationOptionsProvider : IAbpRequestLocalizat _syncSemaphore = new SemaphoreSlim(1, 1); } - public void InitLocalizationOptions(Action optionsAction = null) + public void InitLocalizationOptions(Action? optionsAction = null) { _optionsAction = optionsAction; } @@ -85,7 +85,7 @@ public class DefaultAbpRequestLocalizationOptionsProvider : IAbpRequestLocalizat return _requestLocalizationOptions; } - private static RequestCulture DefaultGetRequestCulture(string defaultLanguage, IReadOnlyList languages) + private static RequestCulture DefaultGetRequestCulture(string? defaultLanguage, IReadOnlyList languages) { if (defaultLanguage == null) { diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/IAbpRequestLocalizationOptionsProvider.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/IAbpRequestLocalizationOptionsProvider.cs index e26a23ef4d..0b8e85ada2 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/IAbpRequestLocalizationOptionsProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/IAbpRequestLocalizationOptionsProvider.cs @@ -6,7 +6,7 @@ namespace Microsoft.AspNetCore.RequestLocalization; public interface IAbpRequestLocalizationOptionsProvider { - void InitLocalizationOptions(Action optionsAction = null); + void InitLocalizationOptions(Action? optionsAction = null); Task GetLocalizationOptionsAsync(); } diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/CookieAuthenticationOptionsExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/CookieAuthenticationOptionsExtensions.cs index f873f3762b..0e33ce87fc 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/CookieAuthenticationOptionsExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/CookieAuthenticationOptionsExtensions.cs @@ -47,7 +47,7 @@ public static class CookieAuthenticationOptionsExtensions var response = await openIdConnectOptions.Backchannel.IntrospectTokenAsync(new TokenIntrospectionRequest { - Address = openIdConnectOptions.Configuration?.IntrospectionEndpoint ?? openIdConnectOptions.Authority.EnsureEndsWith('/') + "connect/introspect", + Address = openIdConnectOptions.Configuration?.IntrospectionEndpoint ?? openIdConnectOptions.Authority!.EnsureEndsWith('/') + "connect/introspect", ClientId = openIdConnectOptions.ClientId, ClientSecret = openIdConnectOptions.ClientSecret, Token = accessToken diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/EmptyHostingEnvironment.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/EmptyHostingEnvironment.cs index 371162f0da..99439b9d70 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/EmptyHostingEnvironment.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/EmptyHostingEnvironment.cs @@ -5,15 +5,15 @@ namespace Microsoft.Extensions.DependencyInjection; internal class EmptyHostingEnvironment : IWebHostEnvironment { - public string EnvironmentName { get; set; } + public string EnvironmentName { get; set; } = default!; - public string ApplicationName { get; set; } + public string ApplicationName { get; set; } = default!; - public string WebRootPath { get; set; } + public string WebRootPath { get; set; } = default!; - public IFileProvider WebRootFileProvider { get; set; } + public IFileProvider WebRootFileProvider { get; set; } = default!; - public string ContentRootPath { get; set; } + public string ContentRootPath { get; set; } = default!; - public IFileProvider ContentRootFileProvider { get; set; } + public IFileProvider ContentRootFileProvider { get; set; } = default!; } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/WebApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/WebApplicationBuilderExtensions.cs index f044348052..00d8b4ab3d 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/WebApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/Extensions/DependencyInjection/WebApplicationBuilderExtensions.cs @@ -11,7 +11,7 @@ public static class WebApplicationBuilderExtensions { public static async Task AddApplicationAsync( [NotNull] this WebApplicationBuilder builder, - [CanBeNull] Action optionsAction = null) + Action? optionsAction = null) where TStartupModule : IAbpModule { return await builder.Services.AddApplicationAsync(options => @@ -28,7 +28,7 @@ public static class WebApplicationBuilderExtensions public static async Task AddApplicationAsync( [NotNull] this WebApplicationBuilder builder, [NotNull] Type startupModuleType, - [CanBeNull] Action optionsAction = null) + Action? optionsAction = null) { return await builder.Services.AddApplicationAsync(startupModuleType, options => { diff --git a/framework/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj b/framework/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj index 0fe01e9f2b..20ee51e01f 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj +++ b/framework/src/Volo.Abp.AspNetCore/Volo.Abp.AspNetCore.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable Volo.Abp.AspNetCore Volo.Abp.AspNetCore $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/ApplicationInitializationContextExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/ApplicationInitializationContextExtensions.cs index 4a57b998c3..045b293489 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/ApplicationInitializationContextExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/ApplicationInitializationContextExtensions.cs @@ -12,7 +12,7 @@ public static class ApplicationInitializationContextExtensions { public static IApplicationBuilder GetApplicationBuilder(this ApplicationInitializationContext context) { - return context.ServiceProvider.GetRequiredService>().Value; + return context.ServiceProvider.GetRequiredService>().Value!; } public static IWebHostEnvironment GetEnvironment(this ApplicationInitializationContext context) @@ -20,8 +20,7 @@ public static class ApplicationInitializationContextExtensions return context.ServiceProvider.GetRequiredService(); } - [CanBeNull] - public static IWebHostEnvironment GetEnvironmentOrNull(this ApplicationInitializationContext context) + public static IWebHostEnvironment? GetEnvironmentOrNull(this ApplicationInitializationContext context) { return context.ServiceProvider.GetService(); } diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/AbpAuthorizationExceptionHandlerOptions.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/AbpAuthorizationExceptionHandlerOptions.cs index 73f668cb49..6d1935c0bd 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/AbpAuthorizationExceptionHandlerOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/AbpAuthorizationExceptionHandlerOptions.cs @@ -2,5 +2,5 @@ public class AbpAuthorizationExceptionHandlerOptions { - public string AuthenticationScheme { get; set; } + public string? AuthenticationScheme { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultAbpAuthorizationExceptionHandler.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultAbpAuthorizationExceptionHandler.cs index 0c65fa6124..43eecc4cd2 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultAbpAuthorizationExceptionHandler.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultAbpAuthorizationExceptionHandler.cs @@ -17,11 +17,11 @@ public class DefaultAbpAuthorizationExceptionHandler : IAbpAuthorizationExceptio var isAuthenticated = httpContext.User.Identity?.IsAuthenticated ?? false; var authenticationSchemeProvider = httpContext.RequestServices.GetRequiredService(); - AuthenticationScheme scheme = null; + AuthenticationScheme? scheme = null; if (!handlerOptions.AuthenticationScheme.IsNullOrWhiteSpace()) { - scheme = await authenticationSchemeProvider.GetSchemeAsync(handlerOptions.AuthenticationScheme); + scheme = await authenticationSchemeProvider.GetSchemeAsync(handlerOptions.AuthenticationScheme!); if (scheme == null) { throw new AbpException($"No authentication scheme named {handlerOptions.AuthenticationScheme} was found."); diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs index 39614ad3ad..892b00b2d3 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs @@ -32,7 +32,7 @@ public class DefaultHttpExceptionStatusCodeFinder : IHttpExceptionStatusCodeFind if (exception is IHasErrorCode exceptionWithErrorCode && !exceptionWithErrorCode.Code.IsNullOrWhiteSpace()) { - if (Options.ErrorCodeToHttpStatusCodeMappings.TryGetValue(exceptionWithErrorCode.Code, out var status)) + if (Options.ErrorCodeToHttpStatusCodeMappings.TryGetValue(exceptionWithErrorCode.Code!, out var status)) { return status; } @@ -40,7 +40,7 @@ public class DefaultHttpExceptionStatusCodeFinder : IHttpExceptionStatusCodeFind if (exception is AbpAuthorizationException) { - return httpContext.User.Identity.IsAuthenticated + return httpContext.User.Identity!.IsAuthenticated ? HttpStatusCode.Forbidden : HttpStatusCode.Unauthorized; } diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/AbpSecurityHeadersMiddleware.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/AbpSecurityHeadersMiddleware.cs index b1068bbe85..aea345159a 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/AbpSecurityHeadersMiddleware.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/AbpSecurityHeadersMiddleware.cs @@ -32,7 +32,7 @@ public class AbpSecurityHeadersMiddleware : IMiddleware, ITransientDependency AddHeader(context, "X-Frame-Options", "SAMEORIGIN"); var requestAcceptTypeHtml = context.Request.Headers["Accept"].Any(x => - x.Contains("text/html") || x.Contains("*/*") || x.Contains("application/xhtml+xml")); + x!.Contains("text/html") || x.Contains("*/*") || x.Contains("application/xhtml+xml")); var endpoint = context.GetEndpoint(); @@ -109,7 +109,7 @@ public class AbpSecurityHeadersMiddleware : IMiddleware, ITransientDependency protected virtual string BuildContentSecurityPolicyValue(HttpContext context) { - var cspValue = Options.Value.ContentSecurityPolicyValue.IsNullOrWhiteSpace() ? DefaultValue : Options.Value.ContentSecurityPolicyValue; + var cspValue = Options.Value.ContentSecurityPolicyValue.IsNullOrWhiteSpace() ? DefaultValue : Options.Value.ContentSecurityPolicyValue!; if (!(Options.Value.UseContentSecurityPolicyScriptNonce && context.Items.TryGetValue(AbpAspNetCoreConsts.ScriptNonceKey, out var nonce) && nonce is string nonceValue && !string.IsNullOrEmpty(nonceValue))) @@ -128,7 +128,7 @@ public class AbpSecurityHeadersMiddleware : IMiddleware, ITransientDependency } var newScriptSrcValue = scriptSrcValue + nonceStr; - return Options.Value.ContentSecurityPolicyValue.Replace(scriptSrcValue, newScriptSrcValue); + return Options.Value.ContentSecurityPolicyValue!.Replace(scriptSrcValue!, newScriptSrcValue); } diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/AbpSecurityHeadersOptions.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/AbpSecurityHeadersOptions.cs index 9a0bb5cd82..eee1d59243 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/AbpSecurityHeadersOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Security/AbpSecurityHeadersOptions.cs @@ -11,7 +11,7 @@ public class AbpSecurityHeadersOptions public bool UseContentSecurityPolicyScriptNonce { get; set; } - public string ContentSecurityPolicyValue { get; set; } + public string? ContentSecurityPolicyValue { get; set; } public Dictionary Headers { get; } diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Tracing/AbpCorrelationIdMiddleware.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Tracing/AbpCorrelationIdMiddleware.cs index 33f5de3582..b5939bdc44 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Tracing/AbpCorrelationIdMiddleware.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Tracing/AbpCorrelationIdMiddleware.cs @@ -38,14 +38,14 @@ public class AbpCorrelationIdMiddleware : IMiddleware, ITransientDependency protected virtual string GetCorrelationIdFromRequest(HttpContext context) { - string correlationId = context.Request.Headers[_options.HttpHeaderName]; + string? correlationId = context.Request.Headers[_options.HttpHeaderName]; if (correlationId.IsNullOrEmpty()) { correlationId = Guid.NewGuid().ToString("N"); context.Request.Headers[_options.HttpHeaderName] = correlationId; } - return correlationId; + return correlationId!; } protected virtual void CheckAndSetCorrelationIdOnResponse( diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/AbpFileExtensionContentTypeProvider.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/AbpFileExtensionContentTypeProvider.cs index 8701353aa0..da96f2b8a9 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/AbpFileExtensionContentTypeProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/AbpFileExtensionContentTypeProvider.cs @@ -18,14 +18,14 @@ public class AbpFileExtensionContentTypeProvider : IContentTypeProvider, ITransi var extension = GetExtension(subpath); if (extension == null) { - contentType = null; + contentType = null!; return false; } - return Options.ContentTypeMaps.TryGetValue(extension, out contentType); + return Options.ContentTypeMaps.TryGetValue(extension, out contentType!); } - protected virtual string GetExtension(string path) + protected virtual string? GetExtension(string path) { if (string.IsNullOrWhiteSpace(path)) { diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/RazorViewEngineVirtualFileProvider.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/RazorViewEngineVirtualFileProvider.cs index 97bca5744f..bc0467a6f2 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/RazorViewEngineVirtualFileProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/RazorViewEngineVirtualFileProvider.cs @@ -16,7 +16,7 @@ public class RazorViewEngineVirtualFileProvider : IFileProvider { _serviceProviderAccessor = serviceProviderAccessor; _fileProvider = new Lazy( - () => serviceProviderAccessor.Value.GetRequiredService(), + () => serviceProviderAccessor.Value!.GetRequiredService(), true ); } diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/WebClientInfo/HttpContextWebClientInfoProvider.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/WebClientInfo/HttpContextWebClientInfoProvider.cs index ae9f342b06..3c44cda4e3 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/WebClientInfo/HttpContextWebClientInfoProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/WebClientInfo/HttpContextWebClientInfoProvider.cs @@ -18,16 +18,16 @@ public class HttpContextWebClientInfoProvider : IWebClientInfoProvider, ITransie HttpContextAccessor = httpContextAccessor; } - public string BrowserInfo => GetBrowserInfo(); + public string? BrowserInfo => GetBrowserInfo(); - public string ClientIpAddress => GetClientIpAddress(); + public string? ClientIpAddress => GetClientIpAddress(); - protected virtual string GetBrowserInfo() + protected virtual string? GetBrowserInfo() { return HttpContextAccessor.HttpContext?.Request?.Headers?["User-Agent"]; } - protected virtual string GetClientIpAddress() + protected virtual string? GetClientIpAddress() { try { diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/WebClientInfo/IWebClientInfoProvider.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/WebClientInfo/IWebClientInfoProvider.cs index 708f663daf..abd92597d3 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/WebClientInfo/IWebClientInfoProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/WebClientInfo/IWebClientInfoProvider.cs @@ -2,7 +2,7 @@ public interface IWebClientInfoProvider { - string BrowserInfo { get; } + string? BrowserInfo { get; } - string ClientIpAddress { get; } + string? ClientIpAddress { get; } } diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/ServiceProviderAccessorExtensions.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/ServiceProviderAccessorExtensions.cs index fd52e9ff0e..da7e40dbdc 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/ServiceProviderAccessorExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/ServiceProviderAccessorExtensions.cs @@ -7,8 +7,7 @@ namespace Volo.Abp; public static class ServiceProviderAccessorExtensions { - [CanBeNull] - public static HttpContext GetHttpContext(this IServiceProviderAccessor serviceProviderAccessor) + public static HttpContext? GetHttpContext(this IServiceProviderAccessor serviceProviderAccessor) { return serviceProviderAccessor.ServiceProvider.GetRequiredService().HttpContext; } From 287f434a8f3832e7b8593e54d25025f59b2efbb6 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 6 Jul 2023 16:50:46 +0800 Subject: [PATCH 02/11] Enable nullable annotations for Volo.Abp.AspNetCore.Components --- .../Volo.Abp.AspNetCore.Components.csproj | 2 + .../AspNetCore/Components/AbpComponentBase.cs | 70 +++++++++---------- .../AspNetCore/Components/Alerts/AlertList.cs | 10 +-- .../Components/Alerts/AlertMessage.cs | 7 +- .../Components/Messages/IUiMessageService.cs | 10 +-- .../Components/Messages/UiMessageEventArgs.cs | 2 +- .../Notifications/IUiNotificationService.cs | 8 +-- .../NullUiNotificationService.cs | 8 +-- .../Progression/IUiPageProgressService.cs | 2 +- .../Progression/NullUiPageProgressService.cs | 4 +- 10 files changed, 62 insertions(+), 61 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo.Abp.AspNetCore.Components.csproj b/framework/src/Volo.Abp.AspNetCore.Components/Volo.Abp.AspNetCore.Components.csproj index 95c23d34ad..865ccb9f75 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo.Abp.AspNetCore.Components.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo.Abp.AspNetCore.Components.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable Volo.Abp.AspNetCore.Components Volo.Abp.AspNetCore.Components $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs index 47a0d570bf..6f2df20de8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs @@ -20,8 +20,8 @@ namespace Volo.Abp.AspNetCore.Components; public abstract class AbpComponentBase : OwningComponentBase { - protected IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory); - private IStringLocalizerFactory _stringLocalizerFactory; + protected IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory)!; + private IStringLocalizerFactory? _stringLocalizerFactory; protected IStringLocalizer L { get { @@ -33,46 +33,46 @@ public abstract class AbpComponentBase : OwningComponentBase return _localizer; } } - private IStringLocalizer _localizer; + private IStringLocalizer? _localizer; - protected Type LocalizationResource { + protected Type? LocalizationResource { get => _localizationResource; set { _localizationResource = value; _localizer = null; } } - private Type _localizationResource = typeof(DefaultResource); + private Type? _localizationResource = typeof(DefaultResource); protected ILogger Logger => _lazyLogger.Value; - private Lazy _lazyLogger => new Lazy(() => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance, true); + private Lazy _lazyLogger => new Lazy(() => LoggerFactory?.CreateLogger(GetType().FullName!) ?? NullLogger.Instance, true); - protected ILoggerFactory LoggerFactory => LazyGetRequiredService(ref _loggerFactory); - private ILoggerFactory _loggerFactory; + protected ILoggerFactory LoggerFactory => LazyGetRequiredService(ref _loggerFactory)!; + private ILoggerFactory? _loggerFactory; - protected IAuthorizationService AuthorizationService => LazyGetRequiredService(ref _authorizationService); - private IAuthorizationService _authorizationService; + protected IAuthorizationService AuthorizationService => LazyGetRequiredService(ref _authorizationService)!; + private IAuthorizationService? _authorizationService; - protected ICurrentUser CurrentUser => LazyGetRequiredService(ref _currentUser); - private ICurrentUser _currentUser; + protected ICurrentUser CurrentUser => LazyGetRequiredService(ref _currentUser)!; + private ICurrentUser? _currentUser; - protected ICurrentTenant CurrentTenant => LazyGetRequiredService(ref _currentTenant); - private ICurrentTenant _currentTenant; + protected ICurrentTenant CurrentTenant => LazyGetRequiredService(ref _currentTenant)!; + private ICurrentTenant? _currentTenant; - protected IUiMessageService Message => LazyGetNonScopedRequiredService(ref _message); - private IUiMessageService _message; + protected IUiMessageService Message => LazyGetNonScopedRequiredService(ref _message)!; + private IUiMessageService? _message; - protected IUiNotificationService Notify => LazyGetNonScopedRequiredService(ref _notify); - private IUiNotificationService _notify; + protected IUiNotificationService Notify => LazyGetNonScopedRequiredService(ref _notify)!; + private IUiNotificationService? _notify; - protected IUserExceptionInformer UserExceptionInformer => LazyGetNonScopedRequiredService(ref _userExceptionInformer); - private IUserExceptionInformer _userExceptionInformer; + protected IUserExceptionInformer UserExceptionInformer => LazyGetNonScopedRequiredService(ref _userExceptionInformer)!; + private IUserExceptionInformer? _userExceptionInformer; - protected IAlertManager AlertManager => LazyGetNonScopedRequiredService(ref _alertManager); - private IAlertManager _alertManager; + protected IAlertManager AlertManager => LazyGetNonScopedRequiredService(ref _alertManager)!; + private IAlertManager? _alertManager; - protected IClock Clock => LazyGetNonScopedRequiredService(ref _clock); - private IClock _clock; + protected IClock Clock => LazyGetNonScopedRequiredService(ref _clock)!; + private IClock? _clock; protected AlertList Alerts => AlertManager.Alerts; @@ -85,19 +85,19 @@ public abstract class AbpComponentBase : OwningComponentBase if (ObjectMapperContext == null) { - return LazyGetRequiredService(ref _objectMapper); + return LazyGetRequiredService(ref _objectMapper)!; } return LazyGetRequiredService( typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext), ref _objectMapper - ); + )!; } } - private IObjectMapper _objectMapper; + private IObjectMapper? _objectMapper; - protected Type ObjectMapperContext { get; set; } + protected Type? ObjectMapperContext { get; set; } protected TService LazyGetRequiredService(ref TService reference) => LazyGetRequiredService(typeof(TService), ref reference); @@ -111,13 +111,13 @@ public abstract class AbpComponentBase : OwningComponentBase return reference; } - protected TService LazyGetService(ref TService reference) => LazyGetService(typeof(TService), ref reference); + protected TService? LazyGetService(ref TService? reference) => LazyGetService(typeof(TService), ref reference); - protected TRef LazyGetService(Type serviceType, ref TRef reference) + protected TRef? LazyGetService(Type serviceType, ref TRef? reference) { if (reference == null) { - reference = (TRef)ScopedServices.GetService(serviceType); + reference = (TRef?)ScopedServices.GetService(serviceType); } return reference; @@ -135,20 +135,20 @@ public abstract class AbpComponentBase : OwningComponentBase return reference; } - protected TService LazyGetNonScopedService(ref TService reference) => LazyGetNonScopedService(typeof(TService), ref reference); + protected TService? LazyGetNonScopedService(ref TService? reference) => LazyGetNonScopedService(typeof(TService), ref reference); - protected TRef LazyGetNonScopedService(Type serviceType, ref TRef reference) + protected TRef? LazyGetNonScopedService(Type serviceType, ref TRef? reference) { if (reference == null) { - reference = (TRef)NonScopedServices.GetService(serviceType); + reference = (TRef?)NonScopedServices.GetService(serviceType); } return reference; } [Inject] - protected IServiceProvider NonScopedServices { get; set; } + protected IServiceProvider NonScopedServices { get; set; } = default!; protected virtual IStringLocalizer CreateLocalizer() { diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertList.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertList.cs index 6ea0031352..f450033b01 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertList.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertList.cs @@ -9,27 +9,27 @@ namespace Volo.Abp.AspNetCore.Components.Alerts; public class AlertList : ObservableCollection { - public void Add(AlertType type, string text, string title = null, bool dismissible = true) + public void Add(AlertType type, string text, string? title = null, bool dismissible = true) { Add(new AlertMessage(type, text, title, dismissible)); } - public void Info(string text, string title = null, bool dismissible = true) + public void Info(string text, string? title = null, bool dismissible = true) { Add(new AlertMessage(AlertType.Info, text, title, dismissible)); } - public void Warning(string text, string title = null, bool dismissible = true) + public void Warning(string text, string? title = null, bool dismissible = true) { Add(new AlertMessage(AlertType.Warning, text, title, dismissible)); } - public void Danger(string text, string title = null, bool dismissible = true) + public void Danger(string text, string? title = null, bool dismissible = true) { Add(new AlertMessage(AlertType.Danger, text, title, dismissible)); } - public void Success(string text, string title = null, bool dismissible = true) + public void Success(string text, string? title = null, bool dismissible = true) { Add(new AlertMessage(AlertType.Success, text, title, dismissible)); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertMessage.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertMessage.cs index 7a38e422a0..15de91599b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertMessage.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertMessage.cs @@ -9,16 +9,15 @@ public class AlertMessage get => _text; set => _text = Check.NotNullOrWhiteSpace(value, nameof(value)); } - private string _text; + private string _text = default!; public AlertType Type { get; set; } - [CanBeNull] - public string Title { get; set; } + public string? Title { get; set; } public bool Dismissible { get; set; } - public AlertMessage(AlertType type, [NotNull] string text, string title = null, bool dismissible = true) + public AlertMessage(AlertType type, [NotNull] string text, string? title = null, bool dismissible = true) { Type = type; Text = Check.NotNullOrWhiteSpace(text, nameof(text)); diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/IUiMessageService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/IUiMessageService.cs index 86e878d2a9..9e8d65fdde 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/IUiMessageService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/IUiMessageService.cs @@ -5,13 +5,13 @@ namespace Volo.Abp.AspNetCore.Components.Messages; public interface IUiMessageService { - Task Info(string message, string title = null, Action options = null); + Task Info(string message, string? title = null, Action? options = null); - Task Success(string message, string title = null, Action options = null); + Task Success(string message, string? title = null, Action? options = null); - Task Warn(string message, string title = null, Action options = null); + Task Warn(string message, string? title = null, Action? options = null); - Task Error(string message, string title = null, Action options = null); + Task Error(string message, string? title = null, Action? options = null); - Task Confirm(string message, string title = null, Action options = null); + Task Confirm(string message, string? title = null, Action? options = null); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageEventArgs.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageEventArgs.cs index 4d73fb2812..adae13a4c2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageEventArgs.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageEventArgs.cs @@ -30,5 +30,5 @@ public class UiMessageEventArgs : EventArgs public UiMessageOptions Options { get; } - public TaskCompletionSource Callback { get; } + public TaskCompletionSource Callback { get; } = default!; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/IUiNotificationService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/IUiNotificationService.cs index 394fdec2a7..d637943af0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/IUiNotificationService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/IUiNotificationService.cs @@ -5,11 +5,11 @@ namespace Volo.Abp.AspNetCore.Components.Notifications; public interface IUiNotificationService { - Task Info(string message, string title = null, Action options = null); + Task Info(string message, string? title = null, Action? options = null); - Task Success(string message, string title = null, Action options = null); + Task Success(string message, string? title = null, Action? options = null); - Task Warn(string message, string title = null, Action options = null); + Task Warn(string message, string? title = null, Action? options = null); - Task Error(string message, string title = null, Action options = null); + Task Error(string message, string? title = null, Action? options = null); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/NullUiNotificationService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/NullUiNotificationService.cs index 6c47586325..e75b1f3524 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/NullUiNotificationService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/NullUiNotificationService.cs @@ -6,21 +6,21 @@ namespace Volo.Abp.AspNetCore.Components.Notifications; public class NullUiNotificationService : IUiNotificationService, ITransientDependency { - public Task Info(string message, string title = null, Action options = null) + public Task Info(string message, string? title = null, Action? options = null) { return Task.CompletedTask; } - public Task Success(string message, string title = null, Action options = null) + public Task Success(string message, string? title = null, Action? options = null) { return Task.CompletedTask; } - public Task Warn(string message, string title = null, Action options = null) + public Task Warn(string message, string? title = null, Action? options = null) { return Task.CompletedTask; } - public Task Error(string message, string title = null, Action options = null) + public Task Error(string message, string? title = null, Action? options = null) { return Task.CompletedTask; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs index 156c763722..1d32c86dc0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs @@ -16,5 +16,5 @@ public interface IUiPageProgressService /// Value of the progress from 0 to 100, or null for indeterminate progress. /// Additional options. /// Awaitable task. - Task Go(int? percentage, Action options = null); + Task Go(int? percentage, Action? options = null); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs index 2277122418..52f97f23d5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs @@ -6,9 +6,9 @@ namespace Volo.Abp.AspNetCore.Components.Progression; public class NullUiPageProgressService : IUiPageProgressService, ISingletonDependency { - public event EventHandler ProgressChanged; + public event EventHandler ProgressChanged = default!; - public Task Go(int? percentage, Action options = null) + public Task Go(int? percentage, Action? options = null) { return Task.CompletedTask; } From faed48d48bb52605f02b65d500893a4503cfda89 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 6 Jul 2023 17:38:30 +0800 Subject: [PATCH 03/11] 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; } } From 981c709b296c83ce8804693c86ae3e86a01bd886 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 7 Jul 2023 14:19:48 +0800 Subject: [PATCH 04/11] Enable nullable annotations for Volo.Abp.AspNetCore.Components.Web --- .../Volo.Abp.AspNetCore.Components.Web.csproj | 2 ++ .../Web/AbpBlazorClientHttpMessageHandler.cs | 2 +- .../Web/AbpBlazorMessageLocalizerHelper.cs | 4 ++-- .../AspNetCore/Components/Web/CookieOptions.cs | 2 +- .../AspNetCore/Components/Web/CookieService.cs | 4 ++-- .../Components/Web/DefaultServerUrlProvider.cs | 2 +- ...omponentsClientScopeServiceProviderAccessor.cs | 2 +- .../AbpExceptionHandlingLogger.cs | 6 +++--- .../AbpExceptionHandlingLoggerProvider.cs | 2 +- .../ExceptionHandling/UserExceptionInformer.cs | 8 ++++---- .../Extensibility/EntityActions/EntityAction.cs | 14 +++++++------- .../EntityActions/EntityActionDictionary.cs | 2 +- .../Web/Extensibility/TableColumns/TableColumn.cs | 15 ++++++--------- .../TableColumns/TableColumnDictionary.cs | 2 +- .../AspNetCore/Components/Web/ICookieService.cs | 4 ++-- .../Components/Web/IServerUrlProvider.cs | 2 +- .../Web/Messages/SimpleUiMessageService.cs | 10 +++++----- .../Web/Security/AbpComponentsClaimsCache.cs | 5 ++--- .../ApplicationConfigurationChangedService.cs | 2 +- 19 files changed, 44 insertions(+), 46 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo.Abp.AspNetCore.Components.Web.csproj b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo.Abp.AspNetCore.Components.Web.csproj index bc975f9f92..7f89d1c254 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo.Abp.AspNetCore.Components.Web.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo.Abp.AspNetCore.Components.Web.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorClientHttpMessageHandler.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorClientHttpMessageHandler.cs index eb8bee99bd..c92c121628 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorClientHttpMessageHandler.cs +++ b/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; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorMessageLocalizerHelper.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorMessageLocalizerHelper.cs index 52efbc6d11..dc0a2182cb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorMessageLocalizerHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorMessageLocalizerHelper.cs @@ -14,12 +14,12 @@ public class AbpBlazorMessageLocalizerHelper this.stringLocalizer = stringLocalizer; } - public string Localize(string message, [CanBeNull] IEnumerable arguments) + public string Localize(string message, IEnumerable? arguments) { try { return arguments?.Count() > 0 - ? stringLocalizer[message, LocalizeMessageArguments(arguments)?.ToArray()] + ? stringLocalizer[message, LocalizeMessageArguments(arguments)?.ToArray()!] : stringLocalizer[message]; } catch diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieOptions.cs index 283f665642..d8a5ec3a1a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieOptions.cs +++ b/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; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieService.cs index 1b61acb459..a3868d5b2e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieService.cs +++ b/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("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); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DefaultServerUrlProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DefaultServerUrlProvider.cs index 281ee3cd73..aae5f1f98b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DefaultServerUrlProvider.cs +++ b/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 GetBaseUrlAsync(string remoteServiceName = null) + public Task GetBaseUrlAsync(string? remoteServiceName = null) { return Task.FromResult("/"); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DependencyInjection/ComponentsClientScopeServiceProviderAccessor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DependencyInjection/ComponentsClientScopeServiceProviderAccessor.cs index f5e07865a7..2311a2c9f9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DependencyInjection/ComponentsClientScopeServiceProviderAccessor.cs +++ b/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!; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLogger.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLogger.cs index cf66f107a0..ba56233ec5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLogger.cs +++ b/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 formatter) { if (exception == null) @@ -58,7 +58,7 @@ public class AbpExceptionHandlingLogger : ILogger return logLevel == LogLevel.Critical || logLevel == LogLevel.Error; } - public virtual IDisposable BeginScope(TState state) + public virtual IDisposable? BeginScope(TState state) where TState : notnull { return NullDisposable.Instance; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs index 3f895502fa..d13fd5a751 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs +++ b/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; diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/UserExceptionInformer.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/UserExceptionInformer.cs index 0f0da11bdf..6773e4ff37 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/UserExceptionInformer.cs +++ b/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); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs index 837eb2c96a..56bcf3d543 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs +++ b/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 { - public string Text { get; set; } - public Func Clicked { get; set; } - public Func ConfirmationMessage { get; set; } + public string Text { get; set; } = default!; + public Func Clicked { get; set; } = default!; + public Func? ConfirmationMessage { get; set; } public bool Primary { get; set; } - public object Color { get; set; } - public string Icon { get; set; } - public Func Visible { get; set; } + public object? Color { get; set; } + public string? Icon { get; set; } + public Func? 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); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityActionDictionary.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityActionDictionary.cs index 0781870b69..8f638baff6 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityActionDictionary.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityActionDictionary.cs @@ -6,6 +6,6 @@ public class EntityActionDictionary : Dictionary> { public List Get() { - return this.GetOrAdd(typeof(T).FullName, () => new List()); + return this.GetOrAdd(typeof(T).FullName!, () => new List()); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumn.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumn.cs index aa48ad633b..efd1d9320b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumn.cs +++ b/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 Actions { get; set; } - [CanBeNull] - public Func ValueConverter { get; set; } + public Func? ValueConverter { get; set; } public bool Sortable { get; set; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumnDictionary.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumnDictionary.cs index 7eda70177c..67616eb061 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumnDictionary.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumnDictionary.cs @@ -6,6 +6,6 @@ public class TableColumnDictionary : Dictionary> { public List Get() { - return this.GetOrAdd(typeof(T).FullName, () => new List()); + return this.GetOrAdd(typeof(T).FullName!, () => new List()); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ICookieService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ICookieService.cs index afb124644e..393088fd6c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ICookieService.cs +++ b/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 GetAsync(string key); - public ValueTask DeleteAsync(string key, string path = null); + public ValueTask DeleteAsync(string key, string? path = null); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IServerUrlProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IServerUrlProvider.cs index f5266a9f18..76c261ea80 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IServerUrlProvider.cs +++ b/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 GetBaseUrlAsync(string remoteServiceName = null); + Task GetBaseUrlAsync(string? remoteServiceName = null); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Messages/SimpleUiMessageService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Messages/SimpleUiMessageService.cs index 647be65b41..91c1648cd2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Messages/SimpleUiMessageService.cs +++ b/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 options = null) + public async Task Info(string message, string? title = null, Action? options = null) { await JsRuntime.InvokeVoidAsync("alert", message); } - public async Task Success(string message, string title = null, Action options = null) + public async Task Success(string message, string? title = null, Action? options = null) { await JsRuntime.InvokeVoidAsync("alert", message); } - public async Task Warn(string message, string title = null, Action options = null) + public async Task Warn(string message, string? title = null, Action? options = null) { await JsRuntime.InvokeVoidAsync("alert", message); } - public async Task Error(string message, string title = null, Action options = null) + public async Task Error(string message, string? title = null, Action? options = null) { await JsRuntime.InvokeVoidAsync("alert", message); } - public async Task Confirm(string message, string title = null, Action options = null) + public async Task Confirm(string message, string? title = null, Action? options = null) { return await JsRuntime.InvokeAsync("confirm", message); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs index 7473387f83..74cbd37e29 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs +++ b/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) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/ApplicationConfigurationChangedService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/ApplicationConfigurationChangedService.cs index 9803a7991d..15aeb7eedb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/ApplicationConfigurationChangedService.cs +++ b/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() { From fdca8e3d2ac1f2d59d70e36596b5dac935f86631 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 7 Jul 2023 14:23:57 +0800 Subject: [PATCH 05/11] Enable nullable annotations for Volo.Abp.AspNetCore.Components.MauiBlazor.Theming --- .../Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.csproj b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.csproj index bc6b5fdb26..3cd049965e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming/Volo.Abp.AspNetCore.Components.MauiBlazor.Theming.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable From 6c1bd8a605e196ce80ba64672d28d506541c7090 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 7 Jul 2023 14:45:55 +0800 Subject: [PATCH 06/11] Enable nullable annotations for Volo.Abp.AspNetCore.Components.Server --- .../Cookies/CookieAuthenticationOptionsExtensions.cs | 2 +- .../Volo.Abp.AspNetCore.Components.Server.csproj | 2 ++ .../Extensibility/BlazorServerLookupApiRequestService.cs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server/Microsoft/AspNetCore/Authentication/Cookies/CookieAuthenticationOptionsExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Components.Server/Microsoft/AspNetCore/Authentication/Cookies/CookieAuthenticationOptionsExtensions.cs index 48065bbac2..ba542312d1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server/Microsoft/AspNetCore/Authentication/Cookies/CookieAuthenticationOptionsExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server/Microsoft/AspNetCore/Authentication/Cookies/CookieAuthenticationOptionsExtensions.cs @@ -33,7 +33,7 @@ public static class CookieAuthenticationOptionsExtensions var openIdConnectOptions = await GetOpenIdConnectOptions(principalContext, oidcAuthenticationScheme); var response = await openIdConnectOptions.Backchannel.IntrospectTokenAsync(new TokenIntrospectionRequest { - Address = openIdConnectOptions.Configuration?.IntrospectionEndpoint ?? openIdConnectOptions.Authority.EnsureEndsWith('/') + "connect/introspect", + Address = openIdConnectOptions.Configuration?.IntrospectionEndpoint ?? openIdConnectOptions.Authority!.EnsureEndsWith('/') + "connect/introspect", ClientId = openIdConnectOptions.ClientId, ClientSecret = openIdConnectOptions.ClientSecret, Token = accessToken diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo.Abp.AspNetCore.Components.Server.csproj b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo.Abp.AspNetCore.Components.Server.csproj index 297b2a8576..a8cb372ddc 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo.Abp.AspNetCore.Components.Server.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo.Abp.AspNetCore.Components.Server.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable true Library true diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs index 355f9fff44..130d2f9225 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs @@ -52,7 +52,7 @@ public class BlazorServerLookupApiRequestService : ILookupApiRequestService, ITr { //Blazor tiered -- mode var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("Default"); - baseUrl = remoteServiceConfig.BaseUrl; + baseUrl = remoteServiceConfig.BaseUrl!; client.BaseAddress = new Uri(baseUrl); AddHeaders(requestMessage); await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client, @@ -62,7 +62,7 @@ public class BlazorServerLookupApiRequestService : ILookupApiRequestService, ITr { baseUrl = NavigationManager.BaseUri; client.BaseAddress = new Uri(baseUrl); - foreach (var header in HttpContextAccessor.HttpContext.Request.Headers) + foreach (var header in HttpContextAccessor.HttpContext!.Request.Headers) { requestMessage.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray()); } From f0f739d2be144bab1b096a651173c66b9cd4543a Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 7 Jul 2023 14:55:59 +0800 Subject: [PATCH 07/11] Enable nullable annotations for Volo.Abp.AspNetCore.Components.Server.Theming --- .../Volo.Abp.AspNetCore.Components.Server.Theming.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Volo.Abp.AspNetCore.Components.Server.Theming.csproj b/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Volo.Abp.AspNetCore.Components.Server.Theming.csproj index c632120d73..266831eba9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Volo.Abp.AspNetCore.Components.Server.Theming.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Volo.Abp.AspNetCore.Components.Server.Theming.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable true Library true From ab0451ef99e4f5ca3be040cd5def479ebb9319cb Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 7 Jul 2023 16:06:18 +0800 Subject: [PATCH 08/11] Enable nullable annotations for Volo.Abp.AspNetCore.Components.Web.Theming --- .../Components/DynamicLayoutComponent.razor.cs | 2 +- .../Components/LayoutHooks/LayoutHook.razor.cs | 8 ++++---- .../Layout/PageHeader.razor.cs | 10 +++++----- .../Layout/PageLayout.cs | 12 ++++++------ .../PageToolbars/PageToolbarExtensions.cs | 16 ++++++++-------- .../PageToolbars/PageToolbarItem.cs | 5 ++--- .../PageToolbars/SimplePageToolbarContributor.cs | 8 ++++---- .../Routing/AbpRouterOptions.cs | 2 +- .../Theming/AbpThemingOptions.cs | 2 +- .../Theming/DefaultThemeManager.cs | 2 +- .../Toolbars/IToolbarConfigurationContext.cs | 3 +-- .../Toolbars/ToolbarConfigurationContext.cs | 3 +-- .../Toolbars/ToolbarItem.cs | 2 +- ....Abp.AspNetCore.Components.Web.Theming.csproj | 2 ++ .../Abp/Ui/LayoutHooks/LayoutHookViewModel.cs | 4 ++-- 15 files changed, 40 insertions(+), 41 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/DynamicLayoutComponent.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/DynamicLayoutComponent.razor.cs index 3c4d68178e..4363b674c0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/DynamicLayoutComponent.razor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/DynamicLayoutComponent.razor.cs @@ -6,5 +6,5 @@ namespace Volo.Abp.AspNetCore.Components.Web.Theming.Components; public partial class DynamicLayoutComponent : ComponentBase { [Inject] - protected IOptions AbpDynamicLayoutComponentOptions { get; set; } + protected IOptions AbpDynamicLayoutComponentOptions { get; set; } = default!; } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs index 729b990f34..f5ce191f20 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs @@ -10,15 +10,15 @@ namespace Volo.Abp.AspNetCore.Components.Web.Theming.Components.LayoutHooks; public partial class LayoutHook : ComponentBase { [Parameter] - public string Name { get; set; } + public string Name { get; set; } = default!; [Parameter] - public string Layout { get; set; } + public string? Layout { get; set; } [Inject] - protected IOptions LayoutHookOptions { get; set; } + protected IOptions LayoutHookOptions { get; set; } = default!; - protected LayoutHookViewModel LayoutHookViewModel { get; private set; } + protected LayoutHookViewModel LayoutHookViewModel { get; private set; } = default!; protected override Task OnInitializedAsync() { diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageHeader.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageHeader.razor.cs index ea0b810765..91485d5bf8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageHeader.razor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageHeader.razor.cs @@ -13,13 +13,13 @@ public partial class PageHeader : ComponentBase { protected List ToolbarItemRenders { get; set; } - public IPageToolbarManager PageToolbarManager { get; set; } + public IPageToolbarManager PageToolbarManager { get; set; } = default!; [Inject] - public PageLayout PageLayout { get; private set; } + public PageLayout PageLayout { get; private set; } = default!; [Parameter] // TODO: Consider removing this property in future and use only PageLayout. - public string Title { get => PageLayout.Title; set => PageLayout.Title = value; } + public string? Title { get => PageLayout.Title; set => PageLayout.Title = value; } [Parameter] public bool BreadcrumbShowHome { get; set; } = true; @@ -28,7 +28,7 @@ public partial class PageHeader : ComponentBase public bool BreadcrumbShowCurrent { get; set; } = true; [Parameter] - public RenderFragment ChildContent { get; set; } + public RenderFragment ChildContent { get; set; } = default!; [Parameter] // TODO: Consider removing this property in future and use only PageLayout. public List BreadcrumbItems { @@ -44,7 +44,7 @@ public partial class PageHeader : ComponentBase } [Parameter] - public PageToolbar Toolbar { get; set; } + public PageToolbar? Toolbar { get; set; } public PageHeader() { diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageLayout.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageLayout.cs index 4d04bd2ad7..077ca5b32c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageLayout.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageLayout.cs @@ -9,10 +9,10 @@ namespace Volo.Abp.AspNetCore.Components.Web.Theming.Layout; public class PageLayout : IScopedDependency, INotifyPropertyChanged { - private string title; + private string? title; // TODO: Consider using this property for setting Page Title too. - public virtual string Title { + public virtual string? Title { get => title; set { title = value; @@ -20,9 +20,9 @@ public class PageLayout : IScopedDependency, INotifyPropertyChanged } } - private string menuItemName; + private string? menuItemName; - public string MenuItemName { + public string? MenuItemName { get => menuItemName; set { @@ -35,9 +35,9 @@ public class PageLayout : IScopedDependency, INotifyPropertyChanged public virtual ObservableCollection ToolbarItems { get; } = new(); - public event PropertyChangedEventHandler PropertyChanged; + public event PropertyChangedEventHandler? PropertyChanged; - protected void OnPropertyChanged([CallerMemberName] string propertyName = null) + protected void OnPropertyChanged([CallerMemberName] string? propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarExtensions.cs index 9d9448d281..673c004fdb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarExtensions.cs @@ -11,9 +11,9 @@ public static class PageToolbarExtensions { public static PageToolbar AddComponent( this PageToolbar toolbar, - Dictionary arguments = null, + Dictionary? arguments = 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, - Dictionary arguments = null, + Dictionary? arguments = null, int order = 0, - string requiredPolicyName = null) + string? requiredPolicyName = null) { toolbar.Contributors.Add( new SimplePageToolbarContributor( @@ -46,14 +46,14 @@ public static class PageToolbarExtensions this PageToolbar toolbar, string text, Func clicked, - object icon = null, - Color color = null, + object? icon = null, + Color? color = null, bool disabled = false, int order = 0, - string requiredPolicyName = null) + string? requiredPolicyName = null) { toolbar.AddComponent( - new Dictionary + new Dictionary { { nameof(ToolbarButton.Color), color ?? Color.Primary}, { nameof(ToolbarButton.Text), text}, diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarItem.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarItem.cs index f62d770403..3e38fb9b1a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarItem.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarItem.cs @@ -9,14 +9,13 @@ public class PageToolbarItem [NotNull] public Type ComponentType { get; } - [CanBeNull] - public Dictionary Arguments { get; set; } + public Dictionary? Arguments { get; set; } public int Order { get; set; } public PageToolbarItem( [NotNull] Type componentType, - [CanBeNull] Dictionary arguments = null, + Dictionary? arguments = null, int order = 0) { ComponentType = Check.NotNull(componentType, nameof(componentType)); diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/SimplePageToolbarContributor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/SimplePageToolbarContributor.cs index d31b12e73c..647538c121 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/SimplePageToolbarContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/SimplePageToolbarContributor.cs @@ -10,17 +10,17 @@ public class SimplePageToolbarContributor : IPageToolbarContributor { public Type ComponentType { get; } - public Dictionary Arguments { get; set; } + public Dictionary? Arguments { get; set; } public int Order { get; } - public string RequiredPolicyName { get; } + public string? RequiredPolicyName { get; } public SimplePageToolbarContributor( Type componentType, - Dictionary arguments = null, + Dictionary? arguments = null, int order = 0, - string requiredPolicyName = null) + string? requiredPolicyName = null) { ComponentType = componentType; Arguments = arguments; diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Routing/AbpRouterOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Routing/AbpRouterOptions.cs index ce3b2746e4..9c21e9485d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Routing/AbpRouterOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Routing/AbpRouterOptions.cs @@ -4,7 +4,7 @@ namespace Volo.Abp.AspNetCore.Components.Web.Theming.Routing; public class AbpRouterOptions { - public Assembly AppAssembly { get; set; } + public Assembly AppAssembly { get; set; } = default!; public RouterAssemblyList AdditionalAssemblies { get; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/AbpThemingOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/AbpThemingOptions.cs index 6bba37e0f8..71b0d8bb35 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/AbpThemingOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/AbpThemingOptions.cs @@ -4,7 +4,7 @@ public class AbpThemingOptions { public ThemeDictionary Themes { get; } - public string DefaultThemeName { get; set; } + public string? DefaultThemeName { get; set; } public AbpThemingOptions() { diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/DefaultThemeManager.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/DefaultThemeManager.cs index c85a25bf19..5abd114f83 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/DefaultThemeManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Theming/DefaultThemeManager.cs @@ -9,7 +9,7 @@ public class DefaultThemeManager : IThemeManager, IScopedDependency, IServicePro public IServiceProvider ServiceProvider { get; } public ITheme CurrentTheme => GetCurrentTheme(); - private ITheme _currentTheme; + private ITheme? _currentTheme; protected IThemeSelector ThemeSelector { get; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarConfigurationContext.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarConfigurationContext.cs index e2bfaf06d0..23c565eb5f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarConfigurationContext.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarConfigurationContext.cs @@ -17,8 +17,7 @@ public interface IToolbarConfigurationContext : IServiceProviderAccessor Task IsGrantedAsync(string policyName); - [CanBeNull] - IStringLocalizer GetDefaultLocalizer(); + IStringLocalizer? GetDefaultLocalizer(); [NotNull] public IStringLocalizer GetLocalizer(); diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarConfigurationContext.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarConfigurationContext.cs index f773ba14e1..7870743851 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarConfigurationContext.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarConfigurationContext.cs @@ -32,8 +32,7 @@ public class ToolbarConfigurationContext : IToolbarConfigurationContext return AuthorizationService.IsGrantedAsync(policyName); } - [CanBeNull] - public IStringLocalizer GetDefaultLocalizer() + public IStringLocalizer? GetDefaultLocalizer() { return StringLocalizerFactory.CreateDefaultOrNull(); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarItem.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarItem.cs index 966145a4ee..32816d7a3b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarItem.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarItem.cs @@ -9,7 +9,7 @@ public class ToolbarItem get => _componentType; set => _componentType = Check.NotNull(value, nameof(value)); } - private Type _componentType; + private Type _componentType = default!; public int Order { get; set; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Volo.Abp.AspNetCore.Components.Web.Theming.csproj b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Volo.Abp.AspNetCore.Components.Web.Theming.csproj index d0abc31cdc..1dd5b61131 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Volo.Abp.AspNetCore.Components.Web.Theming.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Volo.Abp.AspNetCore.Components.Web.Theming.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable diff --git a/framework/src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/LayoutHookViewModel.cs b/framework/src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/LayoutHookViewModel.cs index 107ad6990a..fe3974296f 100644 --- a/framework/src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/LayoutHookViewModel.cs +++ b/framework/src/Volo.Abp.UI/Volo/Abp/Ui/LayoutHooks/LayoutHookViewModel.cs @@ -4,9 +4,9 @@ public class LayoutHookViewModel { public LayoutHookInfo[] Hooks { get; } - public string Layout { get; } + public string? Layout { get; } - public LayoutHookViewModel(LayoutHookInfo[] hooks, string layout) + public LayoutHookViewModel(LayoutHookInfo[] hooks, string? layout) { Hooks = hooks; Layout = layout; From 966592bf21524af147edffdfd15f2ccc1c6372b6 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 7 Jul 2023 16:39:49 +0800 Subject: [PATCH 09/11] Enable nullable annotations for Volo.Abp.AspNetCore.Components.WebAssembly --- .../Components/MauiBlazor/MauiBlazorServerUrlProvider.cs | 2 +- .../Extensibility/BlazorServerLookupApiRequestService.cs | 2 +- .../Volo.Abp.AspNetCore.Components.WebAssembly.csproj | 2 ++ .../WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs | 2 +- .../Components/WebAssembly/WebAssemblyServerUrlProvider.cs | 2 +- .../Volo/Abp/Http/Client/RemoteServiceConfiguration.cs | 4 ++-- 6 files changed, 8 insertions(+), 6 deletions(-) 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 a76d631677..a93472d3b8 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 @@ -23,6 +23,6 @@ public class MauiBlazorServerUrlProvider : IServerUrlProvider, ITransientDepende remoteServiceName ?? RemoteServiceConfigurationDictionary.DefaultName ); - return remoteServiceConfiguration.BaseUrl!.EnsureEndsWith('/'); + return remoteServiceConfiguration.BaseUrl.EnsureEndsWith('/'); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs index 130d2f9225..00a5086031 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs @@ -52,7 +52,7 @@ public class BlazorServerLookupApiRequestService : ILookupApiRequestService, ITr { //Blazor tiered -- mode var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("Default"); - baseUrl = remoteServiceConfig.BaseUrl!; + baseUrl = remoteServiceConfig.BaseUrl; client.BaseAddress = new Uri(baseUrl); AddHeaders(requestMessage); await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client, diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo.Abp.AspNetCore.Components.WebAssembly.csproj b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo.Abp.AspNetCore.Components.WebAssembly.csproj index 4618f31b6c..408844627e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo.Abp.AspNetCore.Components.WebAssembly.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo.Abp.AspNetCore.Components.WebAssembly.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable Volo.Abp.AspNetCore.Components.WebAssembly Volo.Abp.AspNetCore.Components.WebAssembly $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs index 2657e5bca7..b16286c19f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs @@ -67,7 +67,7 @@ public class AbpAspNetCoreComponentsWebAssemblyModule : 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.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyServerUrlProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyServerUrlProvider.cs index 2fb133a10d..b74f5a1900 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyServerUrlProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyServerUrlProvider.cs @@ -17,7 +17,7 @@ public class WebAssemblyServerUrlProvider : IServerUrlProvider, ITransientDepend RemoteServiceConfigurationProvider = remoteServiceConfigurationProvider; } - public async Task GetBaseUrlAsync(string remoteServiceName = null) + public async Task GetBaseUrlAsync(string? remoteServiceName = null) { var remoteServiceConfiguration = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync( remoteServiceName ?? RemoteServiceConfigurationDictionary.DefaultName diff --git a/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs b/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs index 89d0b79f48..531b016a1d 100644 --- a/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs +++ b/framework/src/Volo.Abp.RemoteServices/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs @@ -7,8 +7,8 @@ public class RemoteServiceConfiguration : Dictionary /// /// Base Url. /// - public string? BaseUrl { - get => this.GetOrDefault(nameof(BaseUrl)); + public string BaseUrl { + get => this.GetOrDefault(nameof(BaseUrl))!; set => this[nameof(BaseUrl)] = value; } From 630cc0bf3b33ec0a4163e35acbbe884f986cf6ec Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 7 Jul 2023 16:46:11 +0800 Subject: [PATCH 10/11] Enable nullable annotations for Volo.Abp.AspNetCore.Components.WebAssembly.Theming --- .../Volo.Abp.AspNetCore.Components.WebAssembly.Theming.csproj | 2 ++ .../DependencyInjection/EmptyWebAssemblyHostEnvironment.cs | 4 ++-- .../Components/WebAssembly/ApplicationConfigurationCache.cs | 4 ++-- .../WebAssembly/WebAssemblyCurrentTenantAccessor.cs | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.csproj b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.csproj index e310f4a2e2..06a5276ec0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/Volo.Abp.AspNetCore.Components.WebAssembly.Theming.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/Extensions/DependencyInjection/EmptyWebAssemblyHostEnvironment.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/Extensions/DependencyInjection/EmptyWebAssemblyHostEnvironment.cs index 6393948af7..f06bb37911 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/Extensions/DependencyInjection/EmptyWebAssemblyHostEnvironment.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/Extensions/DependencyInjection/EmptyWebAssemblyHostEnvironment.cs @@ -4,7 +4,7 @@ namespace Microsoft.Extensions.DependencyInjection; public class EmptyWebAssemblyHostEnvironment : IWebAssemblyHostEnvironment { - public string Environment { get; set; } + public string Environment { get; set; } = default!; - public string BaseAddress { get; set; } + public string BaseAddress { get; set; } = default!; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ApplicationConfigurationCache.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ApplicationConfigurationCache.cs index b55d8d8a56..3d2c64ff4e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ApplicationConfigurationCache.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ApplicationConfigurationCache.cs @@ -5,9 +5,9 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly; public class ApplicationConfigurationCache : ISingletonDependency { - protected ApplicationConfigurationDto Configuration { get; set; } + protected ApplicationConfigurationDto? Configuration { get; set; } - public virtual ApplicationConfigurationDto Get() + public virtual ApplicationConfigurationDto? Get() { return Configuration; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCurrentTenantAccessor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCurrentTenantAccessor.cs index e24746f85a..92ba34c4be 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCurrentTenantAccessor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCurrentTenantAccessor.cs @@ -6,5 +6,5 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly; [Dependency(ReplaceServices = true)] public class WebAssemblyCurrentTenantAccessor : ICurrentTenantAccessor, ISingletonDependency { - public BasicTenantInfo Current { get; set; } + public BasicTenantInfo? Current { get; set; } } From 322e9034ac573e09674d31017b267851d80db2ca Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 7 Jul 2023 16:50:21 +0800 Subject: [PATCH 11/11] Update ApplicationConfigurationCache.cs --- .../Components/MauiBlazor/ApplicationConfigurationCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f4857165f7..b5ca46e7d8 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 @@ -9,7 +9,7 @@ public class ApplicationConfigurationCache : ISingletonDependency { protected ApplicationConfigurationDto? Configuration { get; set; } - public event Action ApplicationConfigurationChanged = default!; + public event Action? ApplicationConfigurationChanged; public virtual ApplicationConfigurationDto? Get() {