Skip to content

Commit f373cd1

Browse files
committed
fix: Defer plugin loading to avoid circular dependency
1 parent 8c4dc68 commit f373cd1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

managed/src/SwiftlyS2.Core/Hosting/PluginManagerInjection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public static IServiceCollection AddPluginManager( this IServiceCollection self
1313

1414
public static void UsePluginManager( this IServiceProvider self )
1515
{
16-
_ = self.GetRequiredService<PluginManager>();
16+
self.GetRequiredService<PluginManager>().Initialize();
1717
}
1818
}

managed/src/SwiftlyS2.Core/Modules/Plugins/PluginManager.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,13 @@ static async Task WaitForFileAccess( CancellationToken token, string filePath, i
150150
? Assembly.GetExecutingAssembly()
151151
: AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => loadingAssemblyName == a.GetName().Name);
152152
};
153+
}
153154

155+
/// <summary>
156+
/// Must be called after DI container is fully built to avoid circular dependency.
157+
/// </summary>
158+
internal void Initialize()
159+
{
154160
LoadExports();
155161
LoadPlugins();
156162
}

0 commit comments

Comments
 (0)