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
filePathstringFull path to the C# source file
lineintLine number (1-based)
columnintColumn number (1-based)
actionTitlestringExact 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)