Browse Source

Enable nullable annotations for Volo.Abp.AspNetCore.Mvc

pull/17094/head
liangshiwei 3 years ago
parent
commit
4538e0eee4
  1. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Builder/AbpAspNetCoreMvcApplicationBuilderExtensions.cs
  2. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/AspNetCore/Mvc/Abstractions/ActionDescriptorExtensions.cs
  3. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj
  4. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpActionContextExtensions.cs
  5. 20
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs
  6. 14
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerBase.cs
  7. 12
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpDataAnnotationAutoLocalizationMetadataDetailsProvider.cs
  8. 6
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs
  9. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AbpAntiForgeryCookieNameProvider.cs
  10. 6
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AbpAntiForgeryOptions.cs
  11. 6
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AspNetCoreAbpAntiForgeryManager.cs
  12. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApiExploring/AbpRemoteServiceApiDescriptionProvider.cs
  13. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs
  14. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationLocalizationAppService.cs
  15. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs
  16. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDtoFactory.cs
  17. 6
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationPartSorter.cs
  18. 19
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
  19. 8
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs
  20. 8
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditActionFilter.cs
  21. 10
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditPageFilter.cs
  22. 6
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs
  23. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/AbpRemoteStreamContentModelBinder.cs
  24. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/AbpRemoteStreamContentModelBinderProvider.cs
  25. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentOutputFormatter.cs
  26. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpConventionalControllerOptions.cs
  27. 27
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs
  28. 20
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs
  29. 3
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSettingList.cs
  30. 16
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalRouteBuilder.cs
  31. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/IConventionalRouteBuilder.cs
  32. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/AbpValidationAttributeAdapterProvider.cs
  33. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/DynamicMaxLengthAttributeAdapter.cs
  34. 6
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/DynamicRangeAttributeAdapter.cs
  35. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/DynamicStringLengthAttributeAdapter.cs
  36. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs
  37. 14
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionPageFilter.cs
  38. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs
  39. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs
  40. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpMvcAttributeValidationResultProvider.cs
  41. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinderProvider.cs
  42. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertiesDictionaryModelBinderProvider.cs
  43. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertyModelBinder.cs
  44. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/ExtraPropertyBindingHelper.cs
  45. 14
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/ServiceProxyGenerationModel.cs
  46. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs
  47. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowPageFilter.cs
  48. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Utils/ArrayMatcher.cs
  49. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/ValidationAttributeHelper.cs
  50. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Versioning/HttpContextRequestedApiVersion.cs
  51. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoAspNetCoreMvcExtensions.cs

2
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!")] [Obsolete("Use app.UseConfiguredEndpoints(...) extension method instead!")]
public static IApplicationBuilder UseMvcWithDefaultRouteAndArea( public static IApplicationBuilder UseMvcWithDefaultRouteAndArea(
this IApplicationBuilder app, this IApplicationBuilder app,
Action<IEndpointRouteBuilder> additionalConfigurationAction = null) Action<IEndpointRouteBuilder>? additionalConfigurationAction = null)
{ {
return app.UseConfiguredEndpoints(additionalConfigurationAction); return app.UseConfiguredEndpoints(additionalConfigurationAction);
} }

4
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}"); 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) 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}"); throw new AbpException($"{nameof(actionDescriptor)} should be type of {typeof(PageActionDescriptor).AssemblyQualifiedName}");
} }
return actionDescriptor as PageActionDescriptor; return (actionDescriptor as PageActionDescriptor)!;
} }
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj

@ -5,6 +5,8 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc> <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<AssemblyName>Volo.Abp.AspNetCore.Mvc</AssemblyName> <AssemblyName>Volo.Abp.AspNetCore.Mvc</AssemblyName>
<PackageId>Volo.Abp.AspNetCore.Mvc</PackageId> <PackageId>Volo.Abp.AspNetCore.Mvc</PackageId>

2
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<T>(); return context.HttpContext.RequestServices.GetRequiredService<T>();
} }
public static T GetService<T>(this FilterContext context, T defaultValue = default) public static T? GetService<T>(this FilterContext context, T? defaultValue = default)
where T : class where T : class
{ {
return context.HttpContext.RequestServices.GetService<T>() ?? defaultValue; return context.HttpContext.RequestServices.GetService<T>() ?? defaultValue;

20
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 abstract class AbpController : Controller, IAvoidDuplicateCrossCuttingConcerns
{ {
public IAbpLazyServiceProvider LazyServiceProvider { get; set; } public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!;
[Obsolete("Use LazyServiceProvider instead.")] [Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; } public IServiceProvider ServiceProvider { get; set; } = default!;
protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService<IUnitOfWorkManager>(); protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService<IUnitOfWorkManager>();
protected Type ObjectMapperContext { get; set; } protected Type? ObjectMapperContext { get; set; }
protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService<IObjectMapper>(provider => protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService<IObjectMapper>(provider =>
ObjectMapperContext == null ObjectMapperContext == null
? provider.GetRequiredService<IObjectMapper>() ? provider.GetRequiredService<IObjectMapper>()
@ -40,7 +40,7 @@ public abstract class AbpController : Controller, IAvoidDuplicateCrossCuttingCon
protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService<ILoggerFactory>(); protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService<ILoggerFactory>();
protected ILogger Logger => LazyServiceProvider.LazyGetService<ILogger>(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance); protected ILogger Logger => LazyServiceProvider.LazyGetService<ILogger>(provider => LoggerFactory?.CreateLogger(GetType().FullName!) ?? NullLogger.Instance);
protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetRequiredService<ICurrentUser>(); protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetRequiredService<ICurrentUser>();
@ -48,7 +48,7 @@ public abstract class AbpController : Controller, IAvoidDuplicateCrossCuttingCon
protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetRequiredService<IAuthorizationService>(); protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetRequiredService<IAuthorizationService>();
protected IUnitOfWork CurrentUnitOfWork => UnitOfWorkManager?.Current; protected IUnitOfWork? CurrentUnitOfWork => UnitOfWorkManager?.Current;
protected IClock Clock => LazyServiceProvider.LazyGetRequiredService<IClock>(); protected IClock Clock => LazyServiceProvider.LazyGetRequiredService<IClock>();
@ -70,16 +70,16 @@ public abstract class AbpController : Controller, IAvoidDuplicateCrossCuttingCon
return _localizer; return _localizer;
} }
} }
private IStringLocalizer _localizer; private IStringLocalizer? _localizer;
protected Type LocalizationResource { protected Type? LocalizationResource {
get => _localizationResource; get => _localizationResource;
set { set {
_localizationResource = value; _localizationResource = value;
_localizer = null; _localizer = null;
} }
} }
private Type _localizationResource = typeof(DefaultResource); private Type? _localizationResource = typeof(DefaultResource);
public List<string> AppliedCrossCuttingConcerns { get; } = new List<string>(); public List<string> AppliedCrossCuttingConcerns { get; } = new List<string>();
@ -104,12 +104,12 @@ public abstract class AbpController : Controller, IAvoidDuplicateCrossCuttingCon
return localizer; 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)); 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); returnUrl = NormalizeReturnUrl(returnUrl);

14
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 abstract class AbpControllerBase : ControllerBase, IAvoidDuplicateCrossCuttingConcerns
{ {
public IAbpLazyServiceProvider LazyServiceProvider { get; set; } public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!;
protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService<IUnitOfWorkManager>(); protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService<IUnitOfWorkManager>();
protected Type ObjectMapperContext { get; set; } protected Type? ObjectMapperContext { get; set; }
protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService<IObjectMapper>(provider => protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService<IObjectMapper>(provider =>
ObjectMapperContext == null ObjectMapperContext == null
? provider.GetRequiredService<IObjectMapper>() ? provider.GetRequiredService<IObjectMapper>()
@ -36,7 +36,7 @@ public abstract class AbpControllerBase : ControllerBase, IAvoidDuplicateCrossCu
protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService<ILoggerFactory>(); protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService<ILoggerFactory>();
protected ILogger Logger => LazyServiceProvider.LazyGetService<ILogger>(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance); protected ILogger Logger => LazyServiceProvider.LazyGetService<ILogger>(provider => LoggerFactory?.CreateLogger(GetType().FullName!) ?? NullLogger.Instance);
protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetRequiredService<ICurrentUser>(); protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetRequiredService<ICurrentUser>();
@ -44,7 +44,7 @@ public abstract class AbpControllerBase : ControllerBase, IAvoidDuplicateCrossCu
protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetRequiredService<IAuthorizationService>(); protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetRequiredService<IAuthorizationService>();
protected IUnitOfWork CurrentUnitOfWork => UnitOfWorkManager?.Current; protected IUnitOfWork? CurrentUnitOfWork => UnitOfWorkManager?.Current;
protected IClock Clock => LazyServiceProvider.LazyGetRequiredService<IClock>(); protected IClock Clock => LazyServiceProvider.LazyGetRequiredService<IClock>();
@ -64,16 +64,16 @@ public abstract class AbpControllerBase : ControllerBase, IAvoidDuplicateCrossCu
return _localizer; return _localizer;
} }
} }
private IStringLocalizer _localizer; private IStringLocalizer? _localizer;
protected Type LocalizationResource { protected Type? LocalizationResource {
get => _localizationResource; get => _localizationResource;
set { set {
_localizationResource = value; _localizationResource = value;
_localizer = null; _localizer = null;
} }
} }
private Type _localizationResource = typeof(DefaultResource); private Type? _localizationResource = typeof(DefaultResource);
public List<string> AppliedCrossCuttingConcerns { get; } = new List<string>(); public List<string> AppliedCrossCuttingConcerns { get; } = new List<string>();

12
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpDataAnnotationAutoLocalizationMetadataDetailsProvider.cs

@ -17,13 +17,13 @@ public class AbpDataAnnotationAutoLocalizationMetadataDetailsProvider : IDisplay
private readonly Lazy<IStringLocalizerFactory> _stringLocalizerFactory; private readonly Lazy<IStringLocalizerFactory> _stringLocalizerFactory;
private readonly Lazy<IOptions<MvcDataAnnotationsLocalizationOptions>> _localizationOptions; private readonly Lazy<IOptions<MvcDataAnnotationsLocalizationOptions>> _localizationOptions;
private readonly ConcurrentDictionary<DisplayMetadataProviderContext, string> _displayNameKeys; private readonly ConcurrentDictionary<DisplayMetadataProviderContext, string?> _displayNameKeys;
public AbpDataAnnotationAutoLocalizationMetadataDetailsProvider(IServiceCollection services) public AbpDataAnnotationAutoLocalizationMetadataDetailsProvider(IServiceCollection services)
{ {
_stringLocalizerFactory = services.GetRequiredServiceLazy<IStringLocalizerFactory>(); _stringLocalizerFactory = services.GetRequiredServiceLazy<IStringLocalizerFactory>();
_localizationOptions = services.GetRequiredServiceLazy<IOptions<MvcDataAnnotationsLocalizationOptions>>(); _localizationOptions = services.GetRequiredServiceLazy<IOptions<MvcDataAnnotationsLocalizationOptions>>();
_displayNameKeys = new ConcurrentDictionary<DisplayMetadataProviderContext, string>(); _displayNameKeys = new ConcurrentDictionary<DisplayMetadataProviderContext, string?>();
} }
public virtual void CreateDisplayMetadata(DisplayMetadataProviderContext context) public virtual void CreateDisplayMetadata(DisplayMetadataProviderContext context)
@ -58,11 +58,11 @@ public class AbpDataAnnotationAutoLocalizationMetadataDetailsProvider : IDisplay
displayMetadata.DisplayName = () => displayMetadata.DisplayName = () =>
{ {
var key = _displayNameKeys.GetOrAdd(context, _ => GetDisplayNameKey(context, localizer)); 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 * DisplayName:ClassName:PropertyName
@ -71,7 +71,7 @@ public class AbpDataAnnotationAutoLocalizationMetadataDetailsProvider : IDisplay
* PropertyName * PropertyName
*/ */
LocalizedString localizedString = null; LocalizedString? localizedString = null;
if (context.Key.ContainerType != null) if (context.Key.ContainerType != null)
{ {
@ -102,7 +102,7 @@ public class AbpDataAnnotationAutoLocalizationMetadataDetailsProvider : IDisplay
if (localizedString.ResourceNotFound) if (localizedString.ResourceNotFound)
{ {
localizedString = localizer[context.Key.Name]; localizedString = localizer[context.Key.Name!];
if (!localizedString.ResourceNotFound) if (!localizedString.ResourceNotFound)
{ {
return localizedString.Name; return localizedString.Name;

6
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 abstract class AbpViewComponent : ViewComponent
{ {
public IAbpLazyServiceProvider LazyServiceProvider { get; set; } public IAbpLazyServiceProvider LazyServiceProvider { get; set; } = default!;
[Obsolete("Use LazyServiceProvider instead.")] [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<IObjectMapper>(provider => protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService<IObjectMapper>(provider =>
ObjectMapperContext == null ObjectMapperContext == null

4
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AntiForgery/AbpAntiForgeryCookieNameProvider.cs

@ -17,7 +17,7 @@ public class AbpAntiForgeryCookieNameProvider : ITransientDependency
_abpAntiForgeryOptions = abpAntiForgeryOptions.Value; _abpAntiForgeryOptions = abpAntiForgeryOptions.Value;
} }
public virtual string GetAuthCookieNameOrNull() public virtual string? GetAuthCookieNameOrNull()
{ {
if (_abpAntiForgeryOptions.AuthCookieSchemaName == null) if (_abpAntiForgeryOptions.AuthCookieSchemaName == null)
{ {
@ -27,7 +27,7 @@ public class AbpAntiForgeryCookieNameProvider : ITransientDependency
return _namedOptionsAccessor.Get(_abpAntiForgeryOptions.AuthCookieSchemaName)?.Cookie?.Name; return _namedOptionsAccessor.Get(_abpAntiForgeryOptions.AuthCookieSchemaName)?.Cookie?.Name;
} }
public virtual string GetAntiForgeryCookieNameOrNull() public virtual string? GetAntiForgeryCookieNameOrNull()
{ {
return _abpAntiForgeryOptions.TokenCookie.Name; return _abpAntiForgeryOptions.TokenCookie.Name;
} }

6
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. /// Used to find auth cookie when validating Anti Forgery token.
/// Default value: "Identity.Application". /// Default value: "Identity.Application".
/// </summary> /// </summary>
public string AuthCookieSchemaName { get; set; } public string? AuthCookieSchemaName { get; set; }
/// <summary> /// <summary>
/// Default value: true. /// Default value: true.
@ -34,7 +34,7 @@ public class AbpAntiForgeryOptions
get => _autoValidateFilter; get => _autoValidateFilter;
set => _autoValidateFilter = Check.NotNull(value, nameof(value)); set => _autoValidateFilter = Check.NotNull(value, nameof(value));
} }
private Predicate<Type> _autoValidateFilter; private Predicate<Type> _autoValidateFilter = default!;
/// <summary> /// <summary>
/// Default methods: "GET", "HEAD", "TRACE", "OPTIONS". /// Default methods: "GET", "HEAD", "TRACE", "OPTIONS".
@ -44,7 +44,7 @@ public class AbpAntiForgeryOptions
get => _autoValidateIgnoredHttpMethods; get => _autoValidateIgnoredHttpMethods;
set => _autoValidateIgnoredHttpMethods = Check.NotNull(value, nameof(value)); set => _autoValidateIgnoredHttpMethods = Check.NotNull(value, nameof(value));
} }
private HashSet<string> _autoValidateIgnoredHttpMethods; private HashSet<string> _autoValidateIgnoredHttpMethods = default!;
public AbpAntiForgeryOptions() public AbpAntiForgeryOptions()
{ {

6
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 AbpAntiForgeryOptions Options { get; }
protected HttpContext HttpContext => _httpContextAccessor.HttpContext; protected HttpContext HttpContext => _httpContextAccessor.HttpContext!;
private readonly IAntiforgery _antiforgery; private readonly IAntiforgery _antiforgery;
private readonly IHttpContextAccessor _httpContextAccessor; private readonly IHttpContextAccessor _httpContextAccessor;
@ -27,7 +27,7 @@ public class AspNetCoreAbpAntiForgeryManager : IAbpAntiForgeryManager, ITransien
public virtual void SetCookie() public virtual void SetCookie()
{ {
HttpContext.Response.Cookies.Append( HttpContext.Response.Cookies.Append(
Options.TokenCookie.Name, Options.TokenCookie.Name!,
GenerateToken(), GenerateToken(),
Options.TokenCookie.Build(HttpContext) Options.TokenCookie.Build(HttpContext)
); );
@ -35,6 +35,6 @@ public class AspNetCoreAbpAntiForgeryManager : IAbpAntiForgeryManager, ITransien
public virtual string GenerateToken() public virtual string GenerateToken()
{ {
return _antiforgery.GetAndStoreTokens(_httpContextAccessor.HttpContext).RequestToken; return _antiforgery.GetAndStoreTokens(_httpContextAccessor.HttpContext!).RequestToken!;
} }
} }

4
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) 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<IApiResponseTypeMetadataProvider>()) foreach (var responseTypeMetadataProvider in _mvcOptions.OutputFormatters.OfType<IApiResponseTypeMetadataProvider>())
{ {
var formatterSupportedContentTypes = responseTypeMetadataProvider.GetSupportedContentTypes(null, apiResponse.Type); var formatterSupportedContentTypes = responseTypeMetadataProvider.GetSupportedContentTypes(null!, apiResponse.Type!);
if (formatterSupportedContentTypes == null) if (formatterSupportedContentTypes == null)
{ {
continue; continue;

2
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() TimeZoneName = windowsTimeZoneId.IsNullOrWhiteSpace()
? null ? null
: _timezoneProvider.WindowsToIana(windowsTimeZoneId) : _timezoneProvider.WindowsToIana(windowsTimeZoneId!)
} }
} }
}; };

4
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); var localizer = await StringLocalizerFactory.CreateByResourceNameOrNullAsync(resource.ResourceName);
if (localizer != null) if (localizer != null)
{ {
Dictionary<string, LocalizedString> staticLocalizedStrings = null; Dictionary<string, LocalizedString>? staticLocalizedStrings = null;
if (input.OnlyDynamics) if (input.OnlyDynamics)
{ {
@ -71,7 +71,7 @@ public class AbpApplicationLocalizationAppService :
{ {
if (input.OnlyDynamics) if (input.OnlyDynamics)
{ {
var staticLocalizedString = staticLocalizedStrings.GetOrDefault(localizedString.Name); var staticLocalizedString = staticLocalizedStrings!.GetOrDefault(localizedString.Name);
if (staticLocalizedString != null && if (staticLocalizedString != null &&
localizedString.Value == staticLocalizedString.Value) localizedString.Value == staticLocalizedString.Value)
{ {

4
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 public class CachedObjectExtensionsDtoService : ICachedObjectExtensionsDtoService, ISingletonDependency
{ {
protected IExtensionPropertyAttributeDtoFactory ExtensionPropertyAttributeDtoFactory { get; } protected IExtensionPropertyAttributeDtoFactory ExtensionPropertyAttributeDtoFactory { get; }
protected volatile ObjectExtensionsDto CachedValue; protected volatile ObjectExtensionsDto? CachedValue;
protected readonly object SyncLock = new object(); protected readonly object SyncLock = new object();
public CachedObjectExtensionsDtoService(IExtensionPropertyAttributeDtoFactory extensionPropertyAttributeDtoFactory) public CachedObjectExtensionsDtoService(IExtensionPropertyAttributeDtoFactory extensionPropertyAttributeDtoFactory)
@ -193,7 +193,7 @@ public class CachedObjectExtensionsDtoService : ICachedObjectExtensionsDtoServic
return TypeHelper.GetSimplifiedName(propertyConfig.Type); return TypeHelper.GetSimplifiedName(propertyConfig.Type);
} }
protected virtual LocalizableStringDto CreateDisplayNameDto(ExtensionPropertyConfiguration propertyConfig) protected virtual LocalizableStringDto? CreateDisplayNameDto(ExtensionPropertyConfiguration propertyConfig)
{ {
if (propertyConfig.DisplayName == null) if (propertyConfig.DisplayName == null)
{ {

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDtoFactory.cs

@ -71,7 +71,7 @@ public class ExtensionPropertyAttributeDtoFactory : IExtensionPropertyAttributeD
return false; return false;
} }
protected virtual object GetPropertyValue(Attribute attribute, PropertyInfo property) protected virtual object? GetPropertyValue(Attribute attribute, PropertyInfo property)
{ {
var value = property.GetValue(attribute); var value = property.GetValue(attribute);
if (value == null) if (value == null)

6
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationPartSorter.cs

@ -135,7 +135,7 @@ public static class ApplicationPartSorter
.ToArray(); .ToArray();
} }
private static CompiledRazorAssemblyPart GetViewsPartOrNull(ApplicationPartManager partManager, private static CompiledRazorAssemblyPart? GetViewsPartOrNull(ApplicationPartManager partManager,
ApplicationPart assemblyPart) ApplicationPart assemblyPart)
{ {
var viewsAssemblyName = assemblyPart.Name + ".Views"; var viewsAssemblyName = assemblyPart.Name + ".Views";
@ -145,7 +145,7 @@ public static class ApplicationPartSorter
.FirstOrDefault(p => p.Name == viewsAssemblyName); .FirstOrDefault(p => p.Name == viewsAssemblyName);
} }
private static AssemblyPart GetOriginalAssemblyPartOrNull( private static AssemblyPart? GetOriginalAssemblyPartOrNull(
CompiledRazorAssemblyPart compiledRazorAssemblyPart, CompiledRazorAssemblyPart compiledRazorAssemblyPart,
ApplicationPartManager partManager) ApplicationPartManager partManager)
{ {
@ -155,7 +155,7 @@ public static class ApplicationPartSorter
.FirstOrDefault(p => p.Name == originalAssemblyName); .FirstOrDefault(p => p.Name == originalAssemblyName);
} }
private static IAbpModuleDescriptor GetModuleDescriptorForAssemblyOrNull( private static IAbpModuleDescriptor? GetModuleDescriptorForAssemblyOrNull(
IModuleContainer moduleContainer, IModuleContainer moduleContainer,
Assembly assembly) Assembly assembly)
{ {

19
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs

@ -162,7 +162,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide
} }
private static List<string> GetSupportedVersions(Type controllerType, MethodInfo method, private static List<string> GetSupportedVersions(Type controllerType, MethodInfo method,
ConventionalControllerSetting setting) ConventionalControllerSetting? setting)
{ {
var supportedVersions = new List<ApiVersion>(); var supportedVersions = new List<ApiVersion>();
@ -196,7 +196,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide
} }
private static void AddCustomTypesToModel(ApplicationApiDescriptionModel applicationModel, private static void AddCustomTypesToModel(ApplicationApiDescriptionModel applicationModel,
[CanBeNull] Type type) Type? type)
{ {
if (type == null) if (type == null)
{ {
@ -275,7 +275,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide
.Select(_ => "T" + i++) .Select(_ => "T" + i++)
.JoinAsString(","); .JoinAsString(",");
return $"{type.FullName.Left(type.FullName.IndexOf('`'))}<{argumentList}>"; return $"{type.FullName!.Left(type.FullName!.IndexOf('`'))}<{argumentList}>";
} }
private void AddParameterDescriptionsToModel(ActionApiDescriptionModel actionModel, MethodInfo method, private void AddParameterDescriptionsToModel(ActionApiDescriptionModel actionModel, MethodInfo method,
@ -339,16 +339,16 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide
if (modelNameProvider == null) if (modelNameProvider == null)
{ {
return parameterInfo.Name; return parameterInfo.Name!;
} }
return modelNameProvider.Name ?? parameterInfo.Name; return (modelNameProvider.Name ?? parameterInfo.Name)!;
} }
private static string GetRootPath( private static string GetRootPath(
[NotNull] Type controllerType, [NotNull] Type controllerType,
[NotNull] ActionDescriptor actionDescriptor, [NotNull] ActionDescriptor actionDescriptor,
[CanBeNull] ConventionalControllerSetting setting) ConventionalControllerSetting? setting)
{ {
if (setting != null) if (setting != null)
{ {
@ -364,7 +364,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide
return ModuleApiDescriptionModel.DefaultRootPath; return ModuleApiDescriptionModel.DefaultRootPath;
} }
private string GetRemoteServiceName(Type controllerType, [CanBeNull] ConventionalControllerSetting setting) private string GetRemoteServiceName(Type controllerType, ConventionalControllerSetting? setting)
{ {
if (setting != null) if (setting != null)
{ {
@ -381,7 +381,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide
return ModuleApiDescriptionModel.DefaultRemoteServiceName; return ModuleApiDescriptionModel.DefaultRemoteServiceName;
} }
private string FindGroupName(Type controllerType) private string? FindGroupName(Type controllerType)
{ {
var controllerNameAttribute = var controllerNameAttribute =
controllerType.GetCustomAttributes().OfType<ControllerNameAttribute>().FirstOrDefault(); controllerType.GetCustomAttributes().OfType<ControllerNameAttribute>().FirstOrDefault();
@ -394,8 +394,7 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide
return null; return null;
} }
[CanBeNull] private ConventionalControllerSetting? FindSetting(Type controllerType)
private ConventionalControllerSetting FindSetting(Type controllerType)
{ {
foreach (var controllerSetting in _abpAspNetCoreMvcOptions.ConventionalControllers.ConventionalControllerSettings) foreach (var controllerSetting in _abpAspNetCoreMvcOptions.ConventionalControllers.ConventionalControllerSettings)
{ {

8
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 class AspNetCoreApiDescriptionModelProviderOptions
{ {
public Func<Type, ConventionalControllerSetting, string> ControllerNameGenerator { get; set; } public Func<Type, ConventionalControllerSetting?, string> ControllerNameGenerator { get; set; }
public Func<MethodInfo, string> ActionNameGenerator { get; set; } public Func<MethodInfo, string> ActionNameGenerator { get; set; }
public Func<ApiParameterDescription, string> ApiParameterNameGenerator { get; set; } public Func<ApiParameterDescription, string?> ApiParameterNameGenerator { get; set; }
public AspNetCoreApiDescriptionModelProviderOptions() public AspNetCoreApiDescriptionModelProviderOptions()
{ {
@ -51,7 +51,7 @@ public class AspNetCoreApiDescriptionModelProviderOptions
methodNameBuilder.Append("And"); 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) if (apiParameterDescription.ModelMetadata is DefaultModelMetadata defaultModelMetadata)
{ {
var jsonPropertyNameAttribute = (JsonPropertyNameAttribute) var jsonPropertyNameAttribute = (JsonPropertyNameAttribute?)
defaultModelMetadata?.Attributes?.PropertyAttributes?.FirstOrDefault(x => x is JsonPropertyNameAttribute); defaultModelMetadata?.Attributes?.PropertyAttributes?.FirstOrDefault(x => x is JsonPropertyNameAttribute);
if (jsonPropertyNameAttribute != null) if (jsonPropertyNameAttribute != null)
{ {

8
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) if (result.Exception != null && !result.ExceptionHandled)
{ {
auditLog.Exceptions.Add(result.Exception); auditLog!.Exceptions.Add(result.Exception);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
auditLog.Exceptions.Add(ex); auditLog!.Exceptions.Add(ex);
throw; throw;
} }
finally finally
@ -45,13 +45,13 @@ public class AbpAuditActionFilter : IAsyncActionFilter, ITransientDependency
if (auditLogAction != null) if (auditLogAction != null)
{ {
auditLogAction.ExecutionDuration = Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds); 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; auditLog = null;
auditLogAction = null; auditLogAction = null;

10
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) if (result.Exception != null && !result.ExceptionHandled)
{ {
auditLog.Exceptions.Add(result.Exception); auditLog!.Exceptions.Add(result.Exception);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
auditLog.Exceptions.Add(ex); auditLog!.Exceptions.Add(ex);
throw; throw;
} }
finally finally
@ -50,13 +50,13 @@ public class AbpAuditPageFilter : IAsyncPageFilter, ITransientDependency
if (auditLogAction != null) if (auditLogAction != null)
{ {
auditLogAction.ExecutionDuration = Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds); 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; auditLog = null;
auditLogAction = null; auditLogAction = null;
@ -79,7 +79,7 @@ public class AbpAuditPageFilter : IAsyncPageFilter, ITransientDependency
} }
var auditingHelper = context.GetRequiredService<IAuditingHelper>(); var auditingHelper = context.GetRequiredService<IAuditingHelper>();
if (!auditingHelper.ShouldSaveAudit(context.HandlerMethod.MethodInfo, defaultValue: true)) if (!auditingHelper.ShouldSaveAudit(context.HandlerMethod!.MethodInfo, defaultValue: true))
{ {
return false; return false;
} }

6
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 AuthenticationType { get; }
protected string[] ForbidSchemes { get; } protected string[] ForbidSchemes { get; }
protected ChallengeAccountController(string[] challengeAuthenticationSchemas = null) protected ChallengeAccountController(string[]? challengeAuthenticationSchemas = null)
{ {
ChallengeAuthenticationSchemas = challengeAuthenticationSchemas ?? new[] { "oidc" }; ChallengeAuthenticationSchemas = challengeAuthenticationSchemas ?? new[] { "oidc" };
AuthenticationType = "Identity.Application"; AuthenticationType = "Identity.Application";
@ -68,12 +68,12 @@ public abstract class ChallengeAccountController : AbpController
{ {
RedirectUri = GetRedirectUrl(returnUrl, returnUrlHash) RedirectUri = GetRedirectUrl(returnUrl, returnUrlHash)
}, },
ForbidSchemes.IsNullOrEmpty() (ForbidSchemes.IsNullOrEmpty()
? new[] ? new[]
{ {
HttpContext.RequestServices.GetRequiredService<IOptions<AuthenticationOptions>>().Value.DefaultForbidScheme HttpContext.RequestServices.GetRequiredService<IOptions<AuthenticationOptions>>().Value.DefaultForbidScheme
} }
: ForbidSchemes : ForbidSchemes)!
)); ));
} }
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/AbpRemoteStreamContentModelBinder.cs

@ -155,6 +155,6 @@ public class AbpRemoteStreamContentModelBinder<TRemoteStreamContent> : IModelBin
return new List<T>(); return new List<T>();
} }
return (ICollection<T>)Activator.CreateInstance(modelType); return (ICollection<T>)Activator.CreateInstance(modelType)!;
} }
} }

2
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 class AbpRemoteStreamContentModelBinderProvider : IModelBinderProvider
{ {
public IModelBinder GetBinder(ModelBinderProviderContext context) public IModelBinder? GetBinder(ModelBinderProviderContext context)
{ {
if (context == null) if (context == null)
{ {

4
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("*/*")); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("*/*"));
} }
protected override bool CanWriteType(Type type) protected override bool CanWriteType(Type? type)
{ {
return typeof(IRemoteStreamContent).IsAssignableFrom(type); return typeof(IRemoteStreamContent).IsAssignableFrom(type);
} }
public async override Task WriteResponseBodyAsync(OutputFormatterWriteContext context) public async override Task WriteResponseBodyAsync(OutputFormatterWriteContext context)
{ {
var remoteStream = (IRemoteStreamContent)context.Object; var remoteStream = (IRemoteStreamContent?)context.Object;
if (remoteStream != null) if (remoteStream != null)
{ {

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpConventionalControllerOptions.cs

@ -33,7 +33,7 @@ public class AbpConventionalControllerOptions
public AbpConventionalControllerOptions Create( public AbpConventionalControllerOptions Create(
Assembly assembly, Assembly assembly,
[CanBeNull] Action<ConventionalControllerSetting> optionsAction = null) Action<ConventionalControllerSetting>? optionsAction = null)
{ {
var setting = new ConventionalControllerSetting( var setting = new ConventionalControllerSetting(
assembly, assembly,

27
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()) if (removeControllerModels.Any())
{ {
controllerModelsToRemove.AddRange(removeControllerModels); 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()) if (replaceControllerModels.Any())
{ {
controllerModelsToRemove.AddRange(replaceControllerModels); 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<ExposeServicesAttribute>(controllerModel.ControllerType); var exposeServicesAttr = ReflectionHelper.GetSingleAttributeOrDefault<ExposeServicesAttribute>(controllerModel.ControllerType);
if (exposeServicesAttr.IncludeSelf) if (exposeServicesAttr!.IncludeSelf)
{ {
var exposedControllerModels = GetControllers(application) var exposedControllerModels = GetControllers(application)
.Where(cm => exposeServicesAttr.ServiceTypes.Contains(cm.ControllerType)) .Where(cm => exposeServicesAttr.ServiceTypes.Contains(cm.ControllerType))
@ -148,7 +148,7 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency
if (exposedControllerModels.Any()) if (exposedControllerModels.Any())
{ {
controllerModelsToRemove.AddRange(exposedControllerModels); 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; continue;
} }
@ -173,13 +173,13 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency
} }
controllerModelsToRemove.Add(controllerModel); 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); application.Controllers.RemoveAll(controllerModelsToRemove);
} }
protected virtual void ConfigureRemoteService(ControllerModel controller, [CanBeNull] ConventionalControllerSetting configuration) protected virtual void ConfigureRemoteService(ControllerModel controller, ConventionalControllerSetting? configuration)
{ {
ConfigureApiExplorer(controller); ConfigureApiExplorer(controller);
ConfigureSelector(controller, configuration); ConfigureSelector(controller, configuration);
@ -288,7 +288,7 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency
action.ApiExplorer.IsVisible = visible; action.ApiExplorer.IsVisible = visible;
} }
protected virtual void ConfigureSelector(ControllerModel controller, [CanBeNull] ConventionalControllerSetting configuration) protected virtual void ConfigureSelector(ControllerModel controller, ConventionalControllerSetting? configuration)
{ {
RemoveEmptySelectors(controller.Selectors); 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); 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); var httpMethod = SelectHttpMethod(action, configuration);
@ -345,12 +345,12 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency
action.Selectors.Add(abpServiceSelectorModel); 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); 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) foreach (var selector in action.Selectors)
{ {
@ -394,13 +394,12 @@ public class AbpServiceConvention : IAbpServiceConvention, ITransientDependency
return ModuleApiDescriptionModel.DefaultRootPath; return ModuleApiDescriptionModel.DefaultRootPath;
} }
[CanBeNull] protected virtual ConventionalControllerSetting? GetControllerSettingOrNull(Type controllerType)
protected virtual ConventionalControllerSetting GetControllerSettingOrNull(Type controllerType)
{ {
return Options.ConventionalControllers.ConventionalControllerSettings.GetSettingOrNull(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( return new AttributeRouteModel(
new RouteAttribute( new RouteAttribute(

20
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs

@ -33,7 +33,7 @@ public class ConventionalControllerSetting
_rootPath = value; _rootPath = value;
} }
} }
private string _rootPath; private string _rootPath = default!;
[NotNull] [NotNull]
public string RemoteServiceName { public string RemoteServiceName {
@ -43,28 +43,24 @@ public class ConventionalControllerSetting
_remoteServiceName = value; _remoteServiceName = value;
} }
} }
private string _remoteServiceName; private string _remoteServiceName = default!;
[CanBeNull] public Func<Type, bool>? TypePredicate { get; set; }
public Func<Type, bool> TypePredicate { get; set; }
/// <summary> /// <summary>
/// Default value: All. /// Default value: All.
/// </summary> /// </summary>
public ApplicationServiceTypes ApplicationServiceTypes { get; set; } = ApplicationServiceTypes.All; public ApplicationServiceTypes ApplicationServiceTypes { get; set; } = ApplicationServiceTypes.All;
[CanBeNull] public Action<ControllerModel>? ControllerModelConfigurer { get; set; }
public Action<ControllerModel> ControllerModelConfigurer { get; set; }
[CanBeNull] public Func<UrlControllerNameNormalizerContext, string>? UrlControllerNameNormalizer { get; set; }
public Func<UrlControllerNameNormalizerContext, string> UrlControllerNameNormalizer { get; set; }
[CanBeNull] public Func<UrlActionNameNormalizerContext, string>? UrlActionNameNormalizer { get; set; }
public Func<UrlActionNameNormalizerContext, string> UrlActionNameNormalizer { get; set; }
public List<ApiVersion> ApiVersions { get; } public List<ApiVersion> ApiVersions { get; }
public Action<ApiVersioningOptions> ApiVersionConfigurer { get; set; } public Action<ApiVersioningOptions>? ApiVersionConfigurer { get; set; }
public ConventionalControllerSetting( public ConventionalControllerSetting(
[NotNull] Assembly assembly, [NotNull] Assembly assembly,
@ -84,7 +80,7 @@ public class ConventionalControllerSetting
var types = Assembly.GetTypes() var types = Assembly.GetTypes()
.Where(IsRemoteService) .Where(IsRemoteService)
.Where(IsPreferredApplicationServiceType) .Where(IsPreferredApplicationServiceType)
.WhereIf(TypePredicate != null, TypePredicate); .WhereIf(TypePredicate != null, TypePredicate!);
foreach (var type in types) foreach (var type in types)
{ {

3
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<ConventionalControllerSetting> public class ConventionalControllerSettingList : List<ConventionalControllerSetting>
{ {
[CanBeNull] public ConventionalControllerSetting? GetSettingOrNull(Type controllerType)
public ConventionalControllerSetting GetSettingOrNull(Type controllerType)
{ {
return this.FirstOrDefault(controllerSetting => controllerSetting.ControllerTypes.Contains(controllerType)); return this.FirstOrDefault(controllerSetting => controllerSetting.ControllerTypes.Contains(controllerType));
} }

16
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalRouteBuilder.cs

@ -24,7 +24,7 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep
string controllerName, string controllerName,
ActionModel action, ActionModel action,
string httpMethod, string httpMethod,
[CanBeNull] ConventionalControllerSetting configuration) ConventionalControllerSetting? configuration)
{ {
var apiRoutePrefix = GetApiRoutePrefix(action, configuration); var apiRoutePrefix = GetApiRoutePrefix(action, configuration);
var controllerNameInUrl = var controllerNameInUrl =
@ -71,7 +71,7 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep
return url; return url;
} }
protected virtual string GetApiRoutePrefix(ActionModel actionModel, ConventionalControllerSetting configuration) protected virtual string GetApiRoutePrefix(ActionModel actionModel, ConventionalControllerSetting? configuration)
{ {
if (IntegrationServiceAttribute.IsDefinedOrInherited(actionModel.Controller.ControllerType)) 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, protected virtual string NormalizeUrlActionName(string rootPath, string controllerName, ActionModel action,
string httpMethod, [CanBeNull] ConventionalControllerSetting configuration) string httpMethod, ConventionalControllerSetting? configuration)
{ {
var actionNameInUrl = HttpMethodHelper var actionNameInUrl = HttpMethodHelper
.RemoveHttpMethodPrefix(action.ActionName, httpMethod) .RemoveHttpMethodPrefix(action.ActionName, httpMethod)
@ -105,7 +105,7 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep
} }
protected virtual string NormalizeUrlControllerName(string rootPath, string controllerName, ActionModel action, protected virtual string NormalizeUrlControllerName(string rootPath, string controllerName, ActionModel action,
string httpMethod, [CanBeNull] ConventionalControllerSetting configuration) string httpMethod, ConventionalControllerSetting? configuration)
{ {
if (configuration?.UrlControllerNameNormalizer == null) if (configuration?.UrlControllerNameNormalizer == null)
{ {
@ -121,7 +121,7 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep
} }
protected virtual string NormalizeControllerNameCase(string controllerName, protected virtual string NormalizeControllerNameCase(string controllerName,
[CanBeNull] ConventionalControllerSetting configuration) ConventionalControllerSetting? configuration)
{ {
if (configuration?.UseV3UrlStyle ?? Options.UseV3UrlStyle) if (configuration?.UseV3UrlStyle ?? Options.UseV3UrlStyle)
{ {
@ -134,7 +134,7 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep
} }
protected virtual string NormalizeActionNameCase(string actionName, protected virtual string NormalizeActionNameCase(string actionName,
[CanBeNull] ConventionalControllerSetting configuration) ConventionalControllerSetting? configuration)
{ {
if (configuration?.UseV3UrlStyle ?? Options.UseV3UrlStyle) if (configuration?.UseV3UrlStyle ?? Options.UseV3UrlStyle)
{ {
@ -147,13 +147,13 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep
} }
protected virtual string NormalizeIdPropertyNameCase(PropertyInfo property, protected virtual string NormalizeIdPropertyNameCase(PropertyInfo property,
[CanBeNull] ConventionalControllerSetting configuration) ConventionalControllerSetting? configuration)
{ {
return property.Name; return property.Name;
} }
protected virtual string NormalizeSecondaryIdNameCase(ParameterModel secondaryId, protected virtual string NormalizeSecondaryIdNameCase(ParameterModel secondaryId,
[CanBeNull] ConventionalControllerSetting configuration) ConventionalControllerSetting? configuration)
{ {
return secondaryId.ParameterName; return secondaryId.ParameterName;
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/IConventionalRouteBuilder.cs

@ -10,6 +10,6 @@ public interface IConventionalRouteBuilder
string controllerName, string controllerName,
ActionModel action, ActionModel action,
string httpMethod, string httpMethod,
[CanBeNull] ConventionalControllerSetting configuration ConventionalControllerSetting? configuration
); );
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/AbpValidationAttributeAdapterProvider.cs

@ -14,7 +14,7 @@ public class AbpValidationAttributeAdapterProvider : IValidationAttributeAdapter
_defaultAdapter = defaultAdapter; _defaultAdapter = defaultAdapter;
} }
public virtual IAttributeAdapter GetAttributeAdapter(ValidationAttribute attribute, IStringLocalizer stringLocalizer) public virtual IAttributeAdapter? GetAttributeAdapter(ValidationAttribute attribute, IStringLocalizer? stringLocalizer)
{ {
var type = attribute.GetType(); var type = attribute.GetType();

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/DynamicMaxLengthAttributeAdapter.cs

@ -12,7 +12,7 @@ public class DynamicMaxLengthAttributeAdapter : AttributeAdapterBase<DynamicMaxL
public DynamicMaxLengthAttributeAdapter( public DynamicMaxLengthAttributeAdapter(
DynamicMaxLengthAttribute attribute, DynamicMaxLengthAttribute attribute,
IStringLocalizer stringLocalizer) IStringLocalizer? stringLocalizer)
: base(attribute, stringLocalizer) : base(attribute, stringLocalizer)
{ {
_max = Attribute.Length.ToString(CultureInfo.InvariantCulture); _max = Attribute.Length.ToString(CultureInfo.InvariantCulture);

6
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/DynamicRangeAttributeAdapter.cs

@ -14,11 +14,11 @@ public class DynamicRangeAttributeAdapter : AttributeAdapterBase<DynamicRangeAtt
public DynamicRangeAttributeAdapter( public DynamicRangeAttributeAdapter(
DynamicRangeAttribute attribute, DynamicRangeAttribute attribute,
IStringLocalizer stringLocalizer) IStringLocalizer? stringLocalizer)
: base(attribute, stringLocalizer) : base(attribute, stringLocalizer)
{ {
_min = Convert.ToString(Attribute.Minimum, CultureInfo.InvariantCulture); _min = Convert.ToString(Attribute.Minimum, CultureInfo.InvariantCulture)!;
_max = Convert.ToString(Attribute.Maximum, CultureInfo.InvariantCulture); _max = Convert.ToString(Attribute.Maximum, CultureInfo.InvariantCulture)!;
} }
public override void AddValidation(ClientModelValidationContext context) public override void AddValidation(ClientModelValidationContext context)

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/DataAnnotations/DynamicStringLengthAttributeAdapter.cs

@ -14,7 +14,7 @@ public class DynamicStringLengthAttributeAdapter : AttributeAdapterBase<DynamicS
public DynamicStringLengthAttributeAdapter( public DynamicStringLengthAttributeAdapter(
DynamicStringLengthAttribute attribute, DynamicStringLengthAttribute attribute,
IStringLocalizer stringLocalizer) IStringLocalizer? stringLocalizer)
: base(attribute, stringLocalizer) : base(attribute, stringLocalizer)
{ {
_max = Attribute.MaximumLength.ToString(CultureInfo.InvariantCulture); _max = Attribute.MaximumLength.ToString(CultureInfo.InvariantCulture);

4
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs

@ -77,7 +77,7 @@ public class AbpExceptionFilter : IAsyncExceptionFilter, ITransientDependency
context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo)); context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo));
} }
context.Exception = null; //Handled! context.Exception = null!; //Handled!
} }
protected virtual void LogException(ExceptionContext context, out RemoteServiceErrorInfo remoteServiceErrorInfo) protected virtual void LogException(ExceptionContext context, out RemoteServiceErrorInfo remoteServiceErrorInfo)
@ -94,7 +94,7 @@ public class AbpExceptionFilter : IAsyncExceptionFilter, ITransientDependency
remoteServiceErrorInfoBuilder.AppendLine($"---------- {nameof(RemoteServiceErrorInfo)} ----------"); remoteServiceErrorInfoBuilder.AppendLine($"---------- {nameof(RemoteServiceErrorInfo)} ----------");
remoteServiceErrorInfoBuilder.AppendLine(context.GetRequiredService<IJsonSerializer>().Serialize(remoteServiceErrorInfo, indented: true)); remoteServiceErrorInfoBuilder.AppendLine(context.GetRequiredService<IJsonSerializer>().Serialize(remoteServiceErrorInfo, indented: true));
var logger = context.GetService<ILogger<AbpExceptionFilter>>(NullLogger<AbpExceptionFilter>.Instance); var logger = context.GetService<ILogger<AbpExceptionFilter>>(NullLogger<AbpExceptionFilter>.Instance)!;
var logLevel = context.Exception.GetLogLevel(); var logLevel = context.Exception.GetLogLevel();
logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString()); logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString());
logger.LogException(context.Exception, logLevel); logger.LogException(context.Exception, logLevel);

14
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..? //TODO: Create DontWrap attribute to control wrapping..?
if (context.ActionDescriptor.IsPageAction() && if (context.ActionDescriptor.IsPageAction() &&
ActionResultHelper.IsObjectResult(context.HandlerMethod.MethodInfo.ReturnType, typeof(void))) ActionResultHelper.IsObjectResult(context.HandlerMethod!.MethodInfo.ReturnType, typeof(void)))
{ {
return true; return true;
} }
@ -71,24 +71,24 @@ public class AbpExceptionPageFilter : IAsyncPageFilter, ITransientDependency
var exceptionHandlingOptions = context.GetRequiredService<IOptions<AbpExceptionHandlingOptions>>().Value; var exceptionHandlingOptions = context.GetRequiredService<IOptions<AbpExceptionHandlingOptions>>().Value;
var exceptionToErrorInfoConverter = context.GetRequiredService<IExceptionToErrorInfoConverter>(); var exceptionToErrorInfoConverter = context.GetRequiredService<IExceptionToErrorInfoConverter>();
var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception, options => var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception!, options =>
{ {
options.SendExceptionsDetailsToClients = exceptionHandlingOptions.SendExceptionsDetailsToClients; options.SendExceptionsDetailsToClients = exceptionHandlingOptions.SendExceptionsDetailsToClients;
options.SendStackTraceToClients = exceptionHandlingOptions.SendStackTraceToClients; options.SendStackTraceToClients = exceptionHandlingOptions.SendStackTraceToClients;
}); });
var logLevel = context.Exception.GetLogLevel(); var logLevel = context.Exception!.GetLogLevel();
var remoteServiceErrorInfoBuilder = new StringBuilder(); var remoteServiceErrorInfoBuilder = new StringBuilder();
remoteServiceErrorInfoBuilder.AppendLine($"---------- {nameof(RemoteServiceErrorInfo)} ----------"); remoteServiceErrorInfoBuilder.AppendLine($"---------- {nameof(RemoteServiceErrorInfo)} ----------");
remoteServiceErrorInfoBuilder.AppendLine(context.GetRequiredService<IJsonSerializer>().Serialize(remoteServiceErrorInfo, indented: true)); remoteServiceErrorInfoBuilder.AppendLine(context.GetRequiredService<IJsonSerializer>().Serialize(remoteServiceErrorInfo, indented: true));
var logger = context.GetService<ILogger<AbpExceptionFilter>>(NullLogger<AbpExceptionFilter>.Instance); var logger = context.GetService<ILogger<AbpExceptionFilter>>(NullLogger<AbpExceptionFilter>.Instance)!;
logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString()); logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString());
logger.LogException(context.Exception, logLevel); logger.LogException(context.Exception!, logLevel);
await context.GetRequiredService<IExceptionNotifier>().NotifyAsync(new ExceptionNotificationContext(context.Exception)); await context.GetRequiredService<IExceptionNotifier>().NotifyAsync(new ExceptionNotificationContext(context.Exception!));
if (context.Exception is AbpAuthorizationException) 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.Headers.Add(AbpHttpConsts.AbpErrorFormat, "true");
context.HttpContext.Response.StatusCode = (int)context context.HttpContext.Response.StatusCode = (int)context
.GetRequiredService<IHttpExceptionStatusCodeFinder>() .GetRequiredService<IHttpExceptionStatusCodeFinder>()
.GetStatusCode(context.HttpContext, context.Exception); .GetStatusCode(context.HttpContext, context.Exception!);
context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo)); context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo));
} }

2
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)) if (!GlobalFeatureHelper.IsGlobalFeatureEnabled(context.Controller.GetType(), out var attribute))
{ {
var logger = context.GetService<ILogger<GlobalFeatureActionFilter>>(NullLogger<GlobalFeatureActionFilter>.Instance); var logger = context.GetService<ILogger<GlobalFeatureActionFilter>>(NullLogger<GlobalFeatureActionFilter>.Instance)!;
logger.LogWarning($"The '{context.Controller.GetType().FullName}' controller needs to enable '{attribute.Name}' feature."); logger.LogWarning($"The '{context.Controller.GetType().FullName}' controller needs to enable '{attribute.Name}' feature.");
context.Result = new NotFoundResult(); context.Result = new NotFoundResult();
return; return;

2
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)) if (!GlobalFeatureHelper.IsGlobalFeatureEnabled(context.HandlerInstance.GetType(), out var attribute))
{ {
var logger = context.GetService<ILogger<GlobalFeatureActionFilter>>(NullLogger<GlobalFeatureActionFilter>.Instance); var logger = context.GetService<ILogger<GlobalFeatureActionFilter>>(NullLogger<GlobalFeatureActionFilter>.Instance)!;
logger.LogWarning($"The '{context.HandlerInstance.GetType().FullName}' page needs to enable '{attribute.Name}' feature."); logger.LogWarning($"The '{context.HandlerInstance.GetType().FullName}' page needs to enable '{attribute.Name}' feature.");
context.Result = new NotFoundResult(); context.Result = new NotFoundResult();
return; return;

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpMvcAttributeValidationResultProvider.cs

@ -22,7 +22,7 @@ public class AbpMvcAttributeValidationResultProvider : DefaultAttributeValidatio
_stringLocalizerFactory = stringLocalizerFactory; _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); var resourceSource = _abpMvcDataAnnotationsLocalizationOptions.AssemblyResources.GetOrDefault(validationContext.ObjectType.Assembly);
if (resourceSource == null) if (resourceSource == null)

4
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 class AbpDateTimeModelBinderProvider : IModelBinderProvider
{ {
public IModelBinder GetBinder(ModelBinderProviderContext context) public IModelBinder? GetBinder(ModelBinderProviderContext context)
{ {
var modelType = context.Metadata.UnderlyingOrModelType; var modelType = context.Metadata.UnderlyingOrModelType;
if (modelType == typeof(DateTime)) if (modelType == typeof(DateTime))
@ -31,7 +31,7 @@ public class AbpDateTimeModelBinderProvider : IModelBinderProvider
context.Metadata.ContainerType.IsDefined(typeof(DisableDateTimeNormalizationAttribute), true); context.Metadata.ContainerType.IsDefined(typeof(DisableDateTimeNormalizationAttribute), true);
var dateNormalizationDisabledForProperty = context.Metadata.ContainerType var dateNormalizationDisabledForProperty = context.Metadata.ContainerType
.GetProperty(context.Metadata.PropertyName) .GetProperty(context.Metadata.PropertyName!)
?.IsDefined(typeof(DisableDateTimeNormalizationAttribute), true); ?.IsDefined(typeof(DisableDateTimeNormalizationAttribute), true);
if (!dateNormalizationDisabledForClass && if (!dateNormalizationDisabledForClass &&

4
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 class AbpExtraPropertiesDictionaryModelBinderProvider : IModelBinderProvider
{ {
public IModelBinder GetBinder(ModelBinderProviderContext context) public IModelBinder? GetBinder(ModelBinderProviderContext context)
{ {
if (context == null) if (context == null)
{ {
@ -41,6 +41,6 @@ public class AbpExtraPropertiesDictionaryModelBinderProvider : IModelBinderProvi
valueBinder, valueBinder,
loggerFactory, loggerFactory,
true /* allowValidatingTopLevelNodes */, true /* allowValidatingTopLevelNodes */,
mvcOptions); mvcOptions)!;
} }
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpExtraPropertyModelBinder.cs

@ -35,7 +35,7 @@ public class AbpExtraPropertyModelBinder : IModelBinder
return Task.CompletedTask; 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)) if (bindingContext.ModelMetadata.ConvertEmptyStringToNull && string.IsNullOrWhiteSpace(value))
{ {

4
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/ExtraPropertyBindingHelper.cs

@ -8,7 +8,7 @@ public static class ExtraPropertyBindingHelper
/// <paramref name="expression"/> is a string like "UserInfo.ExtraProperties[SocialSecurityNumber]" /// <paramref name="expression"/> is a string like "UserInfo.ExtraProperties[SocialSecurityNumber]"
/// This method returns "SocialSecurityNumber" for this example. */ /// This method returns "SocialSecurityNumber" for this example. */
/// </summary> /// </summary>
public static string ExtractExtraPropertyName(string expression) public static string? ExtractExtraPropertyName(string expression)
{ {
var index = expression.IndexOf("ExtraProperties[", StringComparison.Ordinal); var index = expression.IndexOf("ExtraProperties[", StringComparison.Ordinal);
if (index < 0) if (index < 0)
@ -23,7 +23,7 @@ public static class ExtraPropertyBindingHelper
/// <paramref name="expression"/> is a string like "UserInfo.ExtraProperties[SocialSecurityNumber]" /// <paramref name="expression"/> is a string like "UserInfo.ExtraProperties[SocialSecurityNumber]"
/// This method returns "UserInfo" for this example. /// This method returns "UserInfo" for this example.
/// </summary> /// </summary>
public static string ExtractContainerName(string expression) public static string? ExtractContainerName(string expression)
{ {
var index = expression.IndexOf("ExtraProperties[", StringComparison.Ordinal); var index = expression.IndexOf("ExtraProperties[", StringComparison.Ordinal);
if (index < 0) if (index < 0)

14
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 class ServiceProxyGenerationModel
{ {
public string Type { get; set; } public string? Type { get; set; }
public bool UseCache { 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() public ServiceProxyGenerationModel()
{ {
@ -36,17 +36,17 @@ public class ServiceProxyGenerationModel
if (!Modules.IsNullOrEmpty()) if (!Modules.IsNullOrEmpty())
{ {
options.Modules = Modules.Split('|').Select(m => m.Trim()).ToArray(); options.Modules = Modules!.Split('|').Select(m => m.Trim()).ToArray();
} }
if (!Controllers.IsNullOrEmpty()) if (!Controllers.IsNullOrEmpty())
{ {
options.Controllers = Controllers.Split('|').Select(m => m.Trim()).ToArray(); options.Controllers = Controllers!.Split('|').Select(m => m.Trim()).ToArray();
} }
if (!Actions.IsNullOrEmpty()) if (!Actions.IsNullOrEmpty())
{ {
options.Actions = Actions.Split('|').Select(m => m.Trim()).ToArray(); options.Actions = Actions!.Split('|').Select(m => m.Trim()).ToArray();
} }
return options; return options;

2
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(); var options = new AbpUnitOfWorkOptions();

2
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(); var options = new AbpUnitOfWorkOptions();

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Utils/ArrayMatcher.cs

@ -33,7 +33,7 @@ internal static class ArrayMatcher
} }
var resultItem = EqualityComparer<T>.Default.Equals(parentItem, default) ? sourceItem : parentItem; var resultItem = EqualityComparer<T>.Default.Equals(parentItem, default) ? sourceItem : parentItem;
result.Add(resultItem); result.Add(resultItem!);
} }
return result.ToArray(); return result.ToArray();

4
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 public static class ValidationAttributeHelper
{ {
private static readonly PropertyInfo ValidationAttributeErrorMessageStringProperty = typeof(ValidationAttribute) 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) 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) public static void SetDefaultErrorMessage(ValidationAttribute validationAttribute)
{ {

2
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 class HttpContextRequestedApiVersion : IRequestedApiVersion
{ {
public string Current => _httpContextAccessor.HttpContext?.GetRequestedApiVersion()?.ToString(); public string? Current => _httpContextAccessor.HttpContext?.GetRequestedApiVersion()?.ToString();
private readonly IHttpContextAccessor _httpContextAccessor; private readonly IHttpContextAccessor _httpContextAccessor;

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoAspNetCoreMvcExtensions.cs

@ -34,7 +34,7 @@ public static class ObjectExtensionPropertyInfoAspNetCoreMvcExtensions
.FirstOrDefault()?.DataType; .FirstOrDefault()?.DataType;
} }
public static string GetDataFormatStringOrNull(this IBasicObjectExtensionPropertyInfo property) public static string? GetDataFormatStringOrNull(this IBasicObjectExtensionPropertyInfo property)
{ {
return property return property
.Attributes .Attributes

Loading…
Cancel
Save