DI Refactor: Azure.Mcp.Tools.Marketplace#2064
Merged
alzimmermsft merged 2 commits intomainfrom Mar 17, 2026
Merged
Conversation
…Command and ProductListCommand Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [microsoft/mcp#158] Refactor Azure.Mcp.Tools.Marketplace for DI
DI Refactor: Azure.Mcp.Tools.Marketplace
Mar 16, 2026
conniey
approved these changes
Mar 17, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the Marketplace tool commands to use constructor dependency injection for IMarketplaceService rather than resolving it from CommandContext during execution, improving explicitness and testability as part of the broader DI refactor effort.
Changes:
- Inject
IMarketplaceServiceintoProductGetCommandandProductListCommandvia primary constructors. - Remove
context.GetService<IMarketplaceService>()usage fromExecuteAsync. - Update unit tests to pass the mocked
IMarketplaceServicedirectly into command constructors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Marketplace/src/Commands/Product/ProductGetCommand.cs | Switches product “get” command to constructor-injected IMarketplaceService and uses it in ExecuteAsync. |
| tools/Azure.Mcp.Tools.Marketplace/src/Commands/Product/ProductListCommand.cs | Switches product “list” command to constructor-injected IMarketplaceService and uses it in ExecuteAsync. |
| tools/Azure.Mcp.Tools.Marketplace/tests/Azure.Mcp.Tools.Marketplace.UnitTests/Product/ProductGetCommandTests.cs | Updates tests to construct the command with a mocked IMarketplaceService instead of registering it in the service collection. |
| tools/Azure.Mcp.Tools.Marketplace/tests/Azure.Mcp.Tools.Marketplace.UnitTests/Product/ProductListCommandTests.cs | Updates tests to construct the command with a mocked IMarketplaceService instead of registering it in the service collection. |
You can also share your feedback on Copilot code review. Take the survey.
alzimmermsft
approved these changes
Mar 17, 2026
6 tasks
colbytimm
pushed a commit
to colbytimm/microsoft-mcp
that referenced
this pull request
Apr 20, 2026
* Initial plan * DI refactor: inject IMarketplaceService via constructor in ProductGetCommand and ProductListCommand Co-authored-by: conniey <10136526+conniey@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
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.
Part of the broader DI refactor (#158):
ProductGetCommandandProductListCommandwere resolvingIMarketplaceServicelazily viacontext.GetService<T>()insideExecuteAsyncinstead of using constructor injection.Changes
ProductGetCommand/ProductListCommand: AddedIMarketplaceServiceas a constructor parameter; removed runtimecontext.GetService<IMarketplaceService>()calls.Original prompt
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.