Skip to content

Comments

IsAbstract plugin check + separate embedded dependency resolving pass#212

Merged
Jesus-QC merged 5 commits intonorthwood-studios:devfrom
Axwabo:dev
Sep 9, 2025
Merged

IsAbstract plugin check + separate embedded dependency resolving pass#212
Jesus-QC merged 5 commits intonorthwood-studios:devfrom
Axwabo:dev

Conversation

@Axwabo
Copy link
Contributor

@Axwabo Axwabo commented Jul 10, 2025

This PR allows the definition of abstract plugin types, and fixes the scenario where a plugin's embedded DLLs would be loaded after another dependent plugin attempted enabling.

  • Plugin assemblies can now define abstract plugin types, allowing them to be inherited
  • Created a separate pass for dependency resolving (relates to Cross-plugin dependency fix #9)

The current dependency problem:

Assume the following scenario:

The following plugins are to be loaded:

  • PluginA
  • PluginB
  • PluginC

Both PluginA and PluginC depend on an external dependency Dependency
PluginB includes Dependency as an embedded resource.

  1. PluginA's assembly is loaded.
  2. The loader attempts to initialize PluginA, but might fail because Dependency is not loaded, unless if Dependency included separately in LabAPI's dependencies folder.
  3. PluginB's assembly is loaded, Dependency is extracted, PluginB loads.
  4. PluginC's assembly is loaded, the plugin is initialized without issues.

Failure also occurs if PluginB does not have missing dependencies (e.g. it does not depend on Dependency while including it as embedded) but PluginC depends on Dependency (PluginB did not resolve embedded resources because it had no missing dependencies).

Changes:

  • Added a check to skip loading abstract Plugin types.
  • The AssemblyUtils class has been modified to load an embedded resource only if no assembly with the same name has been loaded yet. This affects the methods ResolveEmbeddedResources LoadEmbeddedDll LoadCompressedEmbeddedDll
  • Added a check to skip loading abstract Plugin types.
  • After the plugin assemblies are loaded, the list of assemblies is iterated over:
    • Dependencies are checked, any embedded resource DLLs are extracted and loaded.
    • After all assemblies have been checked for dependencies, another loop loads the plugins.

This way, a plugin can reference dependencies that another plugin includes as embedded resources.

Axwabo added 2 commits July 6, 2025 14:45
Added a condition to skip abstract classes when instantiating plugins.
Added a loop between plugin assembly loading and instantiation that resolves embedded DLLs.
Modified `AssemblyUtils::GetMissingDependencies` to create a set of the loaded assemblies.
Changed the `LoadEmbeddedDll` and `LoadCompressedEmbeddedDll` methods in `AssemblyUtils` class to write resolved the assembly to a temporary file, load the DLL if no assembly with the same name has been loaded. The file is deleted after this operation.
@LumiFae
Copy link
Member

LumiFae commented Jul 10, 2025

finally... it is here...

Copy link
Collaborator

@davidsebesta1 davidsebesta1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

Moved private methods in AssemblyUtils & PluginLoader to the end of the file.
Made the LINQ selectors in `LogMissingDependencies` and `GetLoadedAssemblies` static.
Removed the `ToArray` call and made the variable an `IEnumerable<string>` in `LogMissingDependencies` to improve performance.
Co-authored-by: Jesus QC <69375249+Jesus-QC@users.noreply.github.com>
@Axwabo
Copy link
Contributor Author

Axwabo commented Aug 29, 2025

@Jesus-QC Should embedded DLLs also be added to the PluginLoader.Dependencies set?

@Jesus-QC
Copy link
Contributor

@Jesus-QC Should embedded DLLs also be added to the PluginLoader.Dependencies set?

Yeah

VALERA771 pushed a commit to VALERA771/LabAPI that referenced this pull request Sep 8, 2025
* Yaml converters for Vector3 and Color

* Accepts color fix + added converters to the builder

* Vector2, 3 and 4 converter, Color32 converter, extensions for yaml and such

* Docs fixes
@Jesus-QC Jesus-QC merged commit d250b1a into northwood-studios:dev Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants