Conversation
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
|
@copilot pull latest changes, resolve merge conflicts, and check if this builds still |
…tor-azure-mcp-tools-pricing Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Done — merged latest |
There was a problem hiding this comment.
Pull request overview
Refactors the Pricing tool command to use constructor-based dependency injection for IPricingService instead of resolving it from CommandContext at execution time, improving testability and aligning with DI patterns used across the toolset.
Changes:
- Inject
IPricingServiceintoPricingGetCommandvia constructor and use the injected field inExecuteAsync. - Update unit tests to construct
PricingGetCommandwith the mockedIPricingService.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Pricing/src/Commands/PricingGetCommand.cs | Switches from context.GetService<IPricingService>() to constructor-injected _pricingService. |
| tools/Azure.Mcp.Tools.Pricing/tests/Azure.Mcp.Tools.Pricing.UnitTests/PricingGetCommandTests.cs | Updates command construction to pass _pricingService into the new constructor. |
There was a problem hiding this comment.
Convention-aligned mechanical DI refactor. Matches the pattern from the reference PR (#1815, AppConfig) and every sibling DI refactor merged since: ManagedLustre (#2063), Marketplace (#2064), Kusto (#2061), KeyVault (#2060), LoadTesting (#2062), FoundryExtensions (#1990), Grafana (#1992), AppService (#1900), FunctionApp (#1991), Extension (#1988), Compute (#1914), AzureMigrate (#1909), AzureIsv (#1902), Authorization (#1901). Field naming (_pricingService), primary-constructor shape, and the 1:1 test rewiring all line up.
On the null-guard suggestion from the earlier review: the established Azure.Mcp.Tools command convention is plain assignment without ?? throw new ArgumentNullException. A grep across tools/Azure.Mcp.Tools.*/src/Commands/**/*Command.cs shows 0 of 54 DI-injected service fields use the guard pattern. The 19 files that do use it are all in Fabric.Mcp.Tools.OneLake, a separate toolset with its own conventions. Following the majority pattern here is correct.
No new findings. The failing build checks are the repo-wide NU1903 transitive vulnerability on System.Security.Cryptography.Xml 10.0.0 and reproduce on main, so they aren't caused by this PR.
PricingGetCommandresolvesIPricingServiceviacontext.GetService<T>()inExecuteAsyncIPricingServiceconstructor parameter toPricingGetCommandand store as private fieldcontext.GetService<IPricingService>()with the injected_pricingServicefield_pricingServiceto thePricingGetCommandconstructormain— no conflicts, build succeeds, all 15 tests still passInvoking Livetests
Copilot submitted PRs are not trustworthy by default. Users with
writeaccess to the repo need to validate the contents of this PR before leaving a comment with the text/azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.Original prompt
💡 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.