Skip to content

Migrate repository DI wiring from Castle Windsor to Microsoft.Extensions.DependencyInjection#71

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/change-castle-windsor-to-ms-di
Draft

Migrate repository DI wiring from Castle Windsor to Microsoft.Extensions.DependencyInjection#71
Copilot wants to merge 5 commits intomainfrom
copilot/change-castle-windsor-to-ms-di

Conversation

Copy link

Copilot AI commented Mar 9, 2026

This change replaces Castle Windsor-based dependency injection in MarsUndiscovered with Microsoft.Extensions.DependencyInjection. The migration preserves existing runtime/test composition patterns, including typed-factory behavior and property-injected components used across game/view models and commands.

  • Container bootstrap migration (app + tests)

    • Switched Program and integration test setup from WindsorContainer to ServiceCollection/ServiceProvider.
    • Updated installer invocation model to Install(IServiceCollection) across local installers.
  • Installer conversion to MS DI

    • Rewrote MarsUndiscoveredInstaller and GameInstaller to register services via IServiceCollection.
    • Replaced Windsor registration constructs (Component.For, AsFactory, DependsOn, default components) with explicit MS DI registrations and assembly-scanned self/interface registration where needed.
    • Preserved default null handlers for keyboard/mouse interface resolution.
  • Typed factory replacement

    • Added DI-native factory implementations to replace Windsor AsFactory:
      • CommandFactory<T>
      • ServiceFactory<T>
      • MapTileEntityFactory
      • FieldOfViewTileEntityFactory
    • Updated GameObjectFactory to resolve game objects via IServiceProvider + constructor parameters.
  • Property injection compatibility

    • Added ServiceProviderFactoryExtensions to construct instances with constructor args and inject settable properties post-construction.
    • Included per-type property metadata caching to avoid repeated reflection scans.
  • Castle namespace cleanup

    • Removed residual Castle utility imports/usages in non-DI code paths to fully decouple local code from Castle packages.

Example of the new composition model:

var services = new ServiceCollection();

new CoreInstaller().Install(services);
new GameInstaller().Install(services);
new ViewInstaller().Install(services);
new MarsUndiscoveredInstaller().Install(services);

services.AddSingleton(options);

using var provider = services.BuildServiceProvider();
using var game = provider.GetRequiredService<IGame>();
game.Run();
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)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits March 9, 2026 21:22
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 repository DI wiring from Castle Windsor 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