-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Conversation
@dotnet/roslyn-ide @JoeRobich @ToddGrun ptal |
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) | ||
{ |
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.
Indentation seems off here.
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) | |
{ |
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.
The Formatter doesn't like that, and gives an ide0055 error :+)
editor.ReplaceNode( | ||
spreadElement, | ||
(_, _) => collectionToInline.Elements.Select( | ||
e => e.WithLeadingTrivia(leadingTrivia).WithoutTrailingTrivia())); |
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.
Why do we want to remove trailing trivia here?
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.
Probably not needed. Will remove!
...s/CSharp/Portable/CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
…InlineTemporaryCodeRefactoringProvider.cs
editor.ReplaceNode( | ||
spreadElement, | ||
(_, _) => collectionToInline.Elements.Select( | ||
e => e.WithLeadingTrivia(leadingTrivia).WithoutTrailingTrivia())); |
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.
e => e.WithLeadingTrivia(leadingTrivia).WithoutTrailingTrivia())); | |
e => e.WithLeadingTrivia(leadingTrivia))); |
Fixes #73148