Примеры ошибок, обнаруженных с помощью диагностики V3128


V3128. The field (property) is used before it is initialized in constructor.


SharpDevelop

V3128 The 'contentPanel' field is used before it is initialized in constructor. SearchResultsPad.cs 66


Grid contentPanel;
public SearchResultsPad()
{
  ....
  defaultToolbarItems = ToolBarService
    .CreateToolBarItems(contentPanel, ....);
  ....
  contentPanel = new Grid {....};
  ....
}

PascalABC.NET

V3128 The 'dockPanel' field is used before it is initialized in constructor. ICSharpCode.SharpDevelop SearchResultsPad.cs 49


....
DockPanel dockPanel;
....
public SearchResultsPad()
{
  ....
  defaultToolbarItems = ToolBarService.
    CreateToolBarItems(dockPanel, ....);  // <=
  foreach (object toolBarItem in defaultToolbarItems) {
    toolBar.Items.Add(toolBarItem);
  }
  ....
  dockPanel = new DockPanel {
    Children = { toolBar, contentPlaceholder }
  };
  ....
}

.NET Core Libraries (CoreFX)

V3128 The '_index' field is used before it is initialized in constructor. PrinterSettings.Windows.cs 1679


private class ArrayEnumerator : IEnumerator
{
  private object[] _array;
  private object _item;
  private int _index;
  private int _startIndex;
  private int _endIndex;
  public ArrayEnumerator(object[] array, int startIndex, int count)
  {
    _array = array;
    _startIndex = startIndex;
    _endIndex = _index + count; // <=

    _index = _startIndex;
  }
  ....
}

.NET Core Libraries (CoreFX)

V3128 The '_timerInterval' field is used before it is initialized in constructor. TransactionTable.cs 151


internal class TransactionTable
{
  ....
  private int _timerInterval;
  ....
  internal TransactionTable()
  {
    _timer = new Timer(new TimerCallback(ThreadTimer),
                       null,
                       Timeout.Infinite,
                       _timerInterval); // <=

    ....
    _timerInterval = 1 << TransactionTable.timerInternalExponent;
    ....
  }
}


Найденные ошибки

Проверено проектов
367
Собрано ошибок
13 552

А ты совершаешь ошибки в коде?

Проверь с помощью
PVS-Studio

Статический анализ
кода для C, C++, C#
и Java

goto PVS-Studio;