Examples of errors detected by the V3171 diagnostic
V3171. Potentially negative value is used as the size of an array.
ScottPlot
V3171 The value used as the size of an array could reach -1. Consider inspecting: PlotHeights.Count - 1. ScottPlot DraggableRows.cs 42
public class DraggableRows() : IMultiplotLayout
{
readonly List<float> PlotHeights = [];
....
float[] GetDividerPositions()
{
if (PlotHeights.Count == 1)
return [PlotHeights[0]];
float[] positions = new float[PlotHeights.Count - 1]; // <=
positions[0] = PlotHeights[0];
for (int i = 1; i < positions.Length; i++)
{
positions[i] = positions[i - 1] + PlotHeights[i];
}
return positions;
}
....
}