Skip to content

Comments

Cross-plugin dependency fix#9

Merged
ced777ric merged 1 commit intonorthwood-studios:devfrom
Axwabo:dev
Feb 12, 2025
Merged

Cross-plugin dependency fix#9
ced777ric merged 1 commit intonorthwood-studios:devfrom
Axwabo:dev

Conversation

@Axwabo
Copy link
Contributor

@Axwabo Axwabo commented Feb 12, 2025

Cross-plugin dependency fix

This PR fixes an issue where plugins would not load if they referenced another plugin that was not yet loaded.

The problem:

Assume the following scenario:

The following plugins are to be loaded:

  • PluginA
  • PluginB
  • PluginC

Both PluginA and PluginC depend on PluginB. PluginB has no dependencies.

  1. PluginA's assembly is loaded.
  2. The loader attempts to initialize PluginA, but fails because the dependency PluginB is not yet found.
  3. PluginB's assembly is loaded and initialized.
  4. PluginC is loaded and starts without any issues.

Changes:

  • Upon loading of a plugin assembly, it is not checked for missing dependencies nor plugins.
  • The list of plugin assemblies is iterated over:
    • The assembly is checked for missing dependencies.
    • If all dependencies are loaded, plugins are instantiated and registered like before. This loop has been extracted to a separate method for reduced complexity.

This way, a plugin can reference another that comes after it alphabetically and will still be initialized correctly.

Moved plugin type checking & loading to a separate loop in PluginLoader::LoadPlugins.
Extracted the plugin instantiating and registering loop to a separate method InstantiatePlugins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants