-
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
Add analyzer/fixer to suggest changing code fluent collection building to a collection expression #69580
Add analyzer/fixer to suggest changing code fluent collection building to a collection expression #69580
Conversation
@akhera99 for review. thanks! |
...nalyzers/UseCollectionExpression/CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs
Outdated
Show resolved
Hide resolved
…/CyrusNajmabadi/roslyn into useCollectionExpressionForFluent
var conversion = speculationAnalyzer.SpeculativeSemanticModel.GetConversion(speculationAnalyzer.ReplacedExpression, cancellationToken); | ||
if (conversion.IsIdentity) |
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.
@cston this appears to be an error. Once this merged, i'll open a bug on this.
} | ||
|
||
return node; | ||
} |
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.
this improved indentation tracking in a few more situations.
@@ -927,4 +926,87 @@ void M() | |||
ReferenceAssemblies = ReferenceAssemblies.Net.Net80, | |||
}.RunAsync(); | |||
} | |||
|
|||
[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.
beefed up testing in a few existing features.
this.SyntaxFacts.GetNameAndArityOfSimpleName(memberName, out var name, out var arity); | ||
|
||
if (arity != 0 || !Equals(name, methodName)) | ||
return false; |
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.
moved the fast checks up.
@akhera99 ptal. |
Part of #69473
Finds code like:
ImmutableArray<int>.Empty.AddRange(x).AddRange(y).ToXXX()
(and many patterns like that) and offers to convert to code like[..y, ..y]
.This works for varying patterns of
Add/AddRange
as well asConcat
(on a reified list).