Skip to content

Migrate Castle Windsor DI wiring to Microsoft.Extensions.DependencyInjection#24

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/change-windsor-to-ms-di
Draft

Migrate Castle Windsor DI wiring to Microsoft.Extensions.DependencyInjection#24
Copilot wants to merge 4 commits into
mainfrom
copilot/change-windsor-to-ms-di

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 9, 2026

This PR replaces Castle Windsor-based dependency injection in core/view composition code with Microsoft DI, while preserving existing registration intent and mediator behavior. It also removes Castle-specific reflection helpers used for attribute discovery.

  • DI container migration (Core + View)

    • Reworked installers to register services via IServiceCollection instead of Windsor container APIs.
    • Replaced Windsor component registrations with AddTransient / AddSingleton / TryAddTransient.
    • Updated both core and view project dependencies to remove Castle packages and add Microsoft.Extensions.DependencyInjection.
  • Mediator composition update

    • Removed IKernel property injection and Windsor resolve/release usage.
    • Registered ServiceFactory via IServiceProvider and updated Mediator to use constructor injection.
  • Convention registration contributors

    • Replaced Windsor IContributeComponentModelConstruction contributors with assembly-scanning registration helpers for:
      • IRequestHandler<T>
      • INotificationHandler<T>
      • IScreen implementations
    • Added loadable-type fallback handling for partial type-load scenarios (ReflectionTypeLoadException).
  • Castle reflection helper removal

    • Replaced GetAttributes<T>() (Castle.Core.Internal) with standard reflection GetCustomAttributes<T>() in action-map and console-command attribute discovery paths.
    • Updated ConsoleCommandServiceFactory to consume IEnumerable<IConsoleCommand> for MS DI compatibility.
  • Focused unit coverage

    • Added mediator tests validating:
      • Send dispatches to request handler
      • Publish dispatches to all notification handlers
// New ServiceFactory registration pattern
services.AddTransient<ServiceFactory>(sp => type =>
{
    if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
        return sp.GetServices(type.GetGenericArguments()[0]);

    return sp.GetRequiredService(type);
});
Original prompt

This section details on the original issue you should resolve

<issue_title>Change Castle Windsor Dependency Injection to MS Dependency Injection</issue_title>
<issue_description></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.

Copilot AI and others added 3 commits March 9, 2026 21:23
…rosoft DI

Co-authored-by: DavidFidge <2329907+DavidFidge@users.noreply.github.com>
Co-authored-by: DavidFidge <2329907+DavidFidge@users.noreply.github.com>
Co-authored-by: DavidFidge <2329907+DavidFidge@users.noreply.github.com>
Copilot AI changed the title [WIP] Change Castle Windsor dependency injection to MS dependency injection Migrate Castle Windsor DI wiring to Microsoft.Extensions.DependencyInjection Mar 9, 2026
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.

Change Castle Windsor Dependency Injection to MS Dependency Injection

2 participants