refactor(app): harden shutdown per final review
Addresses final code review of phase-1 branch (Important I-1, I-3): - Move plugin Enable() loop inside the same try block as GameWindow.Run, and wrap each Enable() in per-plugin try/catch mirroring the Disable loop. Previously, a plugin Enable() throwing would skip the finally block entirely: plugins that had already enabled would never get disabled, Serilog would never flush, and the exception would escape ungracefully. Now Enable failures are logged and contained, and shutdown always runs. - Add a comment at the Get<LandBlock> call in GameWindow.OnLoad explaining why TryGet was avoided (the [MaybeNullWhen(false)] nullable-generic analysis trips TreatWarningsAsErrors). I-2 (camera aspect doesn't update on window resize) deferred to Phase 2. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fb83e0bb6f
commit
6a100ef6e7
2 changed files with 10 additions and 4 deletions
|
|
@ -40,11 +40,14 @@ foreach (var result in PluginDiscovery.Scan(pluginsDir))
|
|||
Log.Information("loaded plugin {Id} ({DisplayName})", result.Manifest!.Id, result.Manifest.DisplayName);
|
||||
}
|
||||
|
||||
foreach (var plugin in loaded)
|
||||
plugin.Plugin!.Enable();
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var plugin in loaded)
|
||||
{
|
||||
try { plugin.Plugin!.Enable(); }
|
||||
catch (Exception ex) { Log.Error(ex, "plugin enable failed: {Id}", plugin.Manifest.Id); }
|
||||
}
|
||||
|
||||
using var window = new GameWindow(datDir);
|
||||
window.Run();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue