From 68baf341b43d4dd5939fa36194679fa6f5d6e523 Mon Sep 17 00:00:00 2001 From: "Simon G." Date: Tue, 2 Dec 2025 09:26:51 +0100 Subject: [PATCH] - call method from interface --- .../FactoryGenerator.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/LightweightIocContainer.FactoryGenerator/FactoryGenerator.cs b/LightweightIocContainer.FactoryGenerator/FactoryGenerator.cs index f969dff..625c527 100644 --- a/LightweightIocContainer.FactoryGenerator/FactoryGenerator.cs +++ b/LightweightIocContainer.FactoryGenerator/FactoryGenerator.cs @@ -37,7 +37,6 @@ public class FactoryGenerator : IIncrementalGenerator stringBuilder.AppendLine("using LightweightIocContainer.Interfaces.Registrations;"); stringBuilder.AppendLine("using LightweightIocContainer.Interfaces.Registrations.Fluent;"); - stringBuilder.AppendLine("using LightweightIocContainer.Registrations;"); stringBuilder.AppendLine(); if (!string.IsNullOrEmpty(classNamespace)) @@ -52,13 +51,9 @@ public class FactoryGenerator : IIncrementalGenerator stringBuilder.AppendLine($"{INDENT}public static IRegistrationBase WithGeneratedFactory(this IRegistrationBase registration)"); stringBuilder.AppendLine($"{INDENT}{{"); stringBuilder.AppendLine($"{INDENT}{INDENT}TFactory factory = Builder.Create();"); + stringBuilder.AppendLine($"{INDENT}{INDENT}registration.AddGeneratedFactory(factory);"); stringBuilder.AppendLine(); - stringBuilder.AppendLine($"{INDENT}{INDENT}if (registration is not RegistrationBase registrationBase)"); - stringBuilder.AppendLine($"{INDENT}{INDENT}{INDENT}throw new InvalidOperationException(\"The registration must be of type RegistrationBase to add a generated factory.\");"); - stringBuilder.AppendLine(); - stringBuilder.AppendLine($"{INDENT}{INDENT}registrationBase.AddGeneratedFactory(factory);"); - stringBuilder.AppendLine(); - stringBuilder.AppendLine($"{INDENT}{INDENT}return registrationBase;"); + stringBuilder.AppendLine($"{INDENT}{INDENT}return registration;"); stringBuilder.AppendLine($"{INDENT}}}"); stringBuilder.AppendLine("}");