[refactoring]
Moves a type to a different file and/or namespace. Automatically updates all references and adds required using directives.
| Name | Type | Required | Description |
|---|---|---|---|
| typeName | string | Yes | Name of the type to move (simple or fully qualified). |
| targetFilePath | string | No | Target file path. If not specified, creates new file based on type name. |
| targetNamespace | string | No | Target namespace. If not specified, keeps original namespace. |
| projectName | string | No | Optional project name to limit the search scope. |
| applyChanges | boolean | No | If true (default), applies changes. If false, returns preview only. |
Move type to new file
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "move_type",
"arguments": {
"typeName": "MyClass",
"targetFilePath": "/path/to/NewFile.cs"
}
}
}{
"success": true,
"data": {
"symbolName": "MyClass",
"symbolKind": "Class",
"sourceLocation": "/path/to/OldFile.cs",
"targetLocation": "/path/to/NewFile.cs",
"filesChanged": 3,
"filesCreated": 1,
"applied": true,
"unifiedDiff": "..."
},
"error": null
}Move type to new namespace
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "move_type",
"arguments": {
"typeName": "MyClass",
"targetNamespace": "MyApp.NewNamespace"
}
}
}{
"success": true,
"data": {
"symbolName": "MyClass",
"symbolKind": "Class",
"sourceLocation": "/path/to/OldFile.cs",
"targetLocation": "/path/to/NewFile.cs",
"filesChanged": 3,
"filesCreated": 1,
"applied": true,
"unifiedDiff": "..."
},
"error": null
}Returns source and target locations, files changed/created, and diff
Go to Playground to test this tool interactively.