You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
which CC static analyzer will think is possibly accessing a null reference.
DataGridViewRowCollection should require for all methods that take in a DataGridViewRow that the row is non-null, and Ensure for all methods that return a DataGridViewRow that the result is non-null
This seems pretty safe to me after going through the code, exception is thrown when null is passed in in relevant places already. But there is one tricky edge case that needs to be cleared up: DataGridViewBand.Clone() needs to guarantee it returns non-null.
public virtual object Clone()
{
DataGridViewBand dataGridViewBand = (DataGridViewBand) Activator.CreateInstance(base.GetType());
if (dataGridViewBand != null)
{
this.CloneInternal(dataGridViewBand);
}
return dataGridViewBand;
}
It's probably safe, but maybe there's some edge case where Activator.CreateInstance returns null? It calls out to external methods so I can't fully analyze it.
DataGridViewRow CreateCellsInstance() and Cells should Ensure non-null
Similar logic as 1).
DataGridViewColumnCollection should require non-null columns to be added, and ensure columns retrieved are non-null
Similar logic as 2), haven't analyzed yet though.
Control.DataBindings can't be null, ButtonBase.FlatAppearance can't be null, ImageList.Images can't be null
Checked and it's not possible, so just add contracts.
The text was updated successfully, but these errors were encountered:
(This isn't an exhaustive list of contracts worth adding, just what I've noticed so far)
That way, Rows and Columns can ensure non-null as well.
The main reason this is a problem is due to Windows Form Designer generated code in InitializeComponent(). It can make lines like these
this.DataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
which CC static analyzer will think is possibly accessing a null reference.
This seems pretty safe to me after going through the code, exception is thrown when null is passed in in relevant places already. But there is one tricky edge case that needs to be cleared up: DataGridViewBand.Clone() needs to guarantee it returns non-null.
It's probably safe, but maybe there's some edge case where Activator.CreateInstance returns null? It calls out to external methods so I can't fully analyze it.
Similar logic as 1).
Similar logic as 2), haven't analyzed yet though.
Checked and it's not possible, so just add contracts.
The text was updated successfully, but these errors were encountered: