У меня есть следующий метод, который я нашел в обзоре кода. Внутри цикла Resharper сообщает мне, что if (narrativefound == false)
неверен, потому что narrativeFound
всегда прав. Я не думаю, что это так, потому что для того, чтобы установить narrativeFound
в true, сначала нужно передать условное сравнение строк, так как всегда это может быть правдой? Я что-то упускаю? Это ошибка в Resharper или в нашем коде?
public Chassis GetChassisForElcomp(SPPA.Domain.ChassisData.Chassis asMaintained, SPPA.Domain.ChassisData.Chassis newChassis)
{
Chassis c = asMaintained;
List<Narrative> newNarrativeList = new List<Narrative>();
foreach (Narrative newNarrative in newChassis.Narratives)
{
bool narrativefound = false;
foreach (Narrative orig in asMaintained.Narratives)
{
if (string.Compare(orig.PCode, newNarrative.PCode) ==0 )
{
narrativefound = true;
if (newNarrative.NarrativeValue.Trim().Length != 0)
{
orig.NarrativeValue = newNarrative.NarrativeValue;
newNarrativeList.Add(orig);
}
break;
}
if (narrativefound == false)
{
newNarrativeList.Add(newNarrative);
}
}
}
c.SalesCodes = newChassis.SalesCodes;
c.Narratives = newNarrativeList;
return c;
}