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

Check generic argument index bounds. #196

Open
8 tasks
JohanLarsson opened this issue Nov 15, 2018 · 3 comments
Open
8 tasks

Check generic argument index bounds. #196

JohanLarsson opened this issue Nov 15, 2018 · 3 comments
Labels
analyzer Create an analyzer for this.

Comments

@JohanLarsson
Copy link
Collaborator

JohanLarsson commented Nov 15, 2018

type.GetGenericArguments()[0]
  • index
  • ElementAt()
  • First()
  • FirstOrDefault()
  • Last()
  • LastOrDefault()
  • Single()
  • SingleOrDefault()
@JohanLarsson JohanLarsson added the analyzer Create an analyzer for this. label Nov 16, 2018
@jnm2
Copy link
Collaborator

jnm2 commented Nov 16, 2018

Good one! Would you want to check Single and First and Last and the OrDefault versions?

@brian-reichle
Copy link

and the dreaded ElementAt? :)

Maybe also check the conditional invoke variants. There isn't really any reason to use a conditional invoke since GetGenericArguments() doesn't return null, but that doesn't mean people won't use it anyway.

@jnm2
Copy link
Collaborator

jnm2 commented Nov 16, 2018

A warning would be nice for conditional invoke on things that are guaranteed to never return null under any circumstance.

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

No branches or pull requests

3 participants