From 840f85df05e569c654bc6b9db6c31bb75d09db62 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Sun, 1 May 2022 17:25:43 -0500 Subject: [PATCH] fix: Migration steps are registered explicitly Also moved to a module for SoC --- src/Recyclarr/CompositionRoot.cs | 5 +---- .../Migration/MigrationAutofacModule.cs | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/Recyclarr/Migration/MigrationAutofacModule.cs diff --git a/src/Recyclarr/CompositionRoot.cs b/src/Recyclarr/CompositionRoot.cs index aa6c7e55..e44bb924 100644 --- a/src/Recyclarr/CompositionRoot.cs +++ b/src/Recyclarr/CompositionRoot.cs @@ -89,10 +89,6 @@ public static class CompositionRoot builder.RegisterType().As(); builder.RegisterType().As(); - // Automatically register all migration steps - builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AssignableTo(); - builder.RegisterType().As(); - ConfigurationRegistrations(builder); CommandRegistrations(builder); @@ -101,6 +97,7 @@ public static class CompositionRoot builder.RegisterModule(); builder.RegisterModule(); builder.RegisterModule(); + builder.RegisterModule(); builder.Register(_ => AutoMapperConfig.Setup()).SingleInstance(); diff --git a/src/Recyclarr/Migration/MigrationAutofacModule.cs b/src/Recyclarr/Migration/MigrationAutofacModule.cs new file mode 100644 index 00000000..3f9c6601 --- /dev/null +++ b/src/Recyclarr/Migration/MigrationAutofacModule.cs @@ -0,0 +1,20 @@ +using Autofac; +using Recyclarr.Migration.Steps; + +namespace Recyclarr.Migration; + +public class MigrationAutofacModule : Module +{ + protected override void Load(ContainerBuilder builder) + { + base.Load(builder); + builder.RegisterType().As(); + + // Migration Steps + builder.RegisterType().As(); + builder.RegisterType().As(); + + // Automatically register all migration steps + // builder.RegisterAssemblyTypes(typeof(MigrationAutofacModule).Assembly).AssignableTo(); + } +}