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

OptimizeLinqUsageFixer.UseIndexerLast code fix to use from the end Index (or at least propose both options ?) #728

Closed
fforjan opened this issue Jun 12, 2024 · 1 comment

Comments

@fforjan
Copy link

fforjan commented Jun 12, 2024

Following code :

var list = new List<int>() {...}
var last = list.Last();

would be refactored to

var list = new List<int>() {...}
var last = list[list.Count - 1];

it would be good to have a different fix :

var list = new List<int>() {...}
var last = list[^1];
@fforjan fforjan changed the title OptimizeLinqUsageFixer.UseIndexerLast code fix to use IndexRange (or at least propose both options ?) OptimizeLinqUsageFixer.UseIndexerLast code fix to use from the end Index (or at least propose both options ?) Jun 12, 2024
@meziantou
Copy link
Owner

Thanks for the suggestion! It's available in the latest version of the package (2.0.156).

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

No branches or pull requests

2 participants