move_type

[refactoring]

Moves a type to a different file and/or namespace and updates references.

Why this tool exists

C# refactors are semantic operations, not search-and-replace operations.

How it helps the agent

The model can preview or apply semantic changes while preserving symbol identity across overloads, files, and projects.

Parameters

NameTypeRequiredDescription
typeNamestringYesType name to move (simple or fully qualified).
targetFilePathstringNoOptional target file path.
targetNamespacestringNoOptional target namespace.
projectNamestringNoOptional project name to limit symbol search.
applyChangesbooleanNoIf true (default), applies changes to disk. If false, returns a preview diff.
formatAfterbooleanNoFormat changed documents after the move. Default is false.
organizeUsingsAfterbooleanNoOrganize usings in changed documents after the move. Default is false.
includeDiffbooleanNoInclude unified diff in response. Default is true.
maxDiffCharsnumberNoMax diff characters. Use 0 for unlimited. Default is 50000.
includePerFileDiffbooleanNoInclude per-file diffs in changedFiles. Default is true.
pathStylestringNoPath style: 'absolute' (default) or 'relative' (to solution root).

Examples

Move a type to a new namespace

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

Returns a unified diff of the change set

↑/↓ NavigateEnter OpenSpace Expand