From 3ffd8a10a577ac858fc41d0cfbb00ef3b3e51588 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 28 Jun 2023 16:12:55 +0800 Subject: [PATCH] Enable nullable annotations for Volo.Abp.Autofac --- .../Extensions/DependencyInjection/AutofacRegistration.cs | 8 ++++---- .../AbpAutofacServiceCollectionExtensions.cs | 2 +- framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj | 2 ++ .../Volo/Abp/Autofac/AbpAutofacServiceProviderFactory.cs | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs b/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs index 241c3dd7a8..56a5d7480c 100644 --- a/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs +++ b/framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacRegistration.cs @@ -87,7 +87,7 @@ public static class AutofacRegistration public static void Populate( this ContainerBuilder builder, IServiceCollection services, - object lifetimeScopeTagForSingletons) + object? lifetimeScopeTagForSingletons) { if (services == null) { @@ -134,7 +134,7 @@ public static class AutofacRegistration private static IRegistrationBuilder ConfigureLifecycle( this IRegistrationBuilder registrationBuilder, ServiceLifetime lifecycleKind, - object lifetimeScopeTagForSingleton) + object? lifetimeScopeTagForSingleton) { switch (lifecycleKind) { @@ -179,7 +179,7 @@ public static class AutofacRegistration private static void Register( ContainerBuilder builder, IServiceCollection services, - object lifetimeScopeTagForSingletons) + object? lifetimeScopeTagForSingletons) { var moduleContainer = services.GetSingletonInstance(); var registrationActionList = services.GetRegistrationActionList(); @@ -223,7 +223,7 @@ public static class AutofacRegistration else { builder - .RegisterInstance(descriptor.ImplementationInstance) + .RegisterInstance(descriptor.ImplementationInstance!) .As(descriptor.ServiceType) .ConfigureLifecycle(descriptor.Lifetime, null); } diff --git a/framework/src/Volo.Abp.Autofac/Microsoft/Extensions/DependencyInjection/AbpAutofacServiceCollectionExtensions.cs b/framework/src/Volo.Abp.Autofac/Microsoft/Extensions/DependencyInjection/AbpAutofacServiceCollectionExtensions.cs index fe6e57ade8..e249e7e5ac 100644 --- a/framework/src/Volo.Abp.Autofac/Microsoft/Extensions/DependencyInjection/AbpAutofacServiceCollectionExtensions.cs +++ b/framework/src/Volo.Abp.Autofac/Microsoft/Extensions/DependencyInjection/AbpAutofacServiceCollectionExtensions.cs @@ -21,7 +21,7 @@ public static class AbpAutofacServiceCollectionExtensions return builder; } - public static IServiceProvider BuildAutofacServiceProvider([NotNull] this IServiceCollection services, Action builderAction = null) + public static IServiceProvider BuildAutofacServiceProvider([NotNull] this IServiceCollection services, Action? builderAction = null) { return services.BuildServiceProviderFromFactory(builderAction); } diff --git a/framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj b/framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj index 32c4eb4e39..cf1c18994a 100644 --- a/framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj +++ b/framework/src/Volo.Abp.Autofac/Volo.Abp.Autofac.csproj @@ -5,6 +5,8 @@ netstandard2.0;netstandard2.1;net7.0 + enable + Nullable Volo.Abp.Autofac Volo.Abp.Autofac $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacServiceProviderFactory.cs b/framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacServiceProviderFactory.cs index 0cc35cbf81..dd8f383c5c 100644 --- a/framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacServiceProviderFactory.cs +++ b/framework/src/Volo.Abp.Autofac/Volo/Abp/Autofac/AbpAutofacServiceProviderFactory.cs @@ -11,7 +11,7 @@ namespace Volo.Abp.Autofac; public class AbpAutofacServiceProviderFactory : IServiceProviderFactory { private readonly ContainerBuilder _builder; - private IServiceCollection _services; + private IServiceCollection _services = default!; public AbpAutofacServiceProviderFactory(ContainerBuilder builder) {