Remove InitialiationTask from interface

This commit is contained in:
Soreepeong 2024-02-21 16:34:53 +09:00
parent da969dec5c
commit a3217bb86d
2 changed files with 11 additions and 17 deletions

View file

@ -81,7 +81,9 @@ internal sealed class GameConfig : IServiceType, IGameConfig, IDisposable
public event EventHandler<ConfigChangeEvent>? UiControlChanged; public event EventHandler<ConfigChangeEvent>? UiControlChanged;
#pragma warning restore 67 #pragma warning restore 67
/// <inheritdoc/> /// <summary>
/// Gets a task representing the initialization state of this class.
/// </summary>
public Task InitializationTask => this.tcsInitialization.Task; public Task InitializationTask => this.tcsInitialization.Task;
/// <inheritdoc/> /// <inheritdoc/>
@ -251,13 +253,15 @@ internal class GameConfigPluginScoped : IDisposable, IServiceType, IGameConfig
[ServiceManager.ServiceDependency] [ServiceManager.ServiceDependency]
private readonly GameConfig gameConfigService = Service<GameConfig>.Get(); private readonly GameConfig gameConfigService = Service<GameConfig>.Get();
private readonly Task initializationTask;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="GameConfigPluginScoped"/> class. /// Initializes a new instance of the <see cref="GameConfigPluginScoped"/> class.
/// </summary> /// </summary>
internal GameConfigPluginScoped() internal GameConfigPluginScoped()
{ {
this.gameConfigService.Changed += this.ConfigChangedForward; this.gameConfigService.Changed += this.ConfigChangedForward;
this.InitializationTask = this.gameConfigService.InitializationTask.ContinueWith( this.initializationTask = this.gameConfigService.InitializationTask.ContinueWith(
r => r =>
{ {
if (!r.IsCompletedSuccessfully) if (!r.IsCompletedSuccessfully)
@ -281,9 +285,6 @@ internal class GameConfigPluginScoped : IDisposable, IServiceType, IGameConfig
/// <inheritdoc/> /// <inheritdoc/>
public event EventHandler<ConfigChangeEvent>? UiControlChanged; public event EventHandler<ConfigChangeEvent>? UiControlChanged;
/// <inheritdoc/>
public Task InitializationTask { get; }
/// <inheritdoc/> /// <inheritdoc/>
public GameConfigSection System => this.gameConfigService.System; public GameConfigSection System => this.gameConfigService.System;
@ -297,7 +298,7 @@ internal class GameConfigPluginScoped : IDisposable, IServiceType, IGameConfig
public void Dispose() public void Dispose()
{ {
this.gameConfigService.Changed -= this.ConfigChangedForward; this.gameConfigService.Changed -= this.ConfigChangedForward;
this.InitializationTask.ContinueWith( this.initializationTask.ContinueWith(
r => r =>
{ {
if (!r.IsCompletedSuccessfully) if (!r.IsCompletedSuccessfully)

View file

@ -10,7 +10,10 @@ namespace Dalamud.Plugin.Services;
/// This class represents the game's configuration. /// This class represents the game's configuration.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Avoid accessing configuration from your plugin constructor, especially if your plugin sets /// Accessing <see cref="GameConfigSection"/>-typed properties such as <see cref="System"/>, directly or indirectly
/// via <see cref="TryGet(Game.Config.SystemConfigOption,out bool)"/>,
/// <see cref="Set(Game.Config.SystemConfigOption,bool)"/>, or alike will block, if the game is not done loading.<br />
/// Therefore, avoid accessing configuration from your plugin constructor, especially if your plugin sets
/// <see cref="PluginManifest.LoadRequiredState"/> to <c>2</c> and <see cref="PluginManifest.LoadSync"/> to <c>true</c>. /// <see cref="PluginManifest.LoadRequiredState"/> to <c>2</c> and <see cref="PluginManifest.LoadSync"/> to <c>true</c>.
/// If property access from the plugin constructor is desired, do the value retrieval asynchronously via /// If property access from the plugin constructor is desired, do the value retrieval asynchronously via
/// <see cref="IFramework.RunOnFrameworkThread{T}(Func{T})"/>; do not wait for the result right away. /// <see cref="IFramework.RunOnFrameworkThread{T}(Func{T})"/>; do not wait for the result right away.
@ -37,16 +40,6 @@ public interface IGameConfig
/// </summary> /// </summary>
public event EventHandler<ConfigChangeEvent> UiControlChanged; public event EventHandler<ConfigChangeEvent> UiControlChanged;
/// <summary>
/// Gets a task representing the initialization state of this instance of <see cref="IGameConfig"/>.
/// </summary>
/// <remarks>
/// Accessing <see cref="GameConfigSection"/>-typed properties such as <see cref="System"/>, directly or indirectly
/// via <see cref="TryGet(Game.Config.SystemConfigOption,out bool)"/>,
/// <see cref="Set(Game.Config.SystemConfigOption,bool)"/>, or alike will block, if this task is incomplete.
/// </remarks>
public Task InitializationTask { get; }
/// <summary> /// <summary>
/// Gets the collection of config options that persist between characters. /// Gets the collection of config options that persist between characters.
/// </summary> /// </summary>