roslyn:apply_code_fix
Apply automated code fixes for C# diagnostics using Roslyn. List available fixes, preview changes, then apply corrections to resolve compiler issues in .NET projects.
Instructions
Apply automated code fix for a diagnostic. WORKFLOW: (1) Call with no fixIndex to list available fixes, (2) Call with fixIndex and preview=true to preview changes, (3) Call with preview=false to apply. IMPORTANT: Uses ZERO-BASED coordinates.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absolute path to source file | |
| diagnosticId | Yes | Diagnostic ID (e.g., CS0168, CS1998, CS4012) | |
| line | Yes | Zero-based line number (editor line - 1) | |
| column | Yes | Zero-based column number (editor column - 1) | |
| fixIndex | No | Index of fix to apply (omit to list available fixes). Call without this parameter first to see available fixes. | |
| preview | No | Preview mode (default: true). Set to false to apply changes to disk. ALWAYS preview first! |