Skip to content

refactor(communication): constructor DI for SmsSendCommand and EmailSendCommand#1913

Merged
conniey merged 7 commits intomainfrom
copilot/refactor-azure-mcp-communication
Mar 13, 2026
Merged

refactor(communication): constructor DI for SmsSendCommand and EmailSendCommand#1913
conniey merged 7 commits intomainfrom
copilot/refactor-azure-mcp-communication

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

  • Inject ICommunicationService via constructor in SmsSendCommand and EmailSendCommand
  • Remove context.GetService<ICommunicationService>() from ExecuteAsync
  • Update SmsSendCommandTests to use shared fields and constructor injection
  • Update EmailSendCommandTests to pass service via constructor
  • Add changelog entry with PR number (1913)
  • Revert accidental global.json SDK version downgrade (restored to 10.0.103)
Original prompt

This section details on the original issue you should resolve

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

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

An example PR is: #1815
</issue_description>

<agent_instructions>After creating the PR, please double check Step 5 was done. In particular, make sure New-ChangelogEntry.ps1 is executed so the CHANGELOG entry is correct.</agent_instructions>

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.

Copilot AI and others added 4 commits March 3, 2026 19:53
- Inject ICommunicationService via constructor in SmsSendCommand and EmailSendCommand
- Remove context.GetService<ICommunicationService>() from ExecuteAsync
- Update SmsSendCommandTests to use shared fields and constructor injection
- Update EmailSendCommandTests to pass service via constructor
- Add changelog entry

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
…in SmsSendCommandTests

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor Azure.Mcp.Tools.Communication for dependency injection refactor(communication): constructor DI for SmsSendCommand and EmailSendCommand Mar 3, 2026
Comment thread servers/Azure.Mcp.Server/changelog-entries/1772567575847.yaml
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
@conniey conniey marked this pull request as ready for review March 10, 2026 17:25
@conniey conniey requested a review from KarishmaGhiya as a code owner March 10, 2026 17:25
Copilot AI review requested due to automatic review settings March 10, 2026 17:25
@conniey conniey requested review from a team as code owners March 10, 2026 17:25
Copy link
Copy Markdown
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 Communication tool’s send commands to use constructor-based dependency injection for ICommunicationService, improving testability and reducing reliance on CommandContext service resolution.

Changes:

  • Updated SmsSendCommand and EmailSendCommand to receive ICommunicationService via constructor injection and removed context.GetService<T>() usage.
  • Updated unit tests to construct commands with injected mocks rather than relying on DI resolution during execution.
  • Added an Azure.Mcp.Server changelog entry for the refactor (PR #1913).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/Azure.Mcp.Tools.Communication/src/Commands/Sms/SmsSendCommand.cs Injects ICommunicationService via constructor and uses it directly in ExecuteAsync.
tools/Azure.Mcp.Tools.Communication/src/Commands/Email/EmailSendCommand.cs Injects ICommunicationService via constructor and uses it directly in ExecuteAsync.
tools/Azure.Mcp.Tools.Communication/tests/Azure.Mcp.Tools.Communication.UnitTests/Sms/SmsSendCommandTests.cs Updates tests to pass mocked service via constructor and reuse shared fields.
tools/Azure.Mcp.Tools.Communication/tests/Azure.Mcp.Tools.Communication.UnitTests/Email/EmailSendCommandTests.cs Updates tests to pass mocked service via constructor injection.
servers/Azure.Mcp.Server/changelog-entries/1772567575847.yaml Adds changelog entry describing the DI refactor.
global.json Changes pinned .NET SDK version (flagged in review comment).

Comment thread global.json Outdated
Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
@conniey conniey enabled auto-merge (squash) March 10, 2026 23:32
@conniey conniey merged commit 5b81cab into main Mar 13, 2026
15 checks passed
@conniey conniey deleted the copilot/refactor-azure-mcp-communication branch March 13, 2026 01:01
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in Azure MCP Server Mar 13, 2026
colbytimm pushed a commit to colbytimm/microsoft-mcp that referenced this pull request Apr 20, 2026
…endCommand (microsoft#1913)

* Initial plan

* refactor: DI refactor for Azure.Mcp.Tools.Communication commands

- Inject ICommunicationService via constructor in SmsSendCommand and EmailSendCommand
- Remove context.GetService<ICommunicationService>() from ExecuteAsync
- Update SmsSendCommandTests to use shared fields and constructor injection
- Update EmailSendCommandTests to pass service via constructor
- Add changelog entry

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>

* chore: remove accidentally committed global.json.bak

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>

* refactor: address code review - remove unused _serviceProvider field in SmsSendCommandTests

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>

* chore: remove accidentally committed global.json.bak

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>

* chore: add PR number to changelog entry

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>

* revert: restore global.json SDK version to 10.0.103

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

DI Refactor: Azure.Mcp.Tools.Communication

4 participants