roslyn:add_null_checks
Add null argument guard clauses to C# methods. Position the cursor on a method with nullable parameters to automatically insert ArgumentNullException.ThrowIfNull statements at the start.
Instructions
Add ArgumentNullException.ThrowIfNull guard clauses for nullable parameters.
USAGE: Position cursor on a method with reference type parameters. OUTPUT: Generated guard clauses inserted at method start. IMPORTANT: Uses ZERO-BASED coordinates (editor line - 1).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"filePath": "<filePath>",
"line": "<line>",
"column": "<column>"
},
"name": "roslyn:add_null_checks"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| line | Yes | Zero-based line number on the method | |
| column | Yes | Zero-based column number | |
| preview | No | Preview mode (default: true) | |
| filePath | Yes | Absolute path to source file |