Update AV2202: Prefer language syntax over explicit calls to underlying implementations#379
Update AV2202: Prefer language syntax over explicit calls to underlying implementations#379dennisdoomen wants to merge 1 commit intodevelopfrom
Conversation
Split from #298. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| if (startDate is null) ... | ||
|
|
||
| rather than: | ||
|
|
||
| if (startDate == null) ... | ||
|
|
||
| Prefer: | ||
|
|
||
| if (startDate is not null) ... |
There was a problem hiding this comment.
Good addition, but it doesn't belong in this rule. This rule is about using language syntax instead of calling framework methods. Neither of these is a framework method. Also applies to the other addition down below.
There was a problem hiding this comment.
I don't understand the subtlety here? I don't want to suggest != null anymore and instead promote is not null
There was a problem hiding this comment.
I'm indifferent between the two styles, but it's good to choose one, so I'm fine with the addition. Just not in this rule, because that is about preferring language syntax over implementations (for example: int vs System.Int32). It doesn't belong in this rule because != and is not are both language syntax.
There was a problem hiding this comment.
Perhaps an idea to put this in a new rule that prescibes when to prefer pattern syntax (and when not)?
There was a problem hiding this comment.
Good idea. I'll do that.
This PR updates guideline AV2202.
It was split out of #298 so the change can be reviewed independently.
Files:
Part of the replacement for #298.