From a3217bb86d7b270ef4ac802dbae0c5953ef70f59 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Wed, 21 Feb 2024 16:34:53 +0900 Subject: [PATCH] Remove InitialiationTask from interface --- Dalamud/Game/Config/GameConfig.cs | 13 +++++++------ Dalamud/Plugin/Services/IGameConfig.cs | 15 ++++----------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Dalamud/Game/Config/GameConfig.cs b/Dalamud/Game/Config/GameConfig.cs index 94a92a4da..162df9417 100644 --- a/Dalamud/Game/Config/GameConfig.cs +++ b/Dalamud/Game/Config/GameConfig.cs @@ -81,7 +81,9 @@ internal sealed class GameConfig : IServiceType, IGameConfig, IDisposable public event EventHandler? UiControlChanged; #pragma warning restore 67 - /// + /// + /// Gets a task representing the initialization state of this class. + /// public Task InitializationTask => this.tcsInitialization.Task; /// @@ -251,13 +253,15 @@ internal class GameConfigPluginScoped : IDisposable, IServiceType, IGameConfig [ServiceManager.ServiceDependency] private readonly GameConfig gameConfigService = Service.Get(); + private readonly Task initializationTask; + /// /// Initializes a new instance of the class. /// internal GameConfigPluginScoped() { this.gameConfigService.Changed += this.ConfigChangedForward; - this.InitializationTask = this.gameConfigService.InitializationTask.ContinueWith( + this.initializationTask = this.gameConfigService.InitializationTask.ContinueWith( r => { if (!r.IsCompletedSuccessfully) @@ -281,9 +285,6 @@ internal class GameConfigPluginScoped : IDisposable, IServiceType, IGameConfig /// public event EventHandler? UiControlChanged; - /// - public Task InitializationTask { get; } - /// public GameConfigSection System => this.gameConfigService.System; @@ -297,7 +298,7 @@ internal class GameConfigPluginScoped : IDisposable, IServiceType, IGameConfig public void Dispose() { this.gameConfigService.Changed -= this.ConfigChangedForward; - this.InitializationTask.ContinueWith( + this.initializationTask.ContinueWith( r => { if (!r.IsCompletedSuccessfully) diff --git a/Dalamud/Plugin/Services/IGameConfig.cs b/Dalamud/Plugin/Services/IGameConfig.cs index 8249aed76..c69fa906a 100644 --- a/Dalamud/Plugin/Services/IGameConfig.cs +++ b/Dalamud/Plugin/Services/IGameConfig.cs @@ -10,7 +10,10 @@ namespace Dalamud.Plugin.Services; /// This class represents the game's configuration. /// /// -/// Avoid accessing configuration from your plugin constructor, especially if your plugin sets +/// Accessing -typed properties such as , directly or indirectly +/// via , +/// , or alike will block, if the game is not done loading.
+/// Therefore, avoid accessing configuration from your plugin constructor, especially if your plugin sets /// to 2 and to true. /// If property access from the plugin constructor is desired, do the value retrieval asynchronously via /// ; do not wait for the result right away. @@ -37,16 +40,6 @@ public interface IGameConfig /// public event EventHandler UiControlChanged; - /// - /// Gets a task representing the initialization state of this instance of . - /// - /// - /// Accessing -typed properties such as , directly or indirectly - /// via , - /// , or alike will block, if this task is incomplete. - /// - public Task InitializationTask { get; } - /// /// Gets the collection of config options that persist between characters. ///