-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
Implement analysis and fix for OrderBy(x => x) to Order() #1522
Implement analysis and fix for OrderBy(x => x) to Order() #1522
Conversation
@josefpihrt I added a conditional compilation on the unit test and a feature detection on the analyzer. If you want to handle this a different way, just let me know! :) |
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.
Please update changelog.
src/Analyzers.CodeFixes/CSharp/CodeFixes/OptimizeLinqMethodCallCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Analyzers.CodeFixes/CSharp/CodeFixes/OptimizeLinqMethodCallCodeFixProvider.cs
Show resolved
Hide resolved
src/Analyzers/CSharp/Analysis/OptimizeLinqMethodCallAnalysis.cs
Outdated
Show resolved
Hide resolved
src/Tests/Analyzers.Tests/RCS1077OptimizeLinqMethodCallTests.cs
Outdated
Show resolved
Hide resolved
At the moment, I only see methods for adding arguments and ArgumentsList doesn't have a public constructor. |
You can use combination of newInvocationExpression = newInvocationExpression.WithArgumentList(
newInvocationExpression.ArgumentList.WithArguments(
SyntaxFactory.SeparatedList<ArgumentSyntax>())); |
Ah, I just found another way using RemoveNodes, but this works too! (and it is better) |
I've doubled checked that all tests pass, so it should be ready for final review. |
Build is failing. |
Oh wow, it fails even with a little info message. Good to know there are tight checks! Fixed. |
Great PR! Thanks for the contribution! 👍 |
Fixes #1492
TODO:
System.Linq
does not yet implementIEnumerable<T>.Order()
.