Skip to content

Add ExtensionLoader with DI support for assembly-scanned plugin extensions#257

Merged
michaelbeale-IL merged 2 commits into
masterfrom
copilot/update-extension-loader-di
Feb 23, 2026
Merged

Add ExtensionLoader with DI support for assembly-scanned plugin extensions#257
michaelbeale-IL merged 2 commits into
masterfrom
copilot/update-extension-loader-di

Conversation

Copilot AI commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

TypeLoader<T> and ExtensionInstantiator existed independently with no unified entry point that tied assembly scanning, DI-aware instantiation, and service-container registration together. This adds ExtensionLoader<TExtension> to close that gap.

New types

  • IExtensionLoader<TExtension> — interface exposing LoadFromAssembly, LoadFromAssemblies, CreateInstance(Guid), CreateAllInstances(), and RegisterExtensions(IServiceCollection, ServiceLifetime)
  • ExtensionLoader<TExtension> — concrete implementation; wraps TypeLoader<TExtension> for discovery and ActivatorUtilities.CreateInstance so extension constructors receive registered services automatically

DI registration

Added AddExtensionLoader<TExtension>() to ServiceCollectionExtensions, registered as singleton:

services.AddExtensionLoader<IMyExtension>();

// Later, or at startup:
var loader = provider.GetRequiredService<IExtensionLoader<IMyExtension>>();
loader.LoadFromAssembly(path);

// Create instances with full DI resolution
var instances = loader.CreateAllInstances();

// Or register discovered types back into a service collection
loader.RegisterExtensions(services, ServiceLifetime.Transient);

RegisterExtensions registers each discovered type under both its concrete type and TExtension, enabling IEnumerable<TExtension> resolution from the container.

Tests

Added 8 tests to ExtensionLoadingIntegrationTests covering: constructor null-guard, empty state, CreateInstance with unknown GUID, CreateAllInstances with no types, RegisterExtensions null-guard and no-op paths, singleton lifetime via AddExtensionLoader, and interface implementation verification.

Original prompt

This section details on the original issue you should resolve

<issue_title>Extension Loading with DI</issue_title>
<issue_description>Update ExtensionLoader to use IServiceProvider and register extensions in service container.

Acceptance Criteria:

  • ExtensionLoader receives IServiceProvider
  • Extensions registered with proper lifetimes
  • Extension dependencies resolved through DI
  • Extension initialization updated
  • Tests for extension loading
  • Documentation updated

Technical Details:

  • Pass IServiceProvider to extension constructors
  • Register extension types in container
  • Support for extension dependencies
  • Proper disposal of scoped services

Files to Modify:

  • Libraries/ACATCore/Utility/TypeLoader/ExtensionLoader.cs
  • Extension base classes
  • Extension registration code

Epic: Dependency Injection Infrastructure

Estimated Effort: 3 days


Parent Feature: #190 - Dependency Injection Infrastructure

</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…, tests, registration)

Co-authored-by: michaelbeale-IL <63321611+michaelbeale-IL@users.noreply.github.com>
Copilot AI changed the title [WIP] Update ExtensionLoader to use IServiceProvider for DI Add ExtensionLoader with DI support for assembly-scanned plugin extensions Feb 23, 2026
@michaelbeale-IL michaelbeale-IL marked this pull request as ready for review February 23, 2026 17:46
@michaelbeale-IL michaelbeale-IL merged commit 6bc55bf into master Feb 23, 2026
2 checks passed
@michaelbeale-IL michaelbeale-IL deleted the copilot/update-extension-loader-di branch February 23, 2026 17:49
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.

Extension Loading with DI

2 participants