Skip to main content

apply_code_action

Apply a code action (refactoring or fix) by its title. Use get_code_actions first to discover available actions. Defaults to preview mode (returns diff without writing files). Set preview=false to apply changes to disk.

Parameters​

ParameterTypeRequiredDescription
filePathstring✓Full path to the C# source file
lineint✓Line number (1-based)
columnint✓Column number (1-based)
actionTitlestring✓Exact title of the code action to apply (from get_code_actions)
endLineint?End line for text selection (1-based, optional)
endColumnint?End column for text selection (1-based, optional)
previewboolPreview only — return diff without writing to disk (default: true)