-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Move helpers for 'use collection expression'. #69581
Conversation
@@ -454,4 +456,298 @@ or ImplicitStackAllocArrayCreationExpressionSyntax | |||
|
|||
return matches.ToImmutable(); | |||
} | |||
|
|||
public static bool IsCollectionFactoryCreate( |
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.
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( |
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.
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);
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)]