How jpdante/corepluginloader works
Main Components
• Core Plugin Loader Library – This is the core .NET library (located in the CorePluginLoader folder) that implements the main API. It contains key classes such as PluginLoader and PluginLoaderBase.
• Host Application – This component (illustrated by the Examples/Basic/HostApplication project and the Testing/Host application in Testing/CorePluginLoader.Testing) demonstrates how a host uses the plugin loader. It contains the entry point (Program.cs) and the interface IPlugin, which defines the plugin contract.
• Plugin Projects – These are the dynamic libraries (e.g., Examples/Basic/Plugin and the Testing/CorePluginLoader.Testing.Plugin1/Plugin1.cs & Plugin2.cs) that implement the IPlugin interface. They illustrate how plugins are constructed and loaded.
• Testing Suite – A dedicated directory that not only includes plugin examples but also the test harness (found in Testing/CorePluginLoader.Testing) to verify the integration and behavior of the dynamic plugin loading mechanism.
Relationships and Interactions
• The Host Application component calls into the Core Plugin Loader Library, instantiating a PluginLoader for a given interface (IPlugin).
• The PluginLoader then dynamically loads plugin assemblies from specified directories (using, for example, Directory.GetFiles with a "*.dll" search).
• Loaded plugin instances (which conform to the IPlugin interface) then interact with the Host Application, typically by invoking their PluginName properties or other exposed methods.
• The Testing components mimic these interactions to ensure that different plugins (as demonstrated in Plugin1 and Plugin2) are correctly loaded and can interact within the same memory space as the Host.
Architectural Patterns and Design Principles
• Shared Memory Model – Note that the library is designed to allow shared memory between the Host and Plugins, as opposed to isolating them (this is a key design principle noted in the README). This enables plugins to interact and call methods across each other easily.
• Separation of Concerns – Although the host, plugin, and loader are part of the same solution architecture, each holds well-defined responsibilities (the Core Plugin Loader handles plugin resolution, the Host manages application logic, and the Plugins encapsulate the extendable functionality).
Recommend Technologies and Tools
• .NET Core – Highlight that the system is built using .NET Core.
• NuGet Package (CorePluginLoader) – Represent that developers can install the library via NuGet and integrate it into their projects.
Elements
• Clear labels for each component: “CorePluginLoader Library”, “Host Application”, “Plugin (Example/Basic)”, “Plugin (Testing/Plugin1 & Plugin2)”, and “Testing Suite”.
• If needed, include annotations that describe some specific methods or interactions (like the call to LoadPlugins and shared memory design).