Base interfaces for RuntimePluggableClassFactory including IPluginClass and ITypedPluginClass<TInput, TOutput> for type-safe plugin development. Provides strongly-typed plugin interfaces, execution context, and result types for building dynamic plugin systems.
$ dotnet add package DevelApp.RuntimePluggableClassFactory.InterfaceA comprehensive .NET library for dynamic plugin loading, execution, and management with enhanced stability, type safety, and security features.
This project has been enhanced with a complete Technical Design Specification (TDS) implementation featuring:
See TDS_IMPLEMENTATION.md for complete implementation details.
ITypedPluginClass<TInput, TOutput>using DevelApp.RuntimePluggableClassFactory;
using DevelApp.RuntimePluggableClassFactory.FilePlugin;
using DevelApp.RuntimePluggableClassFactory.Security;
// Create plugin loader with security validation
var securityValidator = new DefaultPluginSecurityValidator(PluginSecuritySettings.CreateDefault());
var pluginLoader = new FilePluginLoader<IMyPluginInterface>(pluginDirectory, securityValidator);
var pluginFactory = new PluginClassFactory<IMyPluginInterface>(pluginLoader);
// Load and execute plugins
await pluginFactory.RefreshPluginsAsync();
var plugin = pluginFactory.GetInstance("MyModule", "MyPlugin");
var result = plugin.Execute("input data");
// Cleanup
pluginLoader.UnloadAllPlugins();
// Define strongly-typed input/output
public class MyInput { public string Data { get; set; } }
public class MyOutput { public string Result { get; set; } }
// Create typed plugin factory
var typedFactory = new TypedPluginClassFactory<IMyTypedPlugin, MyInput, MyOutput>(pluginLoader);
// Execute with type safety
var input = new MyInput { Data = "test" };
var result = typedFactory.ExecutePlugin("MyModule", "MyPlugin", input);
if (result.Success)
{
Console.WriteLine($"Result: {result.Data.Result}");
}
public interface IMyPluginInterface : IPluginClass
{
// Custom execution method for this specific interface
string ProcessData(string input);
}
public class MyPlugin : IMyPluginInterface
{
// Implement IPluginClass properties
public IdentifierString Name => "MyPlugin";
public NamespaceString Module => "MyModule";
public string Description => "Example plugin implementation";
public SemanticVersionNumber Version => new SemanticVersionNumber(1, 0, 0);
public string ProcessData(string input)
{
return $"Processed: {input}";
}
}
public interface IMyTypedPlugin : ITypedPluginClass<MyInput, MyOutput>
{
// Inherits both IPluginClass and ITypedPluginClass methods
}
public class MyTypedPlugin : IMyTypedPlugin
{
// Implement IPluginClass properties
public IdentifierString Name => "MyTypedPlugin";
public NamespaceString Module => "MyModule";
public string Description => "Example typed plugin implementation";
public SemanticVersionNumber Version => new SemanticVersionNumber(1, 0, 0);
public PluginExecutionResult<MyOutput> Execute(IPluginExecutionContext context, MyInput input)
{
context?.Logger?.LogInformation($"Processing: {input.Data}");
return PluginExecutionResult<MyOutput>.CreateSuccess(new MyOutput
{
Result = $"Processed: {input.Data}"
});
}
}
The project includes comprehensive testing with 48 tests across 7 categories:
# Run all tests
dotnet test
# Expected: 48 tests passing
// Default security (balanced)
var defaultSettings = PluginSecuritySettings.CreateDefault();
// Strict security (high security)
var strictSettings = PluginSecuritySettings.CreateStrict();
// Permissive security (minimal restrictions)
var permissiveSettings = PluginSecuritySettings.CreatePermissive();
var validator = new DefaultPluginSecurityValidator(strictSettings);
All performance targets are validated by automated tests:
| Metric | Target | Status |
|---|---|---|
| Plugin Discovery | < 5 seconds | ✅ Validated |
| Plugin Instantiation | < 100ms avg | ✅ Validated |
| Plugin Execution | < 10ms avg | ✅ Validated |
| Concurrent Throughput | > 100 exec/sec | ✅ Validated |
| Security Validation | < 500ms avg | ✅ Validated |
| Memory Growth | < 50MB under load | ✅ Validated |
IPluginClass: Basic plugin interfaceITypedPluginClass<TInput, TOutput>: Type-safe plugin interfaceIPluginLoader<T>: Plugin loading interfaceIPluginSecurityValidator: Security validation interfaceIContainerizedPluginOrchestrator (v2.1.0+): Interface for containerized plugin orchestrationThe HybridPluginFactory enables seamless mixing of traditional in-process plugins with containerized plugins loaded from Kubernetes or other remote sources:
using DevelApp.RuntimePluggableClassFactory.Containerized;
using DevelApp.RuntimePluggableClassFactory.Containerized.Interfaces;
// Setup traditional plugin loader
var traditionalLoader = new FilePluginLoader<IMyPlugin>(pluginDirectory, securityValidator);
var traditionalFactory = new PluginClassFactory<IMyPlugin>(traditionalLoader);
// Setup containerized plugin orchestrator (e.g., Kubernetes)
var containerizedOrchestrator = new KubernetesPluginOrchestrator(/* ... */);
// Create hybrid factory
var hybridFactory = new HybridPluginFactory<IMyPlugin>(
traditionalFactory,
containerizedOrchestrator,
logger,
new HybridPluginFactoryOptions
{
PreferContainerized = true,
AutoDeployContainerized = false
});
// Load plugins from either source
var plugin = await hybridFactory.GetPluginAsync(
new NamespaceString("MyCompany.Plugins"),
new IdentifierString("DataProcessor"),
version: new SemanticVersionNumber(1, 0, 0),
executionMode: PluginExecutionMode.Auto);
// List all available plugins
var availablePlugins = await hybridFactory.ListAvailablePluginsAsync();
foreach (var pluginInfo in availablePlugins)
{
Console.WriteLine($"{pluginInfo.ModuleName}.{pluginInfo.PluginName} ({pluginInfo.ExecutionMode})");
}
The following types are now exposed in the public API for implementing custom async module-based plugin loading:
These types enable dynamic module loading from Kubernetes/remote sources as an alternative to traditional directory-based scanning.
# Clone repository
git clone https://github.com/DevelApp-ai/RuntimePluggableClassFactory.git
# Build solution
dotnet build RuntimePluggableClassFactory.sln
# Run tests
dotnet test
This project is licensed under the MIT License - see the LICENSE file for details.
For questions, issues, or support:
TDS Implementation Status: ✅ Complete - All requirements implemented and validated