Skip to content

DI Refactor: Azure.Mcp.Tools.Pricing#2080

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/mcp-158-refactor-azure-mcp-tools-pricing
Draft

DI Refactor: Azure.Mcp.Tools.Pricing#2080
Copilot wants to merge 2 commits intomainfrom
copilot/mcp-158-refactor-azure-mcp-tools-pricing

Conversation

Copy link
Contributor

Copilot AI commented Mar 17, 2026

PricingGetCommand was resolving IPricingService at call-time via context.GetService<T>() rather than through constructor injection, inconsistent with the project-wide DI refactor (#158).

Changes

  • PricingGetCommand: Added IPricingService constructor parameter; replaced context.GetService<IPricingService>() with injected _pricingService field
// Before
public sealed class PricingGetCommand(ILogger<PricingGetCommand> logger) : ...
{
    // In ExecuteAsync:
    var pricingService = context.GetService<IPricingService>();
    var prices = await pricingService.GetPricesAsync(...);
}

// After
public sealed class PricingGetCommand(ILogger<PricingGetCommand> logger, IPricingService pricingService) : ...
{
    private readonly IPricingService _pricingService = pricingService;
    // In ExecuteAsync:
    var prices = await _pricingService.GetPricesAsync(...);
}
  • PricingGetCommandTests: Updated all PricingGetCommand constructor calls to pass _pricingService directly; PricingSetup.cs required no changes as IPricingService and PricingGetCommand were already registered as singletons.
Original prompt

This section details on the original issue you should resolve

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

Refactor Azure.Mcp.Tools.Pricing 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} = Pricing.

An example PR is: #1815
</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: conniey <10136526+conniey@users.noreply.github.com>
Copilot AI changed the title [WIP] [microsoft/mcp#158] Refactor Azure.Mcp.Tools.Pricing for DI DI Refactor: Azure.Mcp.Tools.Pricing Mar 17, 2026
Copilot AI requested a review from conniey March 17, 2026 10:20
@joshfree joshfree added the Do Not Merge Do Not Merge / WIP PRs label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Do Not Merge Do Not Merge / WIP PRs

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

DI Refactor: Azure.Mcp.Tools.Pricing

3 participants