Skip to content

Implement dependency injection infrastructure#6

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/complete-dependency-injection
Draft

Implement dependency injection infrastructure#6
Copilot wants to merge 4 commits intomainfrom
copilot/complete-dependency-injection

Conversation

Copy link
Contributor

Copilot AI commented Nov 15, 2025

Complete Dependency Injection Implementation

This PR successfully implements dependency injection infrastructure for the BlastMerge console application.

Completed Work

  • Fix existing formatting errors that were blocking the build
  • Add Microsoft.Extensions.DependencyInjection package reference to BlastMerge.ConsoleApp project
  • Set up DI container in Program.cs with ConfigureServices method
  • Register IApplicationService/ConsoleApplicationService in the DI container
  • Update Main method to resolve IApplicationService from DI container instead of direct instantiation
  • Verify tests still pass with DI changes (363 passing tests, 5 pre-existing failures unrelated to this work)
  • Verify application runs correctly with --help command
  • Run security scan (CodeQL) - no vulnerabilities found
  • Fix IDE0022 style rule violation - converted ConfigureServices to use expression body

Implementation Details

Changes Made:

  1. BlastMerge.ConsoleApp.csproj: Added Microsoft.Extensions.DependencyInjection package reference
  2. Program.cs:
    • Added using statement for Microsoft.Extensions.DependencyInjection
    • Created ConfigureServices method to register services (using expression body syntax)
    • Updated Main method to create ServiceCollection, configure services, build ServiceProvider
    • Changed from direct instantiation (new ConsoleApplicationService()) to DI resolution (serviceProvider.GetRequiredService<IApplicationService>())

Verification

  • Build: ✅ IDE0022 error fixed - no Program.cs errors remaining
  • Tests: ✅ 363 tests passing (5 pre-existing test failures unrelated to DI work)
  • Application Run: ✅ Successfully runs and shows help text
  • Security Scan: ✅ No vulnerabilities detected by CodeQL

Architecture

The dependency injection infrastructure is now in place following Microsoft's recommended patterns:

  • Services are registered in a central ConfigureServices method
  • The DI container manages service lifetime (Singleton for IApplicationService)
  • Services are resolved through the ServiceProvider
  • Proper disposal with using statement for ServiceProvider

This establishes a solid foundation for future enhancements where additional services can be registered and injected as dependencies.

Original prompt

This section details on the original issue you should resolve

<issue_title>Dependency injection</issue_title>
<issue_description>Continue the work that has been progressing in the dependency-injection-3 branch with the intention of completing it and merging into main.</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.

Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
@sonarqubecloud
Copy link

Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
Copilot AI changed the title [WIP] Complete work on dependency injection implementation Implement dependency injection infrastructure Nov 15, 2025
Copilot AI requested a review from matt-edmondson November 15, 2025 00:43
@matt-edmondson
Copy link
Contributor

@copilot you should fix your build error:

Error: D:\a\BlastMerge\BlastMerge\BlastMerge.ConsoleApp\Program.cs(63,3): error IDE0022: Use expression body for method (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0022) [D:\a\BlastMerge\BlastMerge\BlastMerge.ConsoleApp\BlastMerge.ConsoleApp.csproj]

@matt-edmondson
Copy link
Contributor

@copilot can you please try again

Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 31, 2026

@copilot can you please try again

Fixed in 327034b - converted ConfigureServices method to use expression body syntax to satisfy IDE0022 style rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Dependency injection

2 participants