Skip to content

DI Refactor: Azure.Mcp.Tools.ManagedLustre#2063

Merged
conniey merged 4 commits intomainfrom
copilot/mcp-158-refactor-managed-lustre
Mar 17, 2026
Merged

DI Refactor: Azure.Mcp.Tools.ManagedLustre#2063
conniey merged 4 commits intomainfrom
copilot/mcp-158-refactor-managed-lustre

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

  • Refactor FileSystemListCommand to use constructor DI
  • Refactor FileSystemCreateCommand to use constructor DI
  • Refactor FileSystemUpdateCommand to use constructor DI
  • Refactor SkuGetCommand to use constructor DI
  • Refactor SubnetSizeValidateCommand to use constructor DI
  • Refactor SubnetSizeAskCommand to use constructor DI
  • Refactor ImportJobGetCommand to use constructor DI
  • Refactor ImportJobCreateCommand to use constructor DI
  • Refactor ImportJobDeleteCommand to use constructor DI
  • Refactor ImportJobCancelCommand to use constructor DI
  • Refactor AutoimportJobCreateCommand to use constructor DI
  • Refactor AutoimportJobGetCommand to use constructor DI
  • Refactor AutoimportJobCancelCommand to use constructor DI
  • Refactor AutoimportJobDeleteCommand to use constructor DI
  • Refactor AutoexportJobCreateCommand to use constructor DI
  • Refactor AutoexportJobGetCommand to use constructor DI
  • Refactor AutoexportJobCancelCommand to use constructor DI
  • Refactor AutoexportJobDeleteCommand to use constructor DI
  • Update all unit tests to pass service via constructor
  • Remove unnecessary svc local variable; use _service directly in all ExecuteAsync methods
  • Fix Azure.Mcp.Core.UnitTests failures by registering IResourceGroupService mock in CommandFactoryHelpers.SetupCommonServices
Original prompt

This section details on the original issue you should resolve

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

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

An example PR is: #1815
</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…gedLustre commands

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Copilot AI changed the title [WIP] [mcp-158] Refactor Azure.Mcp.Tools.ManagedLustre for dependency injection DI Refactor: Azure.Mcp.Tools.ManagedLustre Mar 16, 2026
Copilot AI requested a review from conniey March 16, 2026 18:25
…all command ExecuteAsync methods

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Copy link
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 Azure.Mcp.Tools.ManagedLustre command implementations to use constructor dependency injection for IManagedLustreService instead of resolving services via context.GetService<T>(), improving testability and aligning with the broader DI refactor effort.

Changes:

  • Updated ManagedLustre commands to accept IManagedLustreService via constructor and use a private _service field in ExecuteAsync.
  • Removed context.GetService<IManagedLustreService>() usage across the affected commands.
  • Updated unit tests to construct commands with the injected service.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/SubnetSize/SubnetSizeValidateCommand.cs Inject IManagedLustreService via constructor; use _service in execution path.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/SubnetSize/SubnetSizeAskCommand.cs Inject IManagedLustreService via constructor; use _service in execution path.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/Sku/SkuGetCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/ImportJob/ImportJobGetCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service for get/list.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/ImportJob/ImportJobDeleteCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/ImportJob/ImportJobCreateCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/ImportJob/ImportJobCancelCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/FileSystemUpdateCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/FileSystemListCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/FileSystemCreateCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/AutoimportJob/AutoimportJobGetCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service for get/list.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/AutoimportJob/AutoimportJobDeleteCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/AutoimportJob/AutoimportJobCreateCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/AutoimportJob/AutoimportJobCancelCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/AutoexportJob/AutoexportJobGetCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service for get/list.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/AutoexportJob/AutoexportJobDeleteCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/AutoexportJob/AutoexportJobCreateCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/src/Commands/FileSystem/AutoexportJob/AutoexportJobCancelCommand.cs Inject IManagedLustreService via constructor; replace context-based resolution with _service.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/SubnetSize/SubnetSizeValidateCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/SubnetSize/SubnetSizeAskCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/Sku/SkuGetCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/ImportJob/ImportJobGetCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/ImportJob/ImportJobDeleteCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/ImportJob/ImportJobCreateCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/ImportJob/ImportJobCancelCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/FileSystemUpdateCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/FileSystemListCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/FileSystemCreateCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/AutoimportJob/AutoimportJobGetCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/AutoimportJob/AutoimportJobDeleteCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/AutoimportJob/AutoimportJobCreateCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/AutoimportJob/AutoimportJobCancelCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/AutoexportJob/AutoexportJobGetCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/AutoexportJob/AutoexportJobDeleteCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/AutoexportJob/AutoexportJobCreateCommandTests.cs Update command construction to pass injected IManagedLustreService.
tools/Azure.Mcp.Tools.ManagedLustre/tests/Azure.Mcp.Tools.ManagedLustre.UnitTests/FileSystem/AutoexportJob/AutoexportJobCancelCommandTests.cs Update command construction to pass injected IManagedLustreService.

You can also share your feedback on Copilot code review. Take the survey.

@conniey
Copy link
Member

conniey commented Mar 17, 2026

@copilot Tests in Azure.Mcp.Core.UnitTests are failing. Fix them. An example is:

Failed Azure.Mcp.Core.UnitTests.Areas.Tools.UnitTests.ToolsListCommandTests.ExecuteAsync_WithValidContext_FiltersHiddenCommands [16 ms]
  Error Message:
   System.InvalidOperationException : Unable to resolve service for type 'Azure.Mcp.Core.Services.Azure.ResourceGroup.IResourceGroupService' while attempting to activate 'Azure.Mcp.Tools.ManagedLustre.Services.ManagedLustreService'.
  Stack Trace:
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(ServiceIdentifier serviceIdentifier, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, ServiceIdentifier serviceIdentifier, Type implementationType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateExact(ServiceDescriptor descriptor, ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain, Int32 slot)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(ServiceIdentifier serviceIdentifier, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, ServiceIdentifier serviceIdentifier, Type implementationType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateExact(ServiceDescriptor descriptor, ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain, Int32 slot)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain)

…monServices to fix ToolsListCommandTests

Co-authored-by: conniey <10136526+conniey@users.noreply.github.com>
Copilot AI requested a review from a team as a code owner March 17, 2026 10:48
Copy link
Contributor Author

Copilot AI commented Mar 17, 2026

@copilot Tests in Azure.Mcp.Core.UnitTests are failing. Fix them. An example is:

...

Fixed in cbeffcc — added IResourceGroupService as a mocked service in CommandFactoryHelpers.SetupCommonServices(). ManagedLustreService requires it via constructor, but it wasn't registered in the test's DI container.

@conniey conniey merged commit d72e61d into main Mar 17, 2026
16 checks passed
@conniey conniey deleted the copilot/mcp-158-refactor-managed-lustre branch March 17, 2026 17:50
@github-project-automation github-project-automation bot moved this from Untriaged to Done in Azure MCP Server Mar 17, 2026
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.ManagedLustre

4 participants