From 4538e0eee479fc4c663dbad5170cb2c234f87b21 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Mon, 10 Jul 2023 17:24:18 +0800 Subject: [PATCH] Enable nullable annotations for Volo.Abp.AspNetCore.Mvc --- ...pNetCoreMvcApplicationBuilderExtensions.cs | 2 +- .../ActionDescriptorExtensions.cs | 4 +-- .../Volo.Abp.AspNetCore.Mvc.csproj | 2 ++ .../Mvc/AbpActionContextExtensions.cs | 2 +- .../Volo/Abp/AspNetCore/Mvc/AbpController.cs | 20 +++++++------- .../Abp/AspNetCore/Mvc/AbpControllerBase.cs | 14 +++++----- ...AutoLocalizationMetadataDetailsProvider.cs | 12 ++++----- .../Abp/AspNetCore/Mvc/AbpViewComponent.cs | 6 ++--- .../AbpAntiForgeryCookieNameProvider.cs | 4 +-- .../Mvc/AntiForgery/AbpAntiForgeryOptions.cs | 6 ++--- .../AspNetCoreAbpAntiForgeryManager.cs | 6 ++--- .../AbpRemoteServiceApiDescriptionProvider.cs | 4 +-- .../AbpApplicationConfigurationAppService.cs | 2 +- .../AbpApplicationLocalizationAppService.cs | 4 +-- .../CachedObjectExtensionsDtoService.cs | 4 +-- .../ExtensionPropertyAttributeDtoFactory.cs | 2 +- .../AspNetCore/Mvc/ApplicationPartSorter.cs | 6 ++--- .../AspNetCoreApiDescriptionModelProvider.cs | 19 +++++++------ ...tCoreApiDescriptionModelProviderOptions.cs | 8 +++--- .../Mvc/Auditing/AbpAuditActionFilter.cs | 8 +++--- .../Mvc/Auditing/AbpAuditPageFilter.cs | 10 +++---- .../ChallengeAccountController.cs | 6 ++--- .../AbpRemoteStreamContentModelBinder.cs | 2 +- ...pRemoteStreamContentModelBinderProvider.cs | 2 +- .../RemoteStreamContentOutputFormatter.cs | 4 +-- .../AbpConventionalControllerOptions.cs | 2 +- .../Mvc/Conventions/AbpServiceConvention.cs | 27 +++++++++---------- .../ConventionalControllerSetting.cs | 20 ++++++-------- .../ConventionalControllerSettingList.cs | 3 +-- .../Conventions/ConventionalRouteBuilder.cs | 16 +++++------ .../Conventions/IConventionalRouteBuilder.cs | 2 +- .../AbpValidationAttributeAdapterProvider.cs | 2 +- .../DynamicMaxLengthAttributeAdapter.cs | 2 +- .../DynamicRangeAttributeAdapter.cs | 6 ++--- .../DynamicStringLengthAttributeAdapter.cs | 2 +- .../ExceptionHandling/AbpExceptionFilter.cs | 4 +-- .../AbpExceptionPageFilter.cs | 14 +++++----- .../GlobalFeatureActionFilter.cs | 2 +- .../GlobalFeatures/GlobalFeaturePageFilter.cs | 2 +- ...AbpMvcAttributeValidationResultProvider.cs | 2 +- .../AbpDateTimeModelBinderProvider.cs | 4 +-- ...PropertiesDictionaryModelBinderProvider.cs | 4 +-- .../AbpExtraPropertyModelBinder.cs | 2 +- .../ExtraPropertyBindingHelper.cs | 4 +-- .../ServiceProxyGenerationModel.cs | 14 +++++----- .../AspNetCore/Mvc/Uow/AbpUowActionFilter.cs | 2 +- .../AspNetCore/Mvc/Uow/AbpUowPageFilter.cs | 2 +- .../Abp/AspNetCore/Mvc/Utils/ArrayMatcher.cs | 2 +- .../Validation/ValidationAttributeHelper.cs | 4 +-- .../HttpContextRequestedApiVersion.cs | 2 +- ...sionPropertyInfoAspNetCoreMvcExtensions.cs | 2 +- 51 files changed, 151 insertions(+), 156 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Builder/AbpAspNetCoreMvcApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Builder/AbpAspNetCoreMvcApplicationBuilderExtensions.cs index 3b9acc9f85..3409d0b19c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Builder/AbpAspNetCoreMvcApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Builder/AbpAspNetCoreMvcApplicationBuilderExtensions.cs @@ -18,7 +18,7 @@ public static class AbpAspNetCoreMvcApplicationBuilderExtensions [Obsolete("Use app.UseConfiguredEndpoints(...) extension method instead!")] public static IApplicationBuilder UseMvcWithDefaultRouteAndArea( this IApplicationBuilder app, - Action additionalConfigurationAction = null) + Action? additionalConfigurationAction = null) { return app.UseConfiguredEndpoints(additionalConfigurationAction); } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Mvc/Abstractions/ActionDescriptorExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Mvc/Abstractions/ActionDescriptorExtensions.cs index 24c9b071bd..2d33f65b6d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Mvc/Abstractions/ActionDescriptorExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Mvc/Abstractions/ActionDescriptorExtensions.cs @@ -16,7 +16,7 @@ public static class ActionDescriptorExtensions throw new AbpException($"{nameof(actionDescriptor)} should be type of {typeof(ControllerActionDescriptor).AssemblyQualifiedName}"); } - return actionDescriptor as ControllerActionDescriptor; + return (actionDescriptor as ControllerActionDescriptor)!; } public static MethodInfo GetMethodInfo(this ActionDescriptor actionDescriptor) @@ -51,6 +51,6 @@ public static class ActionDescriptorExtensions throw new AbpException($"{nameof(actionDescriptor)} should be type of {typeof(PageActionDescriptor).AssemblyQualifiedName}"); } - return actionDescriptor as PageActionDescriptor; + return (actionDescriptor as PageActionDescriptor)!; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj index 37b9822966..69cc963ca2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj @@ -5,6 +5,8 @@ net7.0 + enable + Nullable true Volo.Abp.AspNetCore.Mvc Volo.Abp.AspNetCore.Mvc diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpActionContextExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpActionContextExtensions.cs index 8c18edaf3e..ea63591826 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpActionContextExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpActionContextExtensions.cs @@ -11,7 +11,7 @@ public static class AbpActionContextExtensions return context.HttpContext.RequestServices.GetRequiredService(); } - public static T GetService(this FilterContext context, T defaultValue = default) + public static T? GetService(this FilterContext context, T? defaultValue = default) where T : class { return context.HttpContext.RequestServices.GetService() ?? defaultValue; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs index 51c0849c66..0a3f042784 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs @@ -23,14 +23,14 @@ namespace Volo.Abp.AspNetCore.Mvc; public abstract class AbpController : Controller, IAvoidDuplicateCrossCuttingConcerns { - public IAbpLazyServiceProvider LazyServiceProvider { get; set; } + public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!; [Obsolete("Use LazyServiceProvider instead.")] - public IServiceProvider ServiceProvider { get; set; } + public IServiceProvider ServiceProvider { get; set; } = default!; protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService(); - protected Type ObjectMapperContext { get; set; } + protected Type? ObjectMapperContext { get; set; } protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService(provider => ObjectMapperContext == null ? provider.GetRequiredService() @@ -40,7 +40,7 @@ public abstract class AbpController : Controller, IAvoidDuplicateCrossCuttingCon protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService(); - protected ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance); + protected ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName!) ?? NullLogger.Instance); protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetRequiredService(); @@ -48,7 +48,7 @@ public abstract class AbpController : Controller, IAvoidDuplicateCrossCuttingCon protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetRequiredService(); - protected IUnitOfWork CurrentUnitOfWork => UnitOfWorkManager?.Current; + protected IUnitOfWork? CurrentUnitOfWork => UnitOfWorkManager?.Current; protected IClock Clock => LazyServiceProvider.LazyGetRequiredService(); @@ -70,16 +70,16 @@ public abstract class AbpController : Controller, IAvoidDuplicateCrossCuttingCon 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); public List AppliedCrossCuttingConcerns { get; } = new List(); @@ -104,12 +104,12 @@ public abstract class AbpController : Controller, IAvoidDuplicateCrossCuttingCon return localizer; } - protected virtual RedirectResult RedirectSafely(string returnUrl, string returnUrlHash = null) + protected virtual RedirectResult RedirectSafely(string returnUrl, string? returnUrlHash = null) { return Redirect(GetRedirectUrl(returnUrl, returnUrlHash)); } - protected virtual string GetRedirectUrl(string returnUrl, string returnUrlHash = null) + protected virtual string GetRedirectUrl(string returnUrl, string? returnUrlHash = null) { returnUrl = NormalizeReturnUrl(returnUrl); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerBase.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerBase.cs index d890c3a9f6..e37ef18f0c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerBase.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerBase.cs @@ -22,11 +22,11 @@ namespace Volo.Abp.AspNetCore.Mvc; public abstract class AbpControllerBase : ControllerBase, IAvoidDuplicateCrossCuttingConcerns { - public IAbpLazyServiceProvider LazyServiceProvider { get; set; } + public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!; protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService(); - protected Type ObjectMapperContext { get; set; } + protected Type? ObjectMapperContext { get; set; } protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService(provider => ObjectMapperContext == null ? provider.GetRequiredService() @@ -36,7 +36,7 @@ public abstract class AbpControllerBase : ControllerBase, IAvoidDuplicateCrossCu protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService(); - protected ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance); + protected ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName!) ?? NullLogger.Instance); protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetRequiredService(); @@ -44,7 +44,7 @@ public abstract class AbpControllerBase : ControllerBase, IAvoidDuplicateCrossCu protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetRequiredService(); - protected IUnitOfWork CurrentUnitOfWork => UnitOfWorkManager?.Current; + protected IUnitOfWork? CurrentUnitOfWork => UnitOfWorkManager?.Current; protected IClock Clock => LazyServiceProvider.LazyGetRequiredService(); @@ -64,16 +64,16 @@ public abstract class AbpControllerBase : ControllerBase, IAvoidDuplicateCrossCu 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); public List AppliedCrossCuttingConcerns { get; } = new List(); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpDataAnnotationAutoLocalizationMetadataDetailsProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpDataAnnotationAutoLocalizationMetadataDetailsProvider.cs index cb0d9547a2..badeeb8edd 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpDataAnnotationAutoLocalizationMetadataDetailsProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpDataAnnotationAutoLocalizationMetadataDetailsProvider.cs @@ -17,13 +17,13 @@ public class AbpDataAnnotationAutoLocalizationMetadataDetailsProvider : IDisplay private readonly Lazy _stringLocalizerFactory; private readonly Lazy> _localizationOptions; - private readonly ConcurrentDictionary _displayNameKeys; + private readonly ConcurrentDictionary _displayNameKeys; public AbpDataAnnotationAutoLocalizationMetadataDetailsProvider(IServiceCollection services) { _stringLocalizerFactory = services.GetRequiredServiceLazy(); _localizationOptions = services.GetRequiredServiceLazy>(); - _displayNameKeys = new ConcurrentDictionary(); + _displayNameKeys = new ConcurrentDictionary(); } public virtual void CreateDisplayMetadata(DisplayMetadataProviderContext context) @@ -58,11 +58,11 @@ public class AbpDataAnnotationAutoLocalizationMetadataDetailsProvider : IDisplay displayMetadata.DisplayName = () => { var key = _displayNameKeys.GetOrAdd(context, _ => GetDisplayNameKey(context, localizer)); - return key != null ? localizer[key] : null; + return (key != null ? localizer[key] : null)!; }; } - protected virtual string GetDisplayNameKey(DisplayMetadataProviderContext context, IStringLocalizer localizer) + protected virtual string? GetDisplayNameKey(DisplayMetadataProviderContext context, IStringLocalizer localizer) { /* * DisplayName:ClassName:PropertyName @@ -71,7 +71,7 @@ public class AbpDataAnnotationAutoLocalizationMetadataDetailsProvider : IDisplay * PropertyName */ - LocalizedString localizedString = null; + LocalizedString? localizedString = null; if (context.Key.ContainerType != null) { @@ -102,7 +102,7 @@ public class AbpDataAnnotationAutoLocalizationMetadataDetailsProvider : IDisplay if (localizedString.ResourceNotFound) { - localizedString = localizer[context.Key.Name]; + localizedString = localizer[context.Key.Name!]; if (!localizedString.ResourceNotFound) { return localizedString.Name; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs index b8de0159f1..b628a39448 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs @@ -8,12 +8,12 @@ namespace Volo.Abp.AspNetCore.Mvc; public abstract class AbpViewComponent : ViewComponent { - public IAbpLazyServiceProvider LazyServiceProvider { get; set; } + public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!; [Obsolete("Use LazyServiceProvider instead.")] - public IServiceProvider ServiceProvider { get; set; } + public IServiceProvider ServiceProvider { get; set; } = default!; - protected Type ObjectMapperContext { get; set; } + protected Type? ObjectMapperContext { get; set; } protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService(provider => ObjectMapperContext == null diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AbpAntiForgeryCookieNameProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AbpAntiForgeryCookieNameProvider.cs index b56ed8ac24..9fa1fc1554 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AbpAntiForgeryCookieNameProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AbpAntiForgeryCookieNameProvider.cs @@ -17,7 +17,7 @@ public class AbpAntiForgeryCookieNameProvider : ITransientDependency _abpAntiForgeryOptions = abpAntiForgeryOptions.Value; } - public virtual string GetAuthCookieNameOrNull() + public virtual string? GetAuthCookieNameOrNull() { if (_abpAntiForgeryOptions.AuthCookieSchemaName == null) { @@ -27,7 +27,7 @@ public class AbpAntiForgeryCookieNameProvider : ITransientDependency return _namedOptionsAccessor.Get(_abpAntiForgeryOptions.AuthCookieSchemaName)?.Cookie?.Name; } - public virtual string GetAntiForgeryCookieNameOrNull() + public virtual string? GetAntiForgeryCookieNameOrNull() { return _abpAntiForgeryOptions.TokenCookie.Name; } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AbpAntiForgeryOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AbpAntiForgeryOptions.cs index ba577027a9..0c2cf8884c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AbpAntiForgeryOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AbpAntiForgeryOptions.cs @@ -17,7 +17,7 @@ public class AbpAntiForgeryOptions /// Used to find auth cookie when validating Anti Forgery token. /// Default value: "Identity.Application". /// - public string AuthCookieSchemaName { get; set; } + public string? AuthCookieSchemaName { get; set; } /// /// Default value: true. @@ -34,7 +34,7 @@ public class AbpAntiForgeryOptions get => _autoValidateFilter; set => _autoValidateFilter = Check.NotNull(value, nameof(value)); } - private Predicate _autoValidateFilter; + private Predicate _autoValidateFilter = default!; /// /// Default methods: "GET", "HEAD", "TRACE", "OPTIONS". @@ -44,7 +44,7 @@ public class AbpAntiForgeryOptions get => _autoValidateIgnoredHttpMethods; set => _autoValidateIgnoredHttpMethods = Check.NotNull(value, nameof(value)); } - private HashSet _autoValidateIgnoredHttpMethods; + private HashSet _autoValidateIgnoredHttpMethods = default!; public AbpAntiForgeryOptions() { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AspNetCoreAbpAntiForgeryManager.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AspNetCoreAbpAntiForgeryManager.cs index 27aa9a0a58..b13fe68508 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AspNetCoreAbpAntiForgeryManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AspNetCoreAbpAntiForgeryManager.cs @@ -9,7 +9,7 @@ public class AspNetCoreAbpAntiForgeryManager : IAbpAntiForgeryManager, ITransien { protected AbpAntiForgeryOptions Options { get; } - protected HttpContext HttpContext => _httpContextAccessor.HttpContext; + protected HttpContext HttpContext => _httpContextAccessor.HttpContext!; private readonly IAntiforgery _antiforgery; private readonly IHttpContextAccessor _httpContextAccessor; @@ -27,7 +27,7 @@ public class AspNetCoreAbpAntiForgeryManager : IAbpAntiForgeryManager, ITransien public virtual void SetCookie() { HttpContext.Response.Cookies.Append( - Options.TokenCookie.Name, + Options.TokenCookie.Name!, GenerateToken(), Options.TokenCookie.Build(HttpContext) ); @@ -35,6 +35,6 @@ public class AspNetCoreAbpAntiForgeryManager : IAbpAntiForgeryManager, ITransien public virtual string GenerateToken() { - return _antiforgery.GetAndStoreTokens(_httpContextAccessor.HttpContext).RequestToken; + return _antiforgery.GetAndStoreTokens(_httpContextAccessor.HttpContext!).RequestToken!; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiExploring/AbpRemoteServiceApiDescriptionProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiExploring/AbpRemoteServiceApiDescriptionProvider.cs index 23cc2e155d..b8d98d7de4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiExploring/AbpRemoteServiceApiDescriptionProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiExploring/AbpRemoteServiceApiDescriptionProvider.cs @@ -62,11 +62,11 @@ public class AbpRemoteServiceApiDescriptionProvider : IApiDescriptionProvider, I { foreach (var apiResponse in _options.SupportedResponseTypes) { - apiResponse.ModelMetadata = _modelMetadataProvider.GetMetadataForType(apiResponse.Type); + apiResponse.ModelMetadata = _modelMetadataProvider.GetMetadataForType(apiResponse.Type!); foreach (var responseTypeMetadataProvider in _mvcOptions.OutputFormatters.OfType()) { - var formatterSupportedContentTypes = responseTypeMetadataProvider.GetSupportedContentTypes(null, apiResponse.Type); + var formatterSupportedContentTypes = responseTypeMetadataProvider.GetSupportedContentTypes(null!, apiResponse.Type!); if (formatterSupportedContentTypes == null) { continue; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs index 4254b5479f..4a6560b08a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs @@ -346,7 +346,7 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp { TimeZoneName = windowsTimeZoneId.IsNullOrWhiteSpace() ? null - : _timezoneProvider.WindowsToIana(windowsTimeZoneId) + : _timezoneProvider.WindowsToIana(windowsTimeZoneId!) } } }; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationLocalizationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationLocalizationAppService.cs index 58eefeba5e..4cf03c0b4a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationLocalizationAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationLocalizationAppService.cs @@ -50,7 +50,7 @@ public class AbpApplicationLocalizationAppService : var localizer = await StringLocalizerFactory.CreateByResourceNameOrNullAsync(resource.ResourceName); if (localizer != null) { - Dictionary staticLocalizedStrings = null; + Dictionary? staticLocalizedStrings = null; if (input.OnlyDynamics) { @@ -71,7 +71,7 @@ public class AbpApplicationLocalizationAppService : { if (input.OnlyDynamics) { - var staticLocalizedString = staticLocalizedStrings.GetOrDefault(localizedString.Name); + var staticLocalizedString = staticLocalizedStrings!.GetOrDefault(localizedString.Name); if (staticLocalizedString != null && localizedString.Value == staticLocalizedString.Value) { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs index 0f9b05830d..6b99451b77 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs @@ -12,7 +12,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; public class CachedObjectExtensionsDtoService : ICachedObjectExtensionsDtoService, ISingletonDependency { protected IExtensionPropertyAttributeDtoFactory ExtensionPropertyAttributeDtoFactory { get; } - protected volatile ObjectExtensionsDto CachedValue; + protected volatile ObjectExtensionsDto? CachedValue; protected readonly object SyncLock = new object(); public CachedObjectExtensionsDtoService(IExtensionPropertyAttributeDtoFactory extensionPropertyAttributeDtoFactory) @@ -193,7 +193,7 @@ public class CachedObjectExtensionsDtoService : ICachedObjectExtensionsDtoServic return TypeHelper.GetSimplifiedName(propertyConfig.Type); } - protected virtual LocalizableStringDto CreateDisplayNameDto(ExtensionPropertyConfiguration propertyConfig) + protected virtual LocalizableStringDto? CreateDisplayNameDto(ExtensionPropertyConfiguration propertyConfig) { if (propertyConfig.DisplayName == null) { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDtoFactory.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDtoFactory.cs index 2fb94d9930..742cab75ea 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDtoFactory.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDtoFactory.cs @@ -71,7 +71,7 @@ public class ExtensionPropertyAttributeDtoFactory : IExtensionPropertyAttributeD return false; } - protected virtual object GetPropertyValue(Attribute attribute, PropertyInfo property) + protected virtual object? GetPropertyValue(Attribute attribute, PropertyInfo property) { var value = property.GetValue(attribute); if (value == null) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationPartSorter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationPartSorter.cs index dc39ef5f53..9bc15ae617 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationPartSorter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationPartSorter.cs @@ -135,7 +135,7 @@ public static class ApplicationPartSorter .ToArray(); } - private static CompiledRazorAssemblyPart GetViewsPartOrNull(ApplicationPartManager partManager, + private static CompiledRazorAssemblyPart? GetViewsPartOrNull(ApplicationPartManager partManager, ApplicationPart assemblyPart) { var viewsAssemblyName = assemblyPart.Name + ".Views"; @@ -145,7 +145,7 @@ public static class ApplicationPartSorter .FirstOrDefault(p => p.Name == viewsAssemblyName); } - private static AssemblyPart GetOriginalAssemblyPartOrNull( + private static AssemblyPart? GetOriginalAssemblyPartOrNull( CompiledRazorAssemblyPart compiledRazorAssemblyPart, ApplicationPartManager partManager) { @@ -155,7 +155,7 @@ public static class ApplicationPartSorter .FirstOrDefault(p => p.Name == originalAssemblyName); } - private static IAbpModuleDescriptor GetModuleDescriptorForAssemblyOrNull( + private static IAbpModuleDescriptor? GetModuleDescriptorForAssemblyOrNull( IModuleContainer moduleContainer, Assembly assembly) { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs index f18e9d6c3c..9e3b0bfba2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs @@ -162,7 +162,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide } private static List GetSupportedVersions(Type controllerType, MethodInfo method, - ConventionalControllerSetting setting) + ConventionalControllerSetting? setting) { var supportedVersions = new List(); @@ -196,7 +196,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide } private static void AddCustomTypesToModel(ApplicationApiDescriptionModel applicationModel, - [CanBeNull] Type type) + Type? type) { if (type == null) { @@ -275,7 +275,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide .Select(_ => "T" + i++) .JoinAsString(","); - return $"{type.FullName.Left(type.FullName.IndexOf('`'))}<{argumentList}>"; + return $"{type.FullName!.Left(type.FullName!.IndexOf('`'))}<{argumentList}>"; } private void AddParameterDescriptionsToModel(ActionApiDescriptionModel actionModel, MethodInfo method, @@ -339,16 +339,16 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide if (modelNameProvider == null) { - return parameterInfo.Name; + return parameterInfo.Name!; } - return modelNameProvider.Name ?? parameterInfo.Name; + return (modelNameProvider.Name ?? parameterInfo.Name)!; } private static string GetRootPath( [NotNull] Type controllerType, [NotNull] ActionDescriptor actionDescriptor, - [CanBeNull] ConventionalControllerSetting setting) + ConventionalControllerSetting? setting) { if (setting != null) { @@ -364,7 +364,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide return ModuleApiDescriptionModel.DefaultRootPath; } - private string GetRemoteServiceName(Type controllerType, [CanBeNull] ConventionalControllerSetting setting) + private string GetRemoteServiceName(Type controllerType, ConventionalControllerSetting? setting) { if (setting != null) { @@ -381,7 +381,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide return ModuleApiDescriptionModel.DefaultRemoteServiceName; } - private string FindGroupName(Type controllerType) + private string? FindGroupName(Type controllerType) { var controllerNameAttribute = controllerType.GetCustomAttributes().OfType().FirstOrDefault(); @@ -394,8 +394,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide return null; } - [CanBeNull] - private ConventionalControllerSetting FindSetting(Type controllerType) + private ConventionalControllerSetting? FindSetting(Type controllerType) { foreach (var controllerSetting in _abpAspNetCoreMvcOptions.ConventionalControllers.ConventionalControllerSettings) { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs index 4dc4a9719a..8446336053 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs @@ -12,11 +12,11 @@ namespace Volo.Abp.AspNetCore.Mvc; public class AspNetCoreApiDescriptionModelProviderOptions { - public Func ControllerNameGenerator { get; set; } + public Func ControllerNameGenerator { get; set; } public Func ActionNameGenerator { get; set; } - public Func ApiParameterNameGenerator { get; set; } + public Func ApiParameterNameGenerator { get; set; } public AspNetCoreApiDescriptionModelProviderOptions() { @@ -51,7 +51,7 @@ public class AspNetCoreApiDescriptionModelProviderOptions methodNameBuilder.Append("And"); } - methodNameBuilder.Append(parameters[i].Name.ToPascalCase()); + methodNameBuilder.Append(parameters[i].Name!.ToPascalCase()); } } @@ -62,7 +62,7 @@ public class AspNetCoreApiDescriptionModelProviderOptions { if (apiParameterDescription.ModelMetadata is DefaultModelMetadata defaultModelMetadata) { - var jsonPropertyNameAttribute = (JsonPropertyNameAttribute) + var jsonPropertyNameAttribute = (JsonPropertyNameAttribute?) defaultModelMetadata?.Attributes?.PropertyAttributes?.FirstOrDefault(x => x is JsonPropertyNameAttribute); if (jsonPropertyNameAttribute != null) { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditActionFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditActionFilter.cs index 82105693ec..07101da0cb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditActionFilter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditActionFilter.cs @@ -30,12 +30,12 @@ public class AbpAuditActionFilter : IAsyncActionFilter, ITransientDependency if (result.Exception != null && !result.ExceptionHandled) { - auditLog.Exceptions.Add(result.Exception); + auditLog!.Exceptions.Add(result.Exception); } } catch (Exception ex) { - auditLog.Exceptions.Add(ex); + auditLog!.Exceptions.Add(ex); throw; } finally @@ -45,13 +45,13 @@ public class AbpAuditActionFilter : IAsyncActionFilter, ITransientDependency if (auditLogAction != null) { auditLogAction.ExecutionDuration = Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds); - auditLog.Actions.Add(auditLogAction); + auditLog!.Actions.Add(auditLogAction); } } } } - private bool ShouldSaveAudit(ActionExecutingContext context, out AuditLogInfo auditLog, out AuditLogActionInfo auditLogAction) + private bool ShouldSaveAudit(ActionExecutingContext context, out AuditLogInfo? auditLog, out AuditLogActionInfo? auditLogAction) { auditLog = null; auditLogAction = null; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditPageFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditPageFilter.cs index 51137d3812..8445be60ae 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditPageFilter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditPageFilter.cs @@ -35,12 +35,12 @@ public class AbpAuditPageFilter : IAsyncPageFilter, ITransientDependency if (result.Exception != null && !result.ExceptionHandled) { - auditLog.Exceptions.Add(result.Exception); + auditLog!.Exceptions.Add(result.Exception); } } catch (Exception ex) { - auditLog.Exceptions.Add(ex); + auditLog!.Exceptions.Add(ex); throw; } finally @@ -50,13 +50,13 @@ public class AbpAuditPageFilter : IAsyncPageFilter, ITransientDependency if (auditLogAction != null) { auditLogAction.ExecutionDuration = Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds); - auditLog.Actions.Add(auditLogAction); + auditLog!.Actions.Add(auditLogAction); } } } } - private bool ShouldSaveAudit(PageHandlerExecutingContext context, out AuditLogInfo auditLog, out AuditLogActionInfo auditLogAction) + private bool ShouldSaveAudit(PageHandlerExecutingContext context, out AuditLogInfo? auditLog, out AuditLogActionInfo? auditLogAction) { auditLog = null; auditLogAction = null; @@ -79,7 +79,7 @@ public class AbpAuditPageFilter : IAsyncPageFilter, ITransientDependency } var auditingHelper = context.GetRequiredService(); - if (!auditingHelper.ShouldSaveAudit(context.HandlerMethod.MethodInfo, defaultValue: true)) + if (!auditingHelper.ShouldSaveAudit(context.HandlerMethod!.MethodInfo, defaultValue: true)) { return false; } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs index 15abd26b1e..802dad66f2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs @@ -14,7 +14,7 @@ public abstract class ChallengeAccountController : AbpController protected string AuthenticationType { get; } protected string[] ForbidSchemes { get; } - protected ChallengeAccountController(string[] challengeAuthenticationSchemas = null) + protected ChallengeAccountController(string[]? challengeAuthenticationSchemas = null) { ChallengeAuthenticationSchemas = challengeAuthenticationSchemas ?? new[] { "oidc" }; AuthenticationType = "Identity.Application"; @@ -68,12 +68,12 @@ public abstract class ChallengeAccountController : AbpController { RedirectUri = GetRedirectUrl(returnUrl, returnUrlHash) }, - ForbidSchemes.IsNullOrEmpty() + (ForbidSchemes.IsNullOrEmpty() ? new[] { HttpContext.RequestServices.GetRequiredService>().Value.DefaultForbidScheme } - : ForbidSchemes + : ForbidSchemes)! )); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/AbpRemoteStreamContentModelBinder.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/AbpRemoteStreamContentModelBinder.cs index ea633f569a..2cc051ba62 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/AbpRemoteStreamContentModelBinder.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/AbpRemoteStreamContentModelBinder.cs @@ -155,6 +155,6 @@ public class AbpRemoteStreamContentModelBinder : IModelBin return new List(); } - return (ICollection)Activator.CreateInstance(modelType); + return (ICollection)Activator.CreateInstance(modelType)!; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/AbpRemoteStreamContentModelBinderProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/AbpRemoteStreamContentModelBinderProvider.cs index 7892e6a1c2..83a31c792e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/AbpRemoteStreamContentModelBinderProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/AbpRemoteStreamContentModelBinderProvider.cs @@ -7,7 +7,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ContentFormatters; public class AbpRemoteStreamContentModelBinderProvider : IModelBinderProvider { - public IModelBinder GetBinder(ModelBinderProviderContext context) + public IModelBinder? GetBinder(ModelBinderProviderContext context) { if (context == null) { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentOutputFormatter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentOutputFormatter.cs index e41616617d..5bba1b386a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentOutputFormatter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentOutputFormatter.cs @@ -13,14 +13,14 @@ public class RemoteStreamContentOutputFormatter : OutputFormatter SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("*/*")); } - protected override bool CanWriteType(Type type) + protected override bool CanWriteType(Type? type) { return typeof(IRemoteStreamContent).IsAssignableFrom(type); } public async override Task WriteResponseBodyAsync(OutputFormatterWriteContext context) { - var remoteStream = (IRemoteStreamContent)context.Object; + var remoteStream = (IRemoteStreamContent?)context.Object; if (remoteStream != null) { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpConventionalControllerOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpConventionalControllerOptions.cs index 1d508fb778..1b8e7fcb1b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpConventionalControllerOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpConventionalControllerOptions.cs @@ -33,7 +33,7 @@ public class AbpConventionalControllerOptions public AbpConventionalControllerOptions Create( Assembly assembly, - [CanBeNull] Action optionsAction = null) + Action? optionsAction = null) { var setting = new ConventionalControllerSetting( assembly, diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs index 19479f552d..ba85a34f65 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs @@ -105,7 +105,7 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency if (removeControllerModels.Any()) { controllerModelsToRemove.AddRange(removeControllerModels); - Logger.LogInformation($"Removing the controller{(removeControllerModels.Length > 1 ? "s" : "")} {removeControllerModels.Select(c => c.ControllerType.AssemblyQualifiedName).JoinAsString(", ")} from the application model"); + Logger.LogInformation($"Removing the controller{(removeControllerModels.Length > 1 ? "s" : "")} {removeControllerModels.Select(c => c.ControllerType.AssemblyQualifiedName)!.JoinAsString(", ")} from the application model"); } } @@ -121,7 +121,7 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency if (replaceControllerModels.Any()) { controllerModelsToRemove.AddRange(replaceControllerModels); - Logger.LogInformation($"Removing the controller{(replaceControllerModels.Length > 1 ? "s" : "")} {replaceControllersAttr.ControllerTypes.Select(c => c.AssemblyQualifiedName).JoinAsString(", ")} from the application model since {(replaceControllerModels.Length > 1 ? "they are" : "it is")} replaced by the controller: {controllerModel.ControllerType.AssemblyQualifiedName}"); + Logger.LogInformation($"Removing the controller{(replaceControllerModels.Length > 1 ? "s" : "")} {replaceControllersAttr.ControllerTypes.Select(c => c.AssemblyQualifiedName)!.JoinAsString(", ")} from the application model since {(replaceControllerModels.Length > 1 ? "they are" : "it is")} replaced by the controller: {controllerModel.ControllerType.AssemblyQualifiedName}"); } } } @@ -139,7 +139,7 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency } var exposeServicesAttr = ReflectionHelper.GetSingleAttributeOrDefault(controllerModel.ControllerType); - if (exposeServicesAttr.IncludeSelf) + if (exposeServicesAttr!.IncludeSelf) { var exposedControllerModels = GetControllers(application) .Where(cm => exposeServicesAttr.ServiceTypes.Contains(cm.ControllerType)) @@ -148,7 +148,7 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency if (exposedControllerModels.Any()) { controllerModelsToRemove.AddRange(exposedControllerModels); - Logger.LogInformation($"Removing the controller{(exposedControllerModels.Length > 1 ? "s" : "")} {exposeServicesAttr.ServiceTypes.Select(c => c.AssemblyQualifiedName).JoinAsString(", ")} from the application model since {(exposedControllerModels.Length > 1 ? "they are" : "it is")} replaced by the controller: {controllerModel.ControllerType.AssemblyQualifiedName}"); + Logger.LogInformation($"Removing the controller{(exposedControllerModels.Length > 1 ? "s" : "")} {exposeServicesAttr.ServiceTypes.Select(c => c.AssemblyQualifiedName)!.JoinAsString(", ")} from the application model since {(exposedControllerModels.Length > 1 ? "they are" : "it is")} replaced by the controller: {controllerModel.ControllerType.AssemblyQualifiedName}"); } continue; } @@ -173,13 +173,13 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency } controllerModelsToRemove.Add(controllerModel); - Logger.LogInformation($"Removing the controller {controllerModel.ControllerType.AssemblyQualifiedName} from the application model since it replaces the controller(s): {baseControllerTypes.Select(c => c.AssemblyQualifiedName).JoinAsString(", ")}"); + Logger.LogInformation($"Removing the controller {controllerModel.ControllerType.AssemblyQualifiedName} from the application model since it replaces the controller(s): {baseControllerTypes.Select(c => c.AssemblyQualifiedName)!.JoinAsString(", ")}"); } application.Controllers.RemoveAll(controllerModelsToRemove); } - protected virtual void ConfigureRemoteService(ControllerModel controller, [CanBeNull] ConventionalControllerSetting configuration) + protected virtual void ConfigureRemoteService(ControllerModel controller, ConventionalControllerSetting? configuration) { ConfigureApiExplorer(controller); ConfigureSelector(controller, configuration); @@ -288,7 +288,7 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency action.ApiExplorer.IsVisible = visible; } - protected virtual void ConfigureSelector(ControllerModel controller, [CanBeNull] ConventionalControllerSetting configuration) + protected virtual void ConfigureSelector(ControllerModel controller, ConventionalControllerSetting? configuration) { RemoveEmptySelectors(controller.Selectors); @@ -312,7 +312,7 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency } } - protected virtual void ConfigureSelector(string rootPath, string controllerName, ActionModel action, [CanBeNull] ConventionalControllerSetting configuration) + protected virtual void ConfigureSelector(string rootPath, string controllerName, ActionModel action, ConventionalControllerSetting? configuration) { RemoveEmptySelectors(action.Selectors); @@ -332,7 +332,7 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency } } - protected virtual void AddAbpServiceSelector(string rootPath, string controllerName, ActionModel action, [CanBeNull] ConventionalControllerSetting configuration) + protected virtual void AddAbpServiceSelector(string rootPath, string controllerName, ActionModel action, ConventionalControllerSetting? configuration) { var httpMethod = SelectHttpMethod(action, configuration); @@ -345,12 +345,12 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency action.Selectors.Add(abpServiceSelectorModel); } - protected virtual string SelectHttpMethod(ActionModel action, ConventionalControllerSetting configuration) + protected virtual string SelectHttpMethod(ActionModel action, ConventionalControllerSetting? configuration) { return HttpMethodHelper.GetConventionalVerbForMethodName(action.ActionName); } - protected virtual void NormalizeSelectorRoutes(string rootPath, string controllerName, ActionModel action, [CanBeNull] ConventionalControllerSetting configuration) + protected virtual void NormalizeSelectorRoutes(string rootPath, string controllerName, ActionModel action, ConventionalControllerSetting? configuration) { foreach (var selector in action.Selectors) { @@ -394,13 +394,12 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency return ModuleApiDescriptionModel.DefaultRootPath; } - [CanBeNull] - protected virtual ConventionalControllerSetting GetControllerSettingOrNull(Type controllerType) + protected virtual ConventionalControllerSetting? GetControllerSettingOrNull(Type controllerType) { return Options.ConventionalControllers.ConventionalControllerSettings.GetSettingOrNull(controllerType); } - protected virtual AttributeRouteModel CreateAbpServiceAttributeRouteModel(string rootPath, string controllerName, ActionModel action, string httpMethod, [CanBeNull] ConventionalControllerSetting configuration) + protected virtual AttributeRouteModel CreateAbpServiceAttributeRouteModel(string rootPath, string controllerName, ActionModel action, string httpMethod, ConventionalControllerSetting? configuration) { return new AttributeRouteModel( new RouteAttribute( diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs index bb059a6674..5523a52020 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs @@ -33,7 +33,7 @@ public class ConventionalControllerSetting _rootPath = value; } } - private string _rootPath; + private string _rootPath = default!; [NotNull] public string RemoteServiceName { @@ -43,28 +43,24 @@ public class ConventionalControllerSetting _remoteServiceName = value; } } - private string _remoteServiceName; + private string _remoteServiceName = default!; - [CanBeNull] - public Func TypePredicate { get; set; } + public Func? TypePredicate { get; set; } /// /// Default value: All. /// public ApplicationServiceTypes ApplicationServiceTypes { get; set; } = ApplicationServiceTypes.All; - [CanBeNull] - public Action ControllerModelConfigurer { get; set; } + public Action? ControllerModelConfigurer { get; set; } - [CanBeNull] - public Func UrlControllerNameNormalizer { get; set; } + public Func? UrlControllerNameNormalizer { get; set; } - [CanBeNull] - public Func UrlActionNameNormalizer { get; set; } + public Func? UrlActionNameNormalizer { get; set; } public List ApiVersions { get; } - public Action ApiVersionConfigurer { get; set; } + public Action? ApiVersionConfigurer { get; set; } public ConventionalControllerSetting( [NotNull] Assembly assembly, @@ -84,7 +80,7 @@ public class ConventionalControllerSetting var types = Assembly.GetTypes() .Where(IsRemoteService) .Where(IsPreferredApplicationServiceType) - .WhereIf(TypePredicate != null, TypePredicate); + .WhereIf(TypePredicate != null, TypePredicate!); foreach (var type in types) { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSettingList.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSettingList.cs index 085eef7163..633be5786f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSettingList.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSettingList.cs @@ -7,8 +7,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Conventions; public class ConventionalControllerSettingList : List { - [CanBeNull] - public ConventionalControllerSetting GetSettingOrNull(Type controllerType) + public ConventionalControllerSetting? GetSettingOrNull(Type controllerType) { return this.FirstOrDefault(controllerSetting => controllerSetting.ControllerTypes.Contains(controllerType)); } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalRouteBuilder.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalRouteBuilder.cs index f9c31467b5..7e5b364b3e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalRouteBuilder.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalRouteBuilder.cs @@ -24,7 +24,7 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep string controllerName, ActionModel action, string httpMethod, - [CanBeNull] ConventionalControllerSetting configuration) + ConventionalControllerSetting? configuration) { var apiRoutePrefix = GetApiRoutePrefix(action, configuration); var controllerNameInUrl = @@ -71,7 +71,7 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep return url; } - protected virtual string GetApiRoutePrefix(ActionModel actionModel, ConventionalControllerSetting configuration) + protected virtual string GetApiRoutePrefix(ActionModel actionModel, ConventionalControllerSetting? configuration) { if (IntegrationServiceAttribute.IsDefinedOrInherited(actionModel.Controller.ControllerType)) { @@ -82,7 +82,7 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep } protected virtual string NormalizeUrlActionName(string rootPath, string controllerName, ActionModel action, - string httpMethod, [CanBeNull] ConventionalControllerSetting configuration) + string httpMethod, ConventionalControllerSetting? configuration) { var actionNameInUrl = HttpMethodHelper .RemoveHttpMethodPrefix(action.ActionName, httpMethod) @@ -105,7 +105,7 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep } protected virtual string NormalizeUrlControllerName(string rootPath, string controllerName, ActionModel action, - string httpMethod, [CanBeNull] ConventionalControllerSetting configuration) + string httpMethod, ConventionalControllerSetting? configuration) { if (configuration?.UrlControllerNameNormalizer == null) { @@ -121,7 +121,7 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep } protected virtual string NormalizeControllerNameCase(string controllerName, - [CanBeNull] ConventionalControllerSetting configuration) + ConventionalControllerSetting? configuration) { if (configuration?.UseV3UrlStyle ?? Options.UseV3UrlStyle) { @@ -134,7 +134,7 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep } protected virtual string NormalizeActionNameCase(string actionName, - [CanBeNull] ConventionalControllerSetting configuration) + ConventionalControllerSetting? configuration) { if (configuration?.UseV3UrlStyle ?? Options.UseV3UrlStyle) { @@ -147,13 +147,13 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep } protected virtual string NormalizeIdPropertyNameCase(PropertyInfo property, - [CanBeNull] ConventionalControllerSetting configuration) + ConventionalControllerSetting? configuration) { return property.Name; } protected virtual string NormalizeSecondaryIdNameCase(ParameterModel secondaryId, - [CanBeNull] ConventionalControllerSetting configuration) + ConventionalControllerSetting? configuration) { return secondaryId.ParameterName; } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/IConventionalRouteBuilder.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/IConventionalRouteBuilder.cs index c1bac761ce..8e55911240 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/IConventionalRouteBuilder.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/IConventionalRouteBuilder.cs @@ -10,6 +10,6 @@ public interface IConventionalRouteBuilder string controllerName, ActionModel action, string httpMethod, - [CanBeNull] ConventionalControllerSetting configuration + ConventionalControllerSetting? configuration ); } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/AbpValidationAttributeAdapterProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/AbpValidationAttributeAdapterProvider.cs index 466d8df630..0ba54c5448 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/AbpValidationAttributeAdapterProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/AbpValidationAttributeAdapterProvider.cs @@ -14,7 +14,7 @@ public class AbpValidationAttributeAdapterProvider : IValidationAttributeAdapter _defaultAdapter = defaultAdapter; } - public virtual IAttributeAdapter GetAttributeAdapter(ValidationAttribute attribute, IStringLocalizer stringLocalizer) + public virtual IAttributeAdapter? GetAttributeAdapter(ValidationAttribute attribute, IStringLocalizer? stringLocalizer) { var type = attribute.GetType(); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/DynamicMaxLengthAttributeAdapter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/DynamicMaxLengthAttributeAdapter.cs index 173931142d..37e4e40a4c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/DynamicMaxLengthAttributeAdapter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/DynamicMaxLengthAttributeAdapter.cs @@ -12,7 +12,7 @@ public class DynamicMaxLengthAttributeAdapter : AttributeAdapterBase().Serialize(remoteServiceErrorInfo, indented: true)); - var logger = context.GetService>(NullLogger.Instance); + var logger = context.GetService>(NullLogger.Instance)!; var logLevel = context.Exception.GetLogLevel(); logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString()); logger.LogException(context.Exception, logLevel); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionPageFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionPageFilter.cs index f595cd16ad..9db528d620 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionPageFilter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionPageFilter.cs @@ -47,7 +47,7 @@ public class AbpExceptionPageFilter : IAsyncPageFilter, ITransientDependency //TODO: Create DontWrap attribute to control wrapping..? if (context.ActionDescriptor.IsPageAction() && - ActionResultHelper.IsObjectResult(context.HandlerMethod.MethodInfo.ReturnType, typeof(void))) + ActionResultHelper.IsObjectResult(context.HandlerMethod!.MethodInfo.ReturnType, typeof(void))) { return true; } @@ -71,24 +71,24 @@ public class AbpExceptionPageFilter : IAsyncPageFilter, ITransientDependency var exceptionHandlingOptions = context.GetRequiredService>().Value; var exceptionToErrorInfoConverter = context.GetRequiredService(); - var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception, options => + var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception!, options => { options.SendExceptionsDetailsToClients = exceptionHandlingOptions.SendExceptionsDetailsToClients; options.SendStackTraceToClients = exceptionHandlingOptions.SendStackTraceToClients; }); - var logLevel = context.Exception.GetLogLevel(); + var logLevel = context.Exception!.GetLogLevel(); var remoteServiceErrorInfoBuilder = new StringBuilder(); remoteServiceErrorInfoBuilder.AppendLine($"---------- {nameof(RemoteServiceErrorInfo)} ----------"); remoteServiceErrorInfoBuilder.AppendLine(context.GetRequiredService().Serialize(remoteServiceErrorInfo, indented: true)); - var logger = context.GetService>(NullLogger.Instance); + var logger = context.GetService>(NullLogger.Instance)!; logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString()); - logger.LogException(context.Exception, logLevel); + logger.LogException(context.Exception!, logLevel); - await context.GetRequiredService().NotifyAsync(new ExceptionNotificationContext(context.Exception)); + await context.GetRequiredService().NotifyAsync(new ExceptionNotificationContext(context.Exception!)); if (context.Exception is AbpAuthorizationException) { @@ -100,7 +100,7 @@ public class AbpExceptionPageFilter : IAsyncPageFilter, ITransientDependency context.HttpContext.Response.Headers.Add(AbpHttpConsts.AbpErrorFormat, "true"); context.HttpContext.Response.StatusCode = (int)context .GetRequiredService() - .GetStatusCode(context.HttpContext, context.Exception); + .GetStatusCode(context.HttpContext, context.Exception!); context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo)); } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs index 6daff20ff8..7b7ccf7db7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs @@ -23,7 +23,7 @@ public class GlobalFeatureActionFilter : IAsyncActionFilter, ITransientDependenc if (!GlobalFeatureHelper.IsGlobalFeatureEnabled(context.Controller.GetType(), out var attribute)) { - var logger = context.GetService>(NullLogger.Instance); + var logger = context.GetService>(NullLogger.Instance)!; logger.LogWarning($"The '{context.Controller.GetType().FullName}' controller needs to enable '{attribute.Name}' feature."); context.Result = new NotFoundResult(); return; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs index d61024e919..c557b6c5bd 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs @@ -28,7 +28,7 @@ public class GlobalFeaturePageFilter : IAsyncPageFilter, ITransientDependency if (!GlobalFeatureHelper.IsGlobalFeatureEnabled(context.HandlerInstance.GetType(), out var attribute)) { - var logger = context.GetService>(NullLogger.Instance); + var logger = context.GetService>(NullLogger.Instance)!; logger.LogWarning($"The '{context.HandlerInstance.GetType().FullName}' page needs to enable '{attribute.Name}' feature."); context.Result = new NotFoundResult(); return; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpMvcAttributeValidationResultProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpMvcAttributeValidationResultProvider.cs index 690c82c9b1..34aeb2c44c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpMvcAttributeValidationResultProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpMvcAttributeValidationResultProvider.cs @@ -22,7 +22,7 @@ public class AbpMvcAttributeValidationResultProvider : DefaultAttributeValidatio _stringLocalizerFactory = stringLocalizerFactory; } - public override ValidationResult GetOrDefault(ValidationAttribute validationAttribute, object validatingObject, ValidationContext validationContext) + public override ValidationResult? GetOrDefault(ValidationAttribute validationAttribute, object? validatingObject, ValidationContext validationContext) { var resourceSource = _abpMvcDataAnnotationsLocalizationOptions.AssemblyResources.GetOrDefault(validationContext.ObjectType.Assembly); if (resourceSource == null) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinderProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinderProvider.cs index 0f122e70f5..a4c3ee2288 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinderProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinderProvider.cs @@ -12,7 +12,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ModelBinding; public class AbpDateTimeModelBinderProvider : IModelBinderProvider { - public IModelBinder GetBinder(ModelBinderProviderContext context) + public IModelBinder? GetBinder(ModelBinderProviderContext context) { var modelType = context.Metadata.UnderlyingOrModelType; if (modelType == typeof(DateTime)) @@ -31,7 +31,7 @@ public class AbpDateTimeModelBinderProvider : IModelBinderProvider context.Metadata.ContainerType.IsDefined(typeof(DisableDateTimeNormalizationAttribute), true); var dateNormalizationDisabledForProperty = context.Metadata.ContainerType - .GetProperty(context.Metadata.PropertyName) + .GetProperty(context.Metadata.PropertyName!) ?.IsDefined(typeof(DisableDateTimeNormalizationAttribute), true); if (!dateNormalizationDisabledForClass && diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertiesDictionaryModelBinderProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertiesDictionaryModelBinderProvider.cs index 4412194ad7..d0c3160092 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertiesDictionaryModelBinderProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertiesDictionaryModelBinderProvider.cs @@ -11,7 +11,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ModelBinding; public class AbpExtraPropertiesDictionaryModelBinderProvider : IModelBinderProvider { - public IModelBinder GetBinder(ModelBinderProviderContext context) + public IModelBinder? GetBinder(ModelBinderProviderContext context) { if (context == null) { @@ -41,6 +41,6 @@ public class AbpExtraPropertiesDictionaryModelBinderProvider : IModelBinderProvi valueBinder, loggerFactory, true /* allowValidatingTopLevelNodes */, - mvcOptions); + mvcOptions)!; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertyModelBinder.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertyModelBinder.cs index 3ff9b0f760..deebcf4a39 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertyModelBinder.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertyModelBinder.cs @@ -35,7 +35,7 @@ public class AbpExtraPropertyModelBinder : IModelBinder return Task.CompletedTask; } - protected virtual object ConvertStringToPropertyType(ModelBindingContext bindingContext, string value) + protected virtual object? ConvertStringToPropertyType(ModelBindingContext bindingContext, string? value) { if (bindingContext.ModelMetadata.ConvertEmptyStringToNull && string.IsNullOrWhiteSpace(value)) { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/ExtraPropertyBindingHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/ExtraPropertyBindingHelper.cs index 646cbf0c4b..46aef196cc 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/ExtraPropertyBindingHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/ExtraPropertyBindingHelper.cs @@ -8,7 +8,7 @@ public static class ExtraPropertyBindingHelper /// is a string like "UserInfo.ExtraProperties[SocialSecurityNumber]" /// This method returns "SocialSecurityNumber" for this example. */ /// - public static string ExtractExtraPropertyName(string expression) + public static string? ExtractExtraPropertyName(string expression) { var index = expression.IndexOf("ExtraProperties[", StringComparison.Ordinal); if (index < 0) @@ -23,7 +23,7 @@ public static class ExtraPropertyBindingHelper /// is a string like "UserInfo.ExtraProperties[SocialSecurityNumber]" /// This method returns "UserInfo" for this example. /// - public static string ExtractContainerName(string expression) + public static string? ExtractContainerName(string expression) { var index = expression.IndexOf("ExtraProperties[", StringComparison.Ordinal); if (index < 0) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/ServiceProxyGenerationModel.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/ServiceProxyGenerationModel.cs index 3501882e3a..b912d3905a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/ServiceProxyGenerationModel.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/ServiceProxyGenerationModel.cs @@ -7,15 +7,15 @@ namespace Volo.Abp.AspNetCore.Mvc.ProxyScripting; public class ServiceProxyGenerationModel { - public string Type { get; set; } + public string? Type { get; set; } public bool UseCache { get; set; } - public string Modules { get; set; } + public string? Modules { get; set; } - public string Controllers { get; set; } + public string? Controllers { get; set; } - public string Actions { get; set; } + public string? Actions { get; set; } public ServiceProxyGenerationModel() { @@ -36,17 +36,17 @@ public class ServiceProxyGenerationModel if (!Modules.IsNullOrEmpty()) { - options.Modules = Modules.Split('|').Select(m => m.Trim()).ToArray(); + options.Modules = Modules!.Split('|').Select(m => m.Trim()).ToArray(); } if (!Controllers.IsNullOrEmpty()) { - options.Controllers = Controllers.Split('|').Select(m => m.Trim()).ToArray(); + options.Controllers = Controllers!.Split('|').Select(m => m.Trim()).ToArray(); } if (!Actions.IsNullOrEmpty()) { - options.Actions = Actions.Split('|').Select(m => m.Trim()).ToArray(); + options.Actions = Actions!.Split('|').Select(m => m.Trim()).ToArray(); } return options; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs index 8f6cc2abf8..14032b52d5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs @@ -67,7 +67,7 @@ public class AbpUowActionFilter : IAsyncActionFilter, ITransientDependency } } - private AbpUnitOfWorkOptions CreateOptions(ActionExecutingContext context, UnitOfWorkAttribute unitOfWorkAttribute) + private AbpUnitOfWorkOptions CreateOptions(ActionExecutingContext context, UnitOfWorkAttribute? unitOfWorkAttribute) { var options = new AbpUnitOfWorkOptions(); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowPageFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowPageFilter.cs index 57e1df8558..7cfc1f0492 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowPageFilter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowPageFilter.cs @@ -73,7 +73,7 @@ public class AbpUowPageFilter : IAsyncPageFilter, ITransientDependency } } - private AbpUnitOfWorkOptions CreateOptions(PageHandlerExecutingContext context, UnitOfWorkAttribute unitOfWorkAttribute) + private AbpUnitOfWorkOptions CreateOptions(PageHandlerExecutingContext context, UnitOfWorkAttribute? unitOfWorkAttribute) { var options = new AbpUnitOfWorkOptions(); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Utils/ArrayMatcher.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Utils/ArrayMatcher.cs index 10198264c2..c785964f1f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Utils/ArrayMatcher.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Utils/ArrayMatcher.cs @@ -33,7 +33,7 @@ internal static class ArrayMatcher } var resultItem = EqualityComparer.Default.Equals(parentItem, default) ? sourceItem : parentItem; - result.Add(resultItem); + result.Add(resultItem!); } return result.ToArray(); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/ValidationAttributeHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/ValidationAttributeHelper.cs index ccec4e0c01..505c07a3e1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/ValidationAttributeHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/ValidationAttributeHelper.cs @@ -6,10 +6,10 @@ namespace Volo.Abp.AspNetCore.Mvc.Validation; public static class ValidationAttributeHelper { private static readonly PropertyInfo ValidationAttributeErrorMessageStringProperty = typeof(ValidationAttribute) - .GetProperty("ErrorMessageString", BindingFlags.Instance | BindingFlags.NonPublic); + .GetProperty("ErrorMessageString", BindingFlags.Instance | BindingFlags.NonPublic)!; private static readonly PropertyInfo ValidationAttributeCustomErrorMessageSetProperty = typeof(ValidationAttribute) - .GetProperty("CustomErrorMessageSet", BindingFlags.Instance | BindingFlags.NonPublic); + .GetProperty("CustomErrorMessageSet", BindingFlags.Instance | BindingFlags.NonPublic)!; public static void SetDefaultErrorMessage(ValidationAttribute validationAttribute) { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Versioning/HttpContextRequestedApiVersion.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Versioning/HttpContextRequestedApiVersion.cs index 09db4c3ce2..b634799fb1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Versioning/HttpContextRequestedApiVersion.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Versioning/HttpContextRequestedApiVersion.cs @@ -6,7 +6,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Versioning; public class HttpContextRequestedApiVersion : IRequestedApiVersion { - public string Current => _httpContextAccessor.HttpContext?.GetRequestedApiVersion()?.ToString(); + public string? Current => _httpContextAccessor.HttpContext?.GetRequestedApiVersion()?.ToString(); private readonly IHttpContextAccessor _httpContextAccessor; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoAspNetCoreMvcExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoAspNetCoreMvcExtensions.cs index b1c61d95bb..b154628a6a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoAspNetCoreMvcExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoAspNetCoreMvcExtensions.cs @@ -34,7 +34,7 @@ public static class ObjectExtensionPropertyInfoAspNetCoreMvcExtensions .FirstOrDefault()?.DataType; } - public static string GetDataFormatStringOrNull(this IBasicObjectExtensionPropertyInfo property) + public static string? GetDataFormatStringOrNull(this IBasicObjectExtensionPropertyInfo property) { return property .Attributes