roslyn:extract_method
Extract selected code statements into a reusable method. Analyzes data flow to determine parameters and return type automatically, simplifying code refactoring in C# projects.
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).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absolute path to source file | |
| startLine | Yes | Zero-based start line of selection | |
| endLine | Yes | Zero-based end line of selection | |
| methodName | Yes | Name for the new method | |
| accessibility | No | Accessibility: private, public, internal (default: private) | |
| preview | No | Preview mode (default: true). Set to false to apply. |