[MVC] Resharper should recognize ModelState dependant returns

Example

var a = db.Baskets.FirstOrDefault();

if (a == null){

     ModelState.AddModelError("A", "A is null");

}

if (!ModelState.IsValid)

{

     return View();

}
        a.Apples.Add(new Apple());

Here it shouldn't underline "a" and say Possible System.NullReferrenceException because if "a" would be null, function would return at "return View();" and would not reach there

There is also this case
     Vegetables.Where(x=>x.Time.HasValue).GroupBy(x=>x.Basket, x=>x.Time.Value.Day)
It doesn't recognize Time cannot be null here (I think it does if you use Select but not GroupBy)

Please sign in to leave a comment.