-
Notifications
You must be signed in to change notification settings - Fork 0
Add consolidated dotnet_solution tool with action-based routing #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Implemented DotnetSolution method that routes to existing solution tools - Added 18 comprehensive tests covering all actions and error scenarios - All new tests pass (40/40 for solution tools) - XML documentation generated correctly - Note: 1 flaky conformance test exists (unrelated to changes) Co-authored-by: jongalloway <[email protected]>
- Replace redundant default case with throw statement - Ensures compiler recognizes all enum values are handled - All tests still passing (40/40) Co-authored-by: jongalloway <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a consolidated dotnet_solution tool that routes to four individual solution management operations (Create, Add, List, Remove) based on an action parameter. This consolidation reduces the tool surface while maintaining backward compatibility with existing individual tools.
Key Changes:
- New
DotnetSolution()method with action-based routing pattern - McpMeta attributes marking this as a consolidated tool with priority 10.0
- Comprehensive validation for action-specific required parameters
- 18 new unit tests covering all actions, parameter validation, and error scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| DotNetMcp/Tools/Cli/DotNetCliTools.Solution.cs | Added consolidated DotnetSolution() method with action routing to existing solution tools, plus helper methods for each action (HandleCreateAction, HandleAddAction, HandleListAction, HandleRemoveAction) |
| DotNetMcp.Tests/Tools/SolutionToolsTests.cs | Added 18 comprehensive tests for the consolidated tool covering all actions, parameter validation, and machine-readable error responses |
| /// This is a consolidated tool that routes to specific solution operations based on the action parameter. | ||
| /// </summary> | ||
| /// <param name="action">The solution operation to perform: Create, Add, List, or Remove</param> | ||
| /// <param name="solution">Path to solution file. Optional for 'create' action (uses name parameter). For other actions, defaults to searching current directory.</param> |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation states "For other actions, defaults to searching current directory" but the implementation in HandleAddAction, HandleListAction, and HandleRemoveAction actually requires the solution parameter and returns an error if it's not provided. This is misleading. The documentation should clarify that the solution parameter is required for Add, List, and Remove actions, not that it defaults to searching the current directory. Consider changing to: "Required for 'add', 'list', and 'remove' actions. Not used for 'create' action (which uses the name parameter)."
| /// <param name="solution">Path to solution file. Optional for 'create' action (uses name parameter). For other actions, defaults to searching current directory.</param> | |
| /// <param name="solution">Path to solution file. Required for 'add', 'list', and 'remove' actions. Not used for 'create' action (which uses the name parameter).</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in fb24d13. The documentation now correctly states that the solution parameter is required for 'add', 'list', and 'remove' actions, matching the actual implementation behavior.
| { | ||
| // Arrange | ||
| var originalDirectory = Environment.CurrentDirectory; | ||
| var tempDirectory = Path.Combine(Path.GetTempPath(), "dotnet-mcp-tests", Guid.NewGuid().ToString("N")); |
Check notice
Code scanning / CodeQL
Call to System.IO.Path.Combine Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 days ago
In general, to avoid Path.Combine silently discarding earlier segments when a later argument is absolute, use Path.Join when you are simply concatenating known path segments, especially when only the first argument is expected to be absolute. Path.Join does not treat later absolute arguments specially and will not drop earlier segments.
For this specific test file, the safest and simplest fix is to replace the single call to Path.Combine on line 352 with Path.Join, keeping the same arguments: Path.GetTempPath(), "dotnet-mcp-tests", and Guid.NewGuid().ToString("N"). This preserves the existing functionality—creating a unique temporary directory under the system temp path—while removing the pattern that CodeQL flags. No additional methods or imports are required because Path.Join is in the same System.IO.Path class already being used via using System.IO;. The only needed change is in DotNetMcp.Tests/Tools/SolutionToolsTests.cs at the definition of tempDirectory in the DotnetSolution_CreateAction_WithName_BuildsCorrectCommand test.
-
Copy modified line R352
| @@ -349,7 +349,7 @@ | ||
| { | ||
| // Arrange | ||
| var originalDirectory = Environment.CurrentDirectory; | ||
| var tempDirectory = Path.Combine(Path.GetTempPath(), "dotnet-mcp-tests", Guid.NewGuid().ToString("N")); | ||
| var tempDirectory = Path.Join(Path.GetTempPath(), "dotnet-mcp-tests", Guid.NewGuid().ToString("N")); | ||
| Directory.CreateDirectory(tempDirectory); | ||
|
|
||
| try |
| public async Task DotnetSolution_CreateAction_WithAllParameters_BuildsCorrectCommand() | ||
| { | ||
| // Arrange | ||
| var tempDirectory = Path.Combine(Path.GetTempPath(), "dotnet-mcp-tests", Guid.NewGuid().ToString("N")); |
Check notice
Code scanning / CodeQL
Call to System.IO.Path.Combine Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 days ago
In general, to avoid Path.Combine silently discarding earlier components when a later argument is absolute, use Path.Join when you want to concatenate path segments without interpreting later segments as potentially overriding the root. Path.Join treats all segments as simple components, producing the expected combined path.
For this specific test, update the construction of tempDirectory in DotnetSolution_CreateAction_WithAllParameters_BuildsCorrectCommand to use Path.Join instead of Path.Combine. The arguments stay the same; only the method changes. This preserves the resulting directory structure under the system temp path while avoiding the potential “absolute path override” behavior. No additional methods or imports are needed because System.IO.Path already exposes Join and using System.IO; is present at the top of the file.
Concretely:
- In
DotNetMcp.Tests/Tools/SolutionToolsTests.cs, at line 381, replacePath.Combine(...)withPath.Join(...)using the same three arguments. - No other code, imports, or definitions need to change.
-
Copy modified line R381
| @@ -378,7 +378,7 @@ | ||
| public async Task DotnetSolution_CreateAction_WithAllParameters_BuildsCorrectCommand() | ||
| { | ||
| // Arrange | ||
| var tempDirectory = Path.Combine(Path.GetTempPath(), "dotnet-mcp-tests", Guid.NewGuid().ToString("N")); | ||
| var tempDirectory = Path.Join(Path.GetTempPath(), "dotnet-mcp-tests", Guid.NewGuid().ToString("N")); | ||
| Directory.CreateDirectory(tempDirectory); | ||
|
|
||
| try |
- Clarify that solution parameter is required for add/list/remove actions - Remove incorrect statement about "defaults to searching current directory" - Update XML documentation to match actual implementation behavior Co-authored-by: jongalloway <[email protected]>
|
@copilot fix the build |
Co-authored-by: jongalloway <[email protected]>
Fixed in a400fab. The build failure was caused by the
Since |
Add global using for action enums and make DotnetSolution a partial tool method so XML-doc descriptions are generated reliably.
|
Reviewer note: This PR switches consolidated tools to rely on MCP’s XML-doc → description source generator.
If you’re reviewing consolidated tools going forward: prefer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Plan for dotnet_solution Consolidated Tool Implementation
DotnetSolutionmethod inDotNetCliTools.Solution.csDotnetSolutionActionenum parameterSolutionToolsTests.csImplementation Summary
The consolidated
dotnet_solutiontool has been successfully implemented and all tests pass!Features Implemented:
✅ Routes to Create, Add, List, and Remove actions
✅ Validates action enum and required parameters
✅ Proper error handling with machine-readable JSON output
✅ Helper methods for clean action-specific logic
✅ Comprehensive McpMeta attributes for AI assistants
✅ Switch expression with throw for compiler exhaustiveness
✅ Accurate documentation matching implementation behavior
✅ Description attribute for MCP SDK compatibility (non-partial methods)
Test Coverage:
✅ 40 tests for solution tools (18 for consolidated tool, 22 for individual tools)
✅ 100% passing test rate (793 total tests, 783 passed, 10 skipped)
✅ Covers all actions and error scenarios
✅ Machine-readable JSON output tested
✅ MCP conformance tests passing
Quality Checks:
✅ No compiler warnings
✅ XML documentation generated correctly
✅ Code review feedback addressed
✅ Follows existing codebase patterns
✅ Build successful - fixed by adding [Description] attribute
Ready for merge! 🎉
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.