From 5f19abd9799301a9960785ad0d18e31285a638f8 Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Tue, 24 Aug 2021 01:49:26 +0200 Subject: [PATCH] fix: wrong parameters for IoC --- Dalamud.CorePlugin/PluginImpl.cs | 3 ++- Dalamud/IoC/Internal/ServiceContainer.cs | 12 +++--------- Dalamud/Plugin/DalamudPluginInterface.cs | 6 ++---- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Dalamud.CorePlugin/PluginImpl.cs b/Dalamud.CorePlugin/PluginImpl.cs index 64462fcf8..a785152a8 100644 --- a/Dalamud.CorePlugin/PluginImpl.cs +++ b/Dalamud.CorePlugin/PluginImpl.cs @@ -1,6 +1,7 @@ using System; using Dalamud.Game.Command; +using Dalamud.Game.Gui; using Dalamud.Interface.Windowing; using Dalamud.IoC; using Dalamud.Logging; @@ -25,7 +26,7 @@ namespace Dalamud.CorePlugin /// Initializes a new instance of the class. /// /// Dalamud plugin interface. - public PluginImpl(DalamudPluginInterface pluginInterface) + public PluginImpl(DalamudPluginInterface pluginInterface, ChatGui chatGui) { try { diff --git a/Dalamud/IoC/Internal/ServiceContainer.cs b/Dalamud/IoC/Internal/ServiceContainer.cs index d7c7df074..6681c7ecb 100644 --- a/Dalamud/IoC/Internal/ServiceContainer.cs +++ b/Dalamud/IoC/Internal/ServiceContainer.cs @@ -86,13 +86,13 @@ namespace Dalamud.IoC.Internal var instance = FormatterServices.GetUninitializedObject(objectType); - if (!this.InjectProperties(instance, scopedObjects)) + if (!this.InjectProperties(instance, resolvedParams)) { Log.Error("Failed to create {TypeName}, a requested property service type could not be satisfied", objectType.FullName); return null; } - ctor.Invoke(instance, scopedObjects); + ctor.Invoke(instance, resolvedParams); return instance; } @@ -109,10 +109,8 @@ namespace Dalamud.IoC.Internal { var objectType = instance.GetType(); - Log.Information($"Injecting props into {objectType.FullName}"); - var props = objectType.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | - BindingFlags.NonPublic).Where(x => x.GetCustomAttributes(typeof(PluginServiceAttribute)).Any()).Select( + BindingFlags.NonPublic).Where(x => x.GetCustomAttributes(typeof(PluginServiceAttribute)).Any()).Select( propertyInfo => { var requiredVersion = propertyInfo.GetCustomAttribute(typeof(RequiredVersionAttribute)) as RequiredVersionAttribute; @@ -129,8 +127,6 @@ namespace Dalamud.IoC.Internal foreach (var prop in props) { - Log.Information($"Injecting {prop.propertyInfo.Name} for type {prop.propertyInfo.PropertyType.GetType().FullName}"); - var service = this.GetService(prop.propertyInfo.PropertyType, scopedObjects); if (service == null) @@ -142,8 +138,6 @@ namespace Dalamud.IoC.Internal prop.propertyInfo.SetValue(instance, service); } - Log.Information("Injected"); - return true; } diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs index 35b274665..ab8e27c10 100644 --- a/Dalamud/Plugin/DalamudPluginInterface.cs +++ b/Dalamud/Plugin/DalamudPluginInterface.cs @@ -15,9 +15,7 @@ using Dalamud.Game.Text.Sanitizer; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Interface; -using Dalamud.Interface.Internal; using Dalamud.Plugin.Internal; -using ServiceContainer = Dalamud.IoC.Internal.ServiceContainer; namespace Dalamud.Plugin { @@ -319,7 +317,7 @@ namespace Dalamud.Plugin /// The created and initialized type. public T? Create(params object[] scopedObjects) where T : class { - var svcContainer = Service.Get(); + var svcContainer = Service.Get(); var realScopedObjects = new object[scopedObjects.Length + 1]; realScopedObjects[0] = this; @@ -336,7 +334,7 @@ namespace Dalamud.Plugin /// Whether or not the injection succeeded. public bool Inject(object instance, params object[] scopedObjects) { - var svcContainer = Service.Get(); + var svcContainer = Service.Get(); var realScopedObjects = new object[scopedObjects.Length + 1]; realScopedObjects[0] = this;