roslyn:extract_method
Extract selected statements inside a method into a new method. Analyzes data flow to detect parameters and return type, then produces both the extracted method code and a replacement call.
Instructions
Extract selected statements into a new method. Uses data flow analysis to determine parameters and return type.
USAGE: Specify startLine/endLine range containing complete statements inside a method. OUTPUT: extractedCode (the new method), replacementCode (the call to insert), detected parameters and return type. WORKFLOW: (1) Preview with preview=true, (2) Apply with preview=false. IMPORTANT: Uses ZERO-BASED coordinates (editor line - 1).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"filePath": "<filePath>",
"startLine": "<startLine>",
"endLine": "<endLine>",
"methodName": "<methodName>"
},
"name": "roslyn:extract_method"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endLine | Yes | Zero-based end line of selection | |
| preview | No | Preview mode (default: true). Set to false to apply. | |
| filePath | Yes | Absolute path to source file | |
| startLine | Yes | Zero-based start line of selection | |
| methodName | Yes | Name for the new method | |
| accessibility | No | Accessibility: private, public, internal (default: private) |