Skip to content

Remove Autofac dependency — use reflection for IDay discovery#53

Merged
ianfnelson merged 2 commits intomainfrom
copilot/bump-autofac-dependency
Mar 18, 2026
Merged

Remove Autofac dependency — use reflection for IDay discovery#53
ianfnelson merged 2 commits intomainfrom
copilot/bump-autofac-dependency

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

Autofac was only used for assembly scanning to discover IDay implementations. Since none have constructor dependencies, a DI container is unnecessary.

  • Removed Autofac package reference from AdventOfCode.csproj
  • Replaced ContainerBuilder/Resolve in Program.cs with plain reflection:
var days = Assembly.GetExecutingAssembly()
    .GetTypes()
    .Where(t => t is { IsClass: true, IsAbstract: false } && typeof(IDay).IsAssignableFrom(t))
    .Select(t => (IDay)Activator.CreateInstance(t)!);

All 182 tests pass. No other files reference Autofac.


💡 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.

Remove Autofac NuGet dependency and replace the DI container usage in
Program.cs with simple reflection to discover and instantiate IDay
implementations. Since none of the Day classes have constructor
dependencies, a DI container is unnecessary.

Co-authored-by: ianfnelson <205606+ianfnelson@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Autofac dependency in project Remove Autofac dependency — use reflection for IDay discovery Mar 16, 2026
Copilot AI requested a review from ianfnelson March 16, 2026 22:48
@ianfnelson ianfnelson marked this pull request as ready for review March 17, 2026 16:57
@ianfnelson ianfnelson merged commit e83f25d into main Mar 18, 2026
1 check passed
@ianfnelson ianfnelson deleted the copilot/bump-autofac-dependency branch March 18, 2026 15:32
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.

2 participants