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

Revisit guidance regarding .Count and .Length #49

Open
amanda-mitchell opened this issue Feb 15, 2019 · 1 comment
Open

Revisit guidance regarding .Count and .Length #49

amanda-mitchell opened this issue Feb 15, 2019 · 1 comment

Comments

@amanda-mitchell
Copy link
Contributor

amanda-mitchell commented Feb 15, 2019

Historically, we've enforced a nitpicky guideline that when .Count and .Length are available, they should be preferred over .Any() or .Count().

We could write an analyzer that enforces this, but the more that I think about it, the more it seems like this guidance is primarily aimed at avoiding multiple enumerations of IEnumerable. (see #32)

Perhaps we should instead have good analyzers for #32 and instead have a guideline that we should always use the most appropriate of

  • .Any()
  • .Count()
  • .CountIsExactly()
  • .CountIsAtLeast()
@amanda-mitchell
Copy link
Contributor Author

If we decide to retain the existing rules, Roslynator has some diagnostics to support them.

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

No branches or pull requests

1 participant