roslyn:validate_code
Validates C# code compilation without writing to disk. Uses existing file context for accurate error detection before applying generated code.
Instructions
Check if code would compile without writing to disk. Use to validate generated code before applying.
USAGE: validate_code(code="public void Foo() {}", contextFilePath="path/to/file.cs") to check with existing usings. OUTPUT: compiles (bool), errors list with line numbers. Essential before inserting AI-generated code.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | C# code to validate | |
| contextFilePath | No | Optional: file to use for context (usings, namespace) | |
| standalone | No | If true, treat code as complete file (default: false) |