Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PH2101 Dereference null - false negative #707

Open
bcollamore opened this issue Nov 8, 2023 · 0 comments
Open

PH2101 Dereference null - false negative #707

bcollamore opened this issue Nov 8, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@bcollamore
Copy link
Member

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.

@ynsehoornenborg ynsehoornenborg added the bug Something isn't working label Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants