roslyn-analyzers icon indicating copy to clipboard operation
roslyn-analyzers copied to clipboard

PH2101 Dereference null - false negative

Open bcollamore opened this issue 1 year ago • 0 comments

PH2101 Dereference Null did not trip on this code:

				DataGridViewTextBoxCell assignedCell = row.Cells[_colAssignedValue.Index] as DataGridViewTextBoxCell;
				if (assignedCell.Value == null)
				{
					assignedCell.Value = string.Empty;
				}

Once IDE0074 was applied, PH2101 did trip on the result:

				DataGridViewTextBoxCell assignedCell = row.Cells[_colAssignedValue.Index] as DataGridViewTextBoxCell;
				assignedCell.Value ??= string.Empty;

```		

Ideally it would have tripped on the original code as well.

bcollamore avatar Nov 08 '23 13:11 bcollamore