Format Method Parameters
Scope: What to Format
ALL projects:
All *.cs files EXCEPT auto-generated code.
Exclude files with:
- "generated", ".g.cs", ".designer.cs" in filename
- AssemblyInfo.cs files
[GeneratedCode] or [GeneratedCodeAttribute]
<auto-generated> tags
- "auto-generated" in headers
- "This code was generated by a tool"
ONLY format parameter lists in DECLARATIONS:
- Method declarations (public, private, protected, internal, static, async, virtual, override, abstract, etc.)
- Constructor declarations
- Local function declarations (functions defined inside methods)
- Delegate declarations
DO NOT format parameter lists in INVOCATIONS or EXPRESSIONS:
- Method calls/invocations (e.g.,
.Replace(...), .Substring(...))
- Constructor invocations (e.g.,
new MyClass(...))
- Ternary operators (e.g.,
condition ? value1 : value2)
- Lambda expressions (e.g.,
(x, y) => x + y)
- LINQ query expressions
- Indexer property declarations (e.g.,
this[int x, int y])
Formatting Rules
Rule 1: Multiple Parameters
Break down all parameters if a method has more than 1 parameter, with each parameter on its own line.
Rule 2: Single Long Parameter
Break down a single parameter if the total line length (including indentation) exceeds 80 characters.
Examples
Declarations to Format
// No parameters - no break
public void MyMethod1()
// Single short parameter - no break
public void MyMethod2(int parameter1)
// Single parameter, total length > 80 chars - break
public void MyLooooooooooooooooooooooooooooooooooooooooooonMethod4(
int parameter1)
// 2 parameters - break all
public void MyMethod5(
int parameter1,
int parameter2)
// 3+ parameters - break all
public void MyMethod6(
int parameter1,
int parameter2,
int parameter3)
// Constructor with multiple parameters - break all
public MyClass(
string name,
int age,
bool isActive)
// Local function with multiple parameters - break all
void LocalFunction(
int param1,
string param2)
// Delegate with multiple parameters - break all
public delegate void MyEventHandler(
object sender,
EventArgs e);
Invocations to Leave Unchanged
// Method invocations - DO NOT format
var result = assembly.GetBeautifiedName().Replace("Api", "API", StringComparison.Ordinal);
var name = someObject.SomeMethod(arg1, arg2, arg3);
// Constructor invocations - DO NOT format
var obj = new MyClass(param1, param2, param3);
// Ternary operators - DO NOT format
return condition ? value1 : value2;
// Lambda expressions - DO NOT format
var filtered = items.Where((item, index) => item.IsActive && index > 0);
// Indexer declarations - DO NOT format
public string this[int row, int column]
Execution Instructions
1. Scan for C# files
Find all .cs files in the repository.
2. Identify DECLARATIONS (not invocations)
Method declarations:
- Lines starting with access modifiers:
public, private, protected, internal
- Lines with method modifiers:
static, virtual, override, abstract, async, sealed
- Pattern:
[modifiers] [return-type] [method-name]([parameters])
- Must have a return type (or
void) before the method name
- Usually followed by
{, ;, or =>
Constructor declarations:
- Pattern:
[modifiers] [class-name]([parameters])
- Class name matches the containing class
- No return type before the name
Local function declarations:
- Found inside method bodies
- Pattern:
[return-type] [function-name]([parameters])
Delegate declarations:
- Pattern:
[modifiers] delegate [return-type] [delegate-name]([parameters]);
- Contains the
delegate keyword
Key distinction from invocations:
- Declarations have modifiers (public, private, static, etc.) OR are preceded by a type
- Invocations follow a
. (member access), are on the right side of =, or are arguments to other methods
3. Apply formatting rules
For each declaration found:
- If 2+ parameters: break all parameters onto separate lines
- If 1 parameter: break only if total line length > 80 characters
- Ensure proper indentation (4 spaces per indentation level)
- Place opening parenthesis
( on same line as method name
- Place each parameter on its own line with proper indentation
- Keep closing parenthesis
) on same line as last parameter
4. Process in batches
Work on files in manageable batches (e.g., 10-20 files at a time).
5. Verify after each batch
Run dotnet build to ensure no syntax errors.
6. Track progress
Use todo list to track which files have been processed.
7. Final verification
Run full test suite after all changes complete.
Guidelines
- Preserve all code logic and comments
- Maintain existing indentation style (spaces vs tabs)
- Handle edge cases: attributes, generic types, default values, nullable types, ref/out/in parameters
- Do not modify method bodies - only parameter declarations
- Do not modify method invocations - only declarations
- Leave ternary operators unchanged
- Leave lambda expressions unchanged
- Leave LINQ expressions unchanged
- If uncertain whether something is a declaration or invocation, skip it and flag for manual review
1---2name: format-params3description: Apply consistent method parameter line break formatting across C# projects. Formats parameter lists in declarations (methods, constructors, local functions, delegates) while leaving invocations untouched. Use when the user wants to format method parameters or apply parameter line break formatting.4---56# Format Method Parameters78## Scope: What to Format910**ALL projects:**1112All *.cs files EXCEPT auto-generated code.13Exclude files with:1415- "generated", ".g.cs", ".designer.cs" in filename16- AssemblyInfo.cs files17- `[GeneratedCode]` or `[GeneratedCodeAttribute]`18- `<auto-generated>` tags19- "auto-generated" in headers20- "This code was generated by a tool"2122**ONLY format parameter lists in DECLARATIONS:**2324- Method declarations (public, private, protected, internal, static, async, virtual, override, abstract, etc.)25- Constructor declarations26- Local function declarations (functions defined inside methods)27- Delegate declarations2829**DO NOT format parameter lists in INVOCATIONS or EXPRESSIONS:**3031- Method calls/invocations (e.g., `.Replace(...)`, `.Substring(...)`)32- Constructor invocations (e.g., `new MyClass(...)`)33- Ternary operators (e.g., `condition ? value1 : value2`)34- Lambda expressions (e.g., `(x, y) => x + y`)35- LINQ query expressions36- Indexer property declarations (e.g., `this[int x, int y]`)3738## Formatting Rules3940### Rule 1: Multiple Parameters4142Break down **all parameters** if a method has **more than 1 parameter**, with each parameter on its own line.4344### Rule 2: Single Long Parameter4546Break down a **single parameter** if the total line length (including indentation) exceeds **80 characters**.4748## Examples4950### Declarations to Format5152```csharp53// No parameters - no break54public void MyMethod1()5556// Single short parameter - no break57public void MyMethod2(int parameter1)5859// Single parameter, total length > 80 chars - break60public void MyLooooooooooooooooooooooooooooooooooooooooooonMethod4(61 int parameter1)6263// 2 parameters - break all64public void MyMethod5(65 int parameter1,66 int parameter2)6768// 3+ parameters - break all69public void MyMethod6(70 int parameter1,71 int parameter2,72 int parameter3)7374// Constructor with multiple parameters - break all75public MyClass(76 string name,77 int age,78 bool isActive)7980// Local function with multiple parameters - break all81void LocalFunction(82 int param1,83 string param2)8485// Delegate with multiple parameters - break all86public delegate void MyEventHandler(87 object sender,88 EventArgs e);89```9091### Invocations to Leave Unchanged9293```csharp94// Method invocations - DO NOT format95var result = assembly.GetBeautifiedName().Replace("Api", "API", StringComparison.Ordinal);96var name = someObject.SomeMethod(arg1, arg2, arg3);9798// Constructor invocations - DO NOT format99var obj = new MyClass(param1, param2, param3);100101// Ternary operators - DO NOT format102return condition ? value1 : value2;103104// Lambda expressions - DO NOT format105var filtered = items.Where((item, index) => item.IsActive && index > 0);106107// Indexer declarations - DO NOT format108public string this[int row, int column]109```110111## Execution Instructions112113### 1. Scan for C# files114115Find all `.cs` files in the repository.116117### 2. Identify DECLARATIONS (not invocations)118119**Method declarations:**120- Lines starting with access modifiers: `public`, `private`, `protected`, `internal`121- Lines with method modifiers: `static`, `virtual`, `override`, `abstract`, `async`, `sealed`122- Pattern: `[modifiers] [return-type] [method-name]([parameters])`123- Must have a return type (or `void`) before the method name124- Usually followed by `{`, `;`, or `=>`125126**Constructor declarations:**127- Pattern: `[modifiers] [class-name]([parameters])`128- Class name matches the containing class129- No return type before the name130131**Local function declarations:**132- Found inside method bodies133- Pattern: `[return-type] [function-name]([parameters])`134135**Delegate declarations:**136- Pattern: `[modifiers] delegate [return-type] [delegate-name]([parameters]);`137- Contains the `delegate` keyword138139**Key distinction from invocations:**140- Declarations have modifiers (public, private, static, etc.) OR are preceded by a type141- Invocations follow a `.` (member access), are on the right side of `=`, or are arguments to other methods142143### 3. Apply formatting rules144145For each declaration found:146- If 2+ parameters: break all parameters onto separate lines147- If 1 parameter: break only if total line length > 80 characters148- Ensure proper indentation (4 spaces per indentation level)149- Place opening parenthesis `(` on same line as method name150- Place each parameter on its own line with proper indentation151- Keep closing parenthesis `)` on same line as last parameter152153### 4. Process in batches154155Work on files in manageable batches (e.g., 10-20 files at a time).156157### 5. Verify after each batch158159Run `dotnet build` to ensure no syntax errors.160161### 6. Track progress162163Use todo list to track which files have been processed.164165### 7. Final verification166167Run full test suite after all changes complete.168169## Guidelines170171- **Preserve all code logic and comments**172- **Maintain existing indentation style** (spaces vs tabs)173- **Handle edge cases**: attributes, generic types, default values, nullable types, ref/out/in parameters174- **Do not modify method bodies** - only parameter declarations175- **Do not modify method invocations** - only declarations176- **Leave ternary operators unchanged**177- **Leave lambda expressions unchanged**178- **Leave LINQ expressions unchanged**179- **If uncertain whether something is a declaration or invocation**, skip it and flag for manual review