Examples of errors detected by the V3029 diagnostic.


V3029. The conditional expressions of the 'if' statements 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;
We use cookies for the analysis of events to improve our content and make user interaction more convenient. By continuing the view of our web-pages you accept the terms of using these files. You can find out more about cookie-files and privacy policy or close the notification, by clicking on the button. Learn More →
Do not show