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

AddNullCheck should use new parameter! syntax #37067

Closed
jcouv opened this issue Jul 9, 2019 · 10 comments
Closed

AddNullCheck should use new parameter! syntax #37067

jcouv opened this issue Jul 9, 2019 · 10 comments
Labels
Area-IDE Feature Request help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-CodeStyle Built-in analyzers, fixes, and refactorings
Milestone

Comments

@jcouv
Copy link
Member

jcouv commented Jul 9, 2019

image

Instead of inserting if (parameter is null) throw new ArgumentNullException(nameof(parameter));, we should just mark the parameter declaration with a !.

We should also not offer this fix if the type of the parameter is annotated with ?.

FYI @fayrose @agocke

@CyrusNajmabadi
Copy link
Member

Has the compiler side of this been done? If so, i'm happy to do the IDE side. Is this currently in a branch, or in master? What langversion is it gated on?

Thanks!

@vatsalyaagrawal vatsalyaagrawal added Feature Request help wanted The issue is "up for grabs" - add a comment if you are interested in working on it labels Jul 10, 2019
@vatsalyaagrawal vatsalyaagrawal added this to the Backlog milestone Jul 10, 2019
@jasonmalinowski
Copy link
Member

@jcouv Is the compiler support in for this?

@jcouv
Copy link
Member Author

jcouv commented Jul 12, 2019

The compiler feature is in feature branch https://github.com/dotnet/roslyn/tree/features/param-nullchecking
LDM actually decided yesterday to keep this feature out of 8.0, so no rush.

@333fred 333fred added IDE-CodeStyle Built-in analyzers, fixes, and refactorings and removed New Language Feature - Nullable Semantic Model Nullable Semantic Model Issues labels Jul 18, 2019
@jasonmalinowski
Copy link
Member

@jcouv I forget, what langver is this going under? 9.0 or something sooner?

@jcouv
Copy link
Member Author

jcouv commented Sep 4, 2019

The feature is now targeting 9.0.

@Youssef1313
Copy link
Member

@jcouv

We should also not offer this fix if the type of the parameter is annotated with ?.

For public method, there is no guarantee that consumers will have NRT feature enabled. So, isn't it better to still offer this fix if the paramater is annotated with ?, BUT for public methods only?

@jasonmalinowski
Copy link
Member

@Youssef1313: this is the fix for adding null checks at the library side of things, not the consumer side of things; the check for ? would only be if your method is directly annotated as allowing a null in that case.

@Youssef1313
Copy link
Member

@jasonmalinowski Yes I see my comment is wrong. I don't know what I was thinking about when I wrote that 😄

@jasonmalinowski
Copy link
Member

@Youssef1313, eh, it's Monday. 😄

@CyrusNajmabadi
Copy link
Member

Closing out. I believe @RikkiGibson has done this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature Request help wanted The issue is "up for grabs" - add a comment if you are interested in working on it IDE-CodeStyle Built-in analyzers, fixes, and refactorings
Projects
None yet
Development

No branches or pull requests

6 participants