move_type

[refactoring]

Moves a type to a different file and/or namespace. Automatically updates all references and adds required using directives.

Parameters

NameTypeRequiredDescription
typeNamestringYesName of the type to move (simple or fully qualified).
targetFilePathstringNoTarget file path. If not specified, creates new file based on type name.
targetNamespacestringNoTarget namespace. If not specified, keeps original namespace.
projectNamestringNoOptional project name to limit the search scope.
applyChangesbooleanNoIf true (default), applies changes. If false, returns preview only.

Examples

Move type to new file

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "move_type",
    "arguments": {
      "typeName": "MyClass",
      "targetFilePath": "/path/to/NewFile.cs"
    }
  }
}
Response
{
  "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

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "move_type",
    "arguments": {
      "typeName": "MyClass",
      "targetNamespace": "MyApp.NewNamespace"
    }
  }
}
Response
{
  "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
}

Response

Returns source and target locations, files changed/created, and diff

Go to Playground to test this tool interactively.