Examples of errors detected by the V3029 diagnostic

V3029. The conditional expressions of the 'if' operators situated alongside each other are identical.


.NET Compiler Platform ("Roslyn")

V3029 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 223, 228. EditAndContinueTestHelpers.cs 223


internal void VerifySemantics(....)
{
  ....
  if (additionalOldSources != null)
  {
    oldTrees = oldTrees.Concat(
      additionalOldSources.Select(s => ParseText(s)));
  }

  if (additionalOldSources != null)
  {
    newTrees = newTrees.Concat(
      additionalNewSources.Select(s => ParseText(s)));
  }
  ....
}

Samples by the Infragistics Company

V3029 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 338, 339.


public void OnPropertyChanged(PropertyChangedEventArgs ea) {
  ....
  var index = this.SelectedBrushCollectionIndex;
  ....
  if (index >= 0) {
    DebugManager.
      LogData(this.BrushCollectionList[index].ToText());
  }
  if (index >= 0) {
    this.SelectedBrushCollectionIndex = index;
  }
  ....
}


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++ and C#

goto PVS-Studio;