Skip to content

DI Refactor: Azure.Mcp.Tools.AppLens#1884

Open
Copilot wants to merge 3 commits intomainfrom
copilot/refactor-app-lens-dependency-injection
Open

DI Refactor: Azure.Mcp.Tools.AppLens#1884
Copilot wants to merge 3 commits intomainfrom
copilot/refactor-app-lens-dependency-injection

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

  • Understand the DI refactor pattern from the example PR AppConfig: Remove usage of ServiceProvider in ExecuteAsync. #1815
  • Refactor ResourceDiagnoseCommand to inject IAppLensService via constructor instead of context.GetService<T>()
  • Update ResourceDiagnoseCommandTests to pass IAppLensService to the command constructor
  • Build and tests pass (17/17)
  • Add changelog entry with correct PR number (1884)
Original prompt

This section details on the original issue you should resolve

<issue_title>DI Refactor: Azure.Mcp.Tools.AppLens</issue_title>
<issue_description>## Summary

Refactor Azure.Mcp.Tools.AppLens to use constructor dependency injection instead of resolving services via context.GetService<T>() in ExecuteAsync.

This is a sub-issue of #158.

Instructions

Follow the algorithm described in tools/di-refactor-plan.md with {ToolArea} = AppLens.

An example PR is: #1815</issue_description>

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…tructor

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor Azure.Mcp.Tools.AppLens for dependency injection DI Refactor: Azure.Mcp.Tools.AppLens Feb 27, 2026
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
@conniey conniey marked this pull request as ready for review March 2, 2026 20:33
@conniey conniey requested a review from msalaman as a code owner March 2, 2026 20:33
Copilot AI review requested due to automatic review settings March 2, 2026 20:33
@conniey conniey requested review from a team as code owners March 2, 2026 20:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the AppLens tool’s ResourceDiagnoseCommand to follow the repo’s DI pattern by making IAppLensService an explicit constructor dependency (instead of resolving it from CommandContext), improving testability and reducing runtime coupling to ServiceProvider.

Changes:

  • Inject IAppLensService into ResourceDiagnoseCommand via primary constructor and use the injected field in ExecuteAsync.
  • Update ResourceDiagnoseCommandTests to construct the command with a mocked IAppLensService.
  • Add a changelog entry documenting the AppLens DI/testability improvement.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tools/Azure.Mcp.Tools.AppLens/src/Commands/Resource/ResourceDiagnoseCommand.cs Removes context.GetService<IAppLensService>() usage and uses constructor-injected IAppLensService.
tools/Azure.Mcp.Tools.AppLens/tests/Azure.Mcp.Tools.AppLens.UnitTests/Resource/ResourceDiagnoseCommandTests.cs Updates unit tests to pass IAppLensService into the command constructor.
servers/Azure.Mcp.Server/changelog-entries/1772200000001.yaml Adds changelog entry for the AppLens DI refactor (PR 1884).

@github-project-automation github-project-automation bot moved this from Untriaged to In Progress in Azure MCP Server Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

DI Refactor: Azure.Mcp.Tools.AppLens

5 participants