ulrichb / ImplicitNullability

Extends ReSharper's static nullability analysis by changing specific, configurable elements to be [NotNull] by default
MIT License
44 stars 7 forks source link

Difference in behavior between explicit and implicit [NotNull] #13

Closed cmeeren closed 7 years ago

cmeeren commented 7 years ago

Please see the following two images. In the first image, the parameter id is implicitly NotNull. ReSharper dims the null check and says it's unnecessary because id is never null. In the second image, I've added an explicit [NotNull] annotation and everything works as expected. I would expect the behavior to be the same in the two cases.

without-annotations

with-annotation

ulrichb commented 7 years ago

Thanks for your report. Unfortunately there isn't much I can do about it because it has to be solved within R#.

I created a bug report: https://youtrack.jetbrains.com/issue/RSRP-464760. Note that it happens even without Implicit Nullability for inherited [NotNull]s.

At the moment, I can only suggest suppression comments or old-style (pre C#7) null checks as workarounds.

cmeeren commented 7 years ago

Thanks! I'll follow that bug report then.

ulrichb commented 7 years ago

Fixed in R# 2017.2