organize_usings

[refactoring]

Organizes using directives in a C# file (sort + remove unused) and returns diff output.

Try this tool in Playground.

Parameters

NameTypeRequiredDescription
filePathstringYesFile path to organize.
projectNamestringNoOptional project name filter.
applyChangesbooleanNoIf true (default), applies changes to disk. If false, returns preview only.
includeDiffbooleanNoInclude unified diff in response. Default is true.
maxDiffCharsnumberNoMax diff characters. Use 0 for unlimited. Default is 50000.
pathStylestringNoPath style: 'absolute' (default) or 'relative' (to solution root).
timeout_msnumberNoTimeout in milliseconds. Use 0 to disable. Default is 60000.

Examples

Preview organize usings

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "organize_usings",
    "arguments": {
      "filePath": "/Users/dev/MyProject/Program.cs",
      "applyChanges": false
    }
  }
}
Response
{
  "success": true,
  "data": {
    "filePath": "/path/to/File.cs",
    "changed": true,
    "applied": false,
    "filesChanged": 1,
    "unifiedDiff": "...",
    "changedFiles": [
      {
        "filePath": "/path/to/File.cs",
        "changeCount": 1,
        "diff": "..."
      }
    ]
  },
  "error": null
}

Response Notes

Returns diff output for the formatting operation