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

RCS1077 for OrderBy(x => x) #1492

Closed
bricelam opened this issue Jul 16, 2024 · 6 comments · Fixed by #1522
Closed

RCS1077 for OrderBy(x => x) #1492

bricelam opened this issue Jul 16, 2024 · 6 comments · Fixed by #1522

Comments

@bricelam
Copy link

RCS1077 should recommend replacing .OrderBy(x => x) with .Order().

@BenjaminBrienen
Copy link
Contributor

This seems like a beginner-friendly task and I'm interested in contributing. I'll see about doing this this weekend if that's ok.

@josefpihrt
Copy link
Collaborator

@BenjaminBrienen You are more than welcome to do so!

Please see this file where you can a reference to the analyzer and cod fix provider:

public class RCS1077OptimizeLinqMethodCallTests : AbstractCSharpDiagnosticVerifier<InvocationExpressionAnalyzer, OptimizeLinqMethodCallCodeFixProvider>

Also, following file can be useful even though you are not adding new analyzer:

https://josefpihrt.github.io/docs/roslynator/how-to-add-new-analyzer

@BenjaminBrienen
Copy link
Contributor

image
I love it when I can just git clone a repository and all the tests pass! (except the test I just added)

@BenjaminBrienen
Copy link
Contributor

Analysis is working, working on code fix

@BenjaminBrienen
Copy link
Contributor

BenjaminBrienen commented Sep 14, 2024

Apparently Order() only exists new newer versions of .NET. The code fix works though!

https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.order?view=net-8.0&viewFallbackFrom=net-6.0

image

@BenjaminBrienen
Copy link
Contributor

I found something that I could use
#1157 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants