Possible NullReferencePointer in for loop
Snippet
In the following code Reshaper gives a warning that curve[i] inside the for loop can be a possible NullReferenceException. Can I get rid of this without checking if curve[i] is null for every loop? As stated with annotations in the parameters, the curve can not contain items that are null.
public double Test([NotNull, ItemNotNull] List<Point2D> curve, double crossPoint)
{
for (var i = 0; i < curve.Count - 1; i++)
{
if (curve[i].X >= crossPoint && curve[i + 1].X > crossPoint)
{
return curve[i].X;
}
}
return double.NaN;
}
Please sign in to leave a comment.
Hello
I filed a new request on YouTrack https://youtrack.jetbrains.com/issue/RSRP-466093, feel free to follow it.
Thanks!