Open
Conversation
…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
conniey
reviewed
Mar 2, 2026
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
conniey
approved these changes
Mar 2, 2026
Contributor
There was a problem hiding this comment.
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
IAppLensServiceintoResourceDiagnoseCommandvia primary constructor and use the injected field inExecuteAsync. - Update
ResourceDiagnoseCommandTeststo construct the command with a mockedIAppLensService. - 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). |
joshfree
approved these changes
Mar 3, 2026
xiangyan99
approved these changes
Mar 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ResourceDiagnoseCommandto injectIAppLensServicevia constructor instead ofcontext.GetService<T>()ResourceDiagnoseCommandTeststo passIAppLensServiceto the command constructorOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.