私は以下のコードを持っていて、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
のような明確されていない任意の思想ください。 ReSharperのは、それについてcompletly確認するようには見えませんが - 一致するレコードが見つからない場合、someCollection
が今までnull
になることを非常にunliklyあるので
と同じである 'WHERE'ので、あなたの' if'条件は常に 'true'に評価され、' null'なのでを返すことは決してありませんが、空のシーケンスを返すことがあります。 – Lee