Skip to content
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

Special case inlining a collection expr into a spreaded element #76823

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #73148

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner January 20, 2025 21:39
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 20, 2025
@CyrusNajmabadi
Copy link
Member Author

@dotnet/roslyn-ide @JoeRobich @ToddGrun ptal

Comment on lines +239 to +246
else if (identifier.Parent is ArgumentSyntax
{
Parent: TupleExpressionSyntax tupleExpression,
NameColon: null,
} argument &&
!SyntaxFacts.IsReservedTupleElementName(identifier.Identifier.ValueText) &&
tupleExpression.Arguments.Count(a => nonConflictReferences.Contains(a.Expression)) == 1)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation seems off here.

Suggested change
else if (identifier.Parent is ArgumentSyntax
{
Parent: TupleExpressionSyntax tupleExpression,
NameColon: null,
} argument &&
!SyntaxFacts.IsReservedTupleElementName(identifier.Identifier.ValueText) &&
tupleExpression.Arguments.Count(a => nonConflictReferences.Contains(a.Expression)) == 1)
{
else if (identifier.Parent is ArgumentSyntax
{
Parent: TupleExpressionSyntax tupleExpression,
NameColon: null,
} argument &&
!SyntaxFacts.IsReservedTupleElementName(identifier.Identifier.ValueText) &&
tupleExpression.Arguments.Count(a => nonConflictReferences.Contains(a.Expression)) == 1)
{

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Formatter doesn't like that, and gives an ide0055 error :+)

editor.ReplaceNode(
spreadElement,
(_, _) => collectionToInline.Elements.Select(
e => e.WithLeadingTrivia(leadingTrivia).WithoutTrailingTrivia()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to remove trailing trivia here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not needed. Will remove!

editor.ReplaceNode(
spreadElement,
(_, _) => collectionToInline.Elements.Select(
e => e.WithLeadingTrivia(leadingTrivia).WithoutTrailingTrivia()));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
e => e.WithLeadingTrivia(leadingTrivia).WithoutTrailingTrivia()));
e => e.WithLeadingTrivia(leadingTrivia)));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inlining collection expression local into a spread could inline more aggressively
3 participants