我有以下代码,并想知道为什么其他部分无法访问resharper。resharper警告代码启发式无法访问
private bool SomeMEthod(some parameter)
{
bool status = false;
var someCollection = _entity.CustomerPaymentStatus.Where(record => record.CustomerPaymentId == paymentId && record.CurrentRecord == true);
if (someCollection != null)
{
var receivedPayment = someCollection.FirstOrDefault();
/*some code to save data into DB*/
status = true;
}
else
{
//Some code here to log failure scenario
//here Resharper giving me warning
//code is heuristically unreachable
}
return status;
}
我检查了几个岗位,但并不清楚像Code is heuristically unreachable
任何思想请。
'Where'永远不应该返回'null'但可能会返回一个空的序列,那么你的'if'条件将始终评估为TRUE;。 – Lee