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

ValidatedNotNull bug for R# nullability analysis #106

Closed
ndrwrbgs opened this issue Oct 19, 2018 · 0 comments
Closed

ValidatedNotNull bug for R# nullability analysis #106

ndrwrbgs opened this issue Oct 19, 2018 · 0 comments
Milestone

Comments

@ndrwrbgs
Copy link
Contributor

Steps:

  • Mark parameter as [CanBeNull]
  • Use EnsureArg.IsNotNull(parameter) - which is documented with [ValidatedNotNull]
  • After that call, do something like var _ = parameter.ToString();

Expectation:

  • parameter is known to not be null at the .ToString() call

Reality:

  • R# does not seem to recognize that (in 2018.2 at least).

I think I mistakenly believed R# would acknowledge ValidatedNotNull (or it used to), either way we can work around it if we are willing to add a ContractAnnotation
[ContractAnnotation("=> parameter:notnull")] Which says if the method returns, parameter will be non-null.

ndrwrbgs added a commit to ndrwrbgs/Ensure.That that referenced this issue Nov 4, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@danielwertheim danielwertheim added this to the v8.1 milestone Nov 5, 2018
danielwertheim pushed a commit that referenced this issue Nov 6, 2018
danielwertheim pushed a commit that referenced this issue Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants