roslyn:generate_constructor
Generate constructors automatically from class or struct fields and properties in C# code. Specify file location and options to create parameterized constructors with field assignments.
Instructions
Generate a constructor from fields and/or properties of a type.
USAGE: Position on class/struct declaration. Use includeProperties=true for auto-properties. OUTPUT: constructorCode string ready to paste, parameter list, and field assignments. IMPORTANT: Uses ZERO-BASED coordinates (editor line - 1).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absolute path to source file containing the type | |
| line | Yes | Zero-based line number on the type declaration | |
| column | Yes | Zero-based column number | |
| includeProperties | No | Include properties with setters (default: false) | |
| initializeToDefault | No | Use ?? default for nullable types (default: false) |