replace_member
[refactoring]
Replaces one C# member selected by its exact symbolKey.
Unreleased: available on main, but absent from Glider 11.0.0. Install a release that includes this tool before use.
Before you use this tool
Writes files by default. Set applyChanges: false to preview. This tool requires an unreleased build.
Try it locally in the Glider playground
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| symbolKey | string | Yes | Exact member key from symbol discovery. Names and fuzzy matches are unsupported. |
| expectedText | string | Yes | Exact current declaration without outer trivia. Read replacementSpans from get_symbol_info, then get_file_contents. |
| memberCode | string | Yes | One complete declaration of the same member category. Exclude outer comments and directives. |
| filePath | string | No | Exact declaration file for a partial member. Absolute or loaded-root-relative. |
| applyChanges | boolean | No | Apply to disk by default. Set false to preview. Default: true |
| failOnErrors | boolean | No | Refuse a write when the replacement has compiler errors or incomplete linked-target coverage. Default: false |
| includeDiff | boolean | No | Include the unified diff. Default: true |
| maxDiffChars | number | No | Maximum diff characters. Use 0 for unlimited. Default: 50000 |
| pathStyle | string | No | Path style: absolute or relative to the loaded root. Default: "absolute" |
| responseDetail | string | No | compact returns results and actionable state. full adds diagnostic metadata under responseDiagnostics. Default: "compact" |
Examples
Replace sample paths and symbol keys with values from your workspace.
Preview an exact member replacement
{
"symbolKey": "<member key from search_symbols>",
"expectedText": "public int Total() => 1;",
"memberCode": "public int Total() => 2;",
"applyChanges": false
}Full MCP request
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "replace_member",
"arguments": {
"symbolKey": "<member key from search_symbols>",
"expectedText": "public int Total() => 1;",
"memberCode": "public int Total() => 2;",
"applyChanges": false
}
}
}{
"success": true,
"status": "preview",
"preview": true,
"applied": false,
"diskWriteAttempted": false,
"filesChanged": 0,
"wouldChange": true,
"filePath": "/project/OrderService.cs",
"workspaceUpdate": "unchanged",
"diagnostics": {
"errorCount": 0,
"warningCount": 0,
"items": []
},
"uncheckedProjects": [],
"unifiedDiff": "..."
}Response Notes
Supply its current declaration as expectedText and one replacement declaration as memberCode. Surrounding code and outer comments remain unchanged. Use applyChanges=false for a preview.
Returns status, the original span, replacementSymbolKey, diagnostics, and a bounded diff. Span lines and UTF-16 columns are one-based, with exclusive ends; start/length are zero-based UTF-16 offsets. A conflict requires a fresh read. Compiler checks cover only the replacement; callers remain unchanged. uncheckedProjects reports incomplete coverage. Apply awaits sync across all linked targets without a full reload. A failed sync returns success=false and applied=true. If workspaceUpdate is failed, sync the file instead of repeating the write. Internal directives and multi-variable declarations are unsupported. Supported encodings are UTF-8 and UTF-16 with a BOM. Concurrent writer exclusion covers Windows and cooperating .NET clients on Unix. Results use top-level fields with success. Compact is the default; full adds responseDiagnostics. Both modes retain errors, coverage, partial state, and recovery advice.