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

Move helpers for 'use collection expression'. #69581

Merged

Conversation

CyrusNajmabadi
Copy link
Member

These helpers are useful for the next upcoming analyzer/fixer, which finds things of the form ImmutableArray.Create(1, 2, 3).Add(x).Concat(other).ToArray() (and similar expressions) and offers to conver to [1, 2, 3, x, .. other)]

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner August 17, 2023 19:11
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 17, 2023
@@ -454,4 +456,298 @@ or ImplicitStackAllocArrayCreationExpressionSyntax

return matches.ToImmutable();
}

public static bool IsCollectionFactoryCreate(
Copy link
Member Author

Choose a reason for hiding this comment

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

all moves.

@@ -123,16 +123,15 @@ public bool ValuePatternMatches(TExpressionSyntax expression)
/// <summary>
/// Analyze an expression statement to see if it is a legal call of the form <c>val.Add(...)</c>.
/// </summary>
public bool TryAnalyzeAddInvocation<TExpressionStatementSyntax>(
TExpressionStatementSyntax statement,
public bool TryAnalyzeAddInvocation(
Copy link
Member Author

Choose a reason for hiding this comment

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

changed this to actually only analyze the invocation-expression itself, not hte containing expression-statement. that's because in the next PR .Add/.AddRange may be part of a long expression chain, not standalone like foo.Add(x);

@CyrusNajmabadi CyrusNajmabadi merged commit f9ce519 into dotnet:main Aug 18, 2023
23 of 24 checks passed
@ghost ghost added this to the Next milestone Aug 18, 2023
@CyrusNajmabadi CyrusNajmabadi deleted the useCollectionExpressionExtracts branch August 18, 2023 19:21
@dibarbet dibarbet modified the milestones: Next, 17.8 P2 Aug 28, 2023
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants