Remove nullability from IServiceScope.CreateAsync

This commit is contained in:
Soreepeong 2024-07-24 18:55:27 +09:00
parent 32b24b3b5a
commit 4b98f4e60a
5 changed files with 42 additions and 37 deletions

View file

@ -417,24 +417,16 @@ internal class LocalPlugin : IDisposable
try
{
if (this.manifest.LoadSync && this.manifest.LoadRequiredState is 0 or 1)
{
var newInstance = await framework.RunOnFrameworkThread(
() => this.ServiceScope.CreateAsync(
this.pluginType!,
this.DalamudInterface!)).ConfigureAwait(false);
this.instance = newInstance as IDalamudPlugin;
}
else
{
this.instance =
await this.ServiceScope.CreateAsync(this.pluginType!, this.DalamudInterface!) as IDalamudPlugin;
}
var forceFrameworkThread = this.manifest.LoadSync && this.manifest.LoadRequiredState is 0 or 1;
var newInstanceTask = forceFrameworkThread ? framework.RunOnFrameworkThread(Create) : Create();
this.instance = await newInstanceTask.ConfigureAwait(false);
async Task<IDalamudPlugin> Create() =>
(IDalamudPlugin)await this.ServiceScope!.CreateAsync(this.pluginType!, this.DalamudInterface!);
}
catch (Exception ex)
{
Log.Error(ex, "Exception in plugin constructor");
Log.Error(ex, "Exception during plugin initialization");
this.instance = null;
}