move_member

[refactoring]

Moves a member (method/property/field) from one type to another and updates references. An applied refactor keeps the line endings each file already has. A file that mixes LF and CRLF is written with the ending it uses most. The unified diff normalizes both sides to LF, so it shows the edit and not the endings.

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.

Try it locally in the Glider playground

Parameters

NameTypeRequiredDescription
memberNamestringYesMember name to move.
sourceTypeNamestringYesSource type name.
targetTypeNamestringYesTarget type name.
projectNamestringNoOptional project name to limit search.
applyChangesbooleanNoIf true (default), applies changes to disk. If false, returns a preview diff.
maxReferenceUpdatesnumberNoMaximum reference updates when rewriting call sites. Use 0 to disable. Default is 2000.
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 method to another class

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "move_member",
    "arguments": {
      "memberName": "ProcessData",
      "sourceTypeName": "OldClass",
      "targetTypeName": "NewClass"
    }
  }
}
Response
{
  "success": true,
  "data": {
    "symbolName": "MyMethod",
    "symbolKind": "Method",
    "sourceLocation": "SourceClass",
    "targetLocation": "TargetClass",
    "filesChanged": 2,
    "filesCreated": 0,
    "applied": true,
    "unifiedDiff": "...",
    "workspaceUpdate": null
  },
  "error": null
}

Response Notes

Returns a unified diff of the change set. workspaceUpdate reports what the workspace did with a file the move created, and is null when it created none. kind reloaded_not_included means the file was written but no project compiles it, so the moved code builds nowhere. Its message names each such file and why.

↑/↓ NavigateEnter OpenSpace Expand