-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix comma placement after lambda block in variable declarations #81197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
| } | ||
| """); | ||
|
|
||
| [Fact] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot add [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/10526")] to all added tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 2e74af8.
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
| { | ||
| Action a = () => { }, | ||
| b = () => { }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot add tests with non-block lambdas:
Action a = () => x,
b = () => y;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 23bc2683.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot add tests with non-block lambdas:
Action a = () => x,
b = () => y;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 4893298.
Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
Fix comma placement after lambda block in variable declarations
Formatting incorrectly moved commas to a new line when multiple lambda or anonymous method variables were declared in a single statement:
Root Cause
Lambda/anonymous method blocks have
BlockSyntaxparent (notExpressionSyntax), soIsCloseBraceOfExpression()returns false. This triggered newline insertion logic, which checked exceptions for commas in initializers, arguments, tuples, and collections—but missed commas in variable declarations.Changes
IsCommaInVariableDeclaration()helper!currentToken.IsCommaInVariableDeclaration()Testing
Fixes #10526
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.