コードコントラクトとlinqに問題があります。問題を次のコードサンプルに絞り込むことができました。そして今、私は立ち往生しています。
public void SomeMethod()
{
var list = new List<Question>();
if (list.Take(5) == null) { }
// resharper hints that condition can never be true
if (list.ForPerson(12) == null) { }
// resharper does not hint that condition can never be true
}
public static IQueryable<Question> ForPerson(this IQueryable<Question> source, int personId)
{
if(source == null) throw new ArgumentNullException();
return from q in source
where q.PersonId == personId
select q;
}
私のlinqチェーンの何が問題になっていますか?ForPersonの呼び出しを分析するときに、なぜ「不平を言う」のではないのですか?
編集:ForPersonメソッドの戻りタイプが文字列からIQueryableに変更されました。(私の悪い)