Enable nullability in BindToObject#9554
Conversation
| /// in the current row | ||
| /// </summary> | ||
| private string GetErrorText(object value) | ||
| private string GetErrorText(object? value) |
There was a problem hiding this comment.
can text local nullable and avoid duplicate assignment?
There was a problem hiding this comment.
Sorry, what do you mean?
There was a problem hiding this comment.
local on line 109 can be declared as string? text ?
There was a problem hiding this comment.
Actually, I see that text can never be null. Maybe we should remove ?? string.Empty; instead from line 130?
There was a problem hiding this comment.
@dreddy-work I added a separate commit with the proposed change.
There was a problem hiding this comment.
final change could alter functionality. Though Interface says default is empty string, I see implementations of this interface returning null either for errorInfo[FieldInfo.Name] or errorInfo.Error. So, i would go with declaration as string? text and return text??striong.Empty;
There was a problem hiding this comment.
I kept the removal of text and added some null checks instead.
| return true; | ||
| } | ||
|
|
||
| if (!(_owner.DataSource is ISupportInitializeNotification ds) || ds.IsInitialized) |
There was a problem hiding this comment.
| if (!(_owner.DataSource is ISupportInitializeNotification ds) || ds.IsInitialized) | |
| if (_owner.DataSource is not ISupportInitializeNotification ds || ds.IsInitialized) |
| CheckBinding(); | ||
| } | ||
|
|
||
| internal void SetBindingManagerBase(BindingManagerBase lManager) |
There was a problem hiding this comment.
Are you sure lManager can't be null? I was under the impression the BindingManagerBase property whose setter calls this method can be null.
| } | ||
| } | ||
|
|
||
| internal void SetValue(object value) |
There was a problem hiding this comment.
Same here, I thought the argument could be null on the call site.
b0533c9 to
64e883a
Compare
Proposed changes
Microsoft Reviewers: Open in CodeFlow