diff --git a/Dalamud/IoC/Internal/ServiceContainer.cs b/Dalamud/IoC/Internal/ServiceContainer.cs index 39c2007f31..a8eacb02de 100644 --- a/Dalamud/IoC/Internal/ServiceContainer.cs +++ b/Dalamud/IoC/Internal/ServiceContainer.cs @@ -145,7 +145,7 @@ await Task.WhenAll( /// Scoped objects to be injected. /// The scope to be used to create scoped services. /// A representing the operation. - public async ValueTask InjectProperties(object instance, object[] publicScopes, IServiceScope? scope = null) + public async Task InjectProperties(object instance, object[] publicScopes, IServiceScope? scope = null) { var scopeImpl = scope as ServiceScopeImpl; var objectType = instance.GetType(); diff --git a/Dalamud/IoC/Internal/ServiceScope.cs b/Dalamud/IoC/Internal/ServiceScope.cs index fb06ec75c5..4fc299f6e7 100644 --- a/Dalamud/IoC/Internal/ServiceScope.cs +++ b/Dalamud/IoC/Internal/ServiceScope.cs @@ -17,7 +17,7 @@ internal interface IServiceScope : IDisposable /// but not directly to created objects. /// /// The scopes to add. - public void RegisterPrivateScopes(params object[] scopes); + void RegisterPrivateScopes(params object[] scopes); /// /// Create an object. @@ -25,7 +25,7 @@ internal interface IServiceScope : IDisposable /// The type of object to create. /// Scoped objects to be included in the constructor. /// The created object. - public Task CreateAsync(Type objectType, params object[] scopedObjects); + Task CreateAsync(Type objectType, params object[] scopedObjects); /// /// Inject interfaces into public or static properties on the provided object. @@ -34,7 +34,7 @@ internal interface IServiceScope : IDisposable /// The object instance. /// Scoped objects to be injected. /// A representing the status of the operation. - public ValueTask InjectPropertiesAsync(object instance, params object[] scopedObjects); + Task InjectPropertiesAsync(object instance, params object[] scopedObjects); } /// @@ -47,29 +47,20 @@ internal class ServiceScopeImpl : IServiceScope private readonly List privateScopedObjects = []; private readonly ConcurrentDictionary> scopeCreatedObjects = new(); - /// - /// Initializes a new instance of the class. - /// + /// Initializes a new instance of the class. /// The container this scope will use to create services. - public ServiceScopeImpl(ServiceContainer container) - { - this.container = container; - } + public ServiceScopeImpl(ServiceContainer container) => this.container = container; /// - public void RegisterPrivateScopes(params object[] scopes) - { + public void RegisterPrivateScopes(params object[] scopes) => this.privateScopedObjects.AddRange(scopes); - } /// - public Task CreateAsync(Type objectType, params object[] scopedObjects) - { - return this.container.CreateAsync(objectType, scopedObjects, this); - } + public Task CreateAsync(Type objectType, params object[] scopedObjects) => + this.container.CreateAsync(objectType, scopedObjects, this); /// - public ValueTask InjectPropertiesAsync(object instance, params object[] scopedObjects) => + public Task InjectPropertiesAsync(object instance, params object[] scopedObjects) => this.container.InjectProperties(instance, scopedObjects, this); /// diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs index f0882c6fe9..ecd2e07991 100644 --- a/Dalamud/Plugin/DalamudPluginInterface.cs +++ b/Dalamud/Plugin/DalamudPluginInterface.cs @@ -487,7 +487,7 @@ public async Task CreateAsync(params object[] scopedObjects) where T : cla /// public bool Inject(object instance, params object[] scopedObjects) { - var t = this.InjectAsync(instance, scopedObjects).AsTask(); + var t = this.InjectAsync(instance, scopedObjects); t.Wait(); if (t.Exception is { } e) @@ -504,7 +504,7 @@ public bool Inject(object instance, params object[] scopedObjects) } /// - public ValueTask InjectAsync(object instance, params object[] scopedObjects) => + public Task InjectAsync(object instance, params object[] scopedObjects) => this.plugin.ServiceScope!.InjectPropertiesAsync(instance, this.GetPublicIocScopes(scopedObjects)); #endregion diff --git a/Dalamud/Plugin/IDalamudPluginInterface.cs b/Dalamud/Plugin/IDalamudPluginInterface.cs index 5205c3ed18..100d4570e1 100644 --- a/Dalamud/Plugin/IDalamudPluginInterface.cs +++ b/Dalamud/Plugin/IDalamudPluginInterface.cs @@ -321,7 +321,7 @@ public interface IDalamudPluginInterface /// /// The instance to inject services into. /// Objects to inject additionally. - /// Whether or not the injection succeeded. + /// Whether the injection succeeded. bool Inject(object instance, params object[] scopedObjects); /// @@ -330,5 +330,5 @@ public interface IDalamudPluginInterface /// The instance to inject services into. /// Objects to inject additionally. /// A representing the status of the operation. - ValueTask InjectAsync(object instance, params object[] scopedObjects); + Task InjectAsync(object instance, params object[] scopedObjects); }