Skip to content

Update AV2202: Prefer language syntax over explicit calls to underlying implementations#379

Open
dennisdoomen wants to merge 1 commit intodevelopfrom
copilot/pr298-update-av2202
Open

Update AV2202: Prefer language syntax over explicit calls to underlying implementations#379
dennisdoomen wants to merge 1 commit intodevelopfrom
copilot/pr298-update-av2202

Conversation

@dennisdoomen
Copy link
Copy Markdown
Owner

This PR updates guideline AV2202.

It was split out of #298 so the change can be reviewed independently.

Files:

  • _rules/2202.md

Part of the replacement for #298.

Split from #298.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines +27 to +35
if (startDate is null) ...

rather than:

if (startDate == null) ...

Prefer:

if (startDate is not null) ...
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the subtlety here? I don't want to suggest != null anymore and instead promote is not null

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps an idea to put this in a new rule that prescibes when to prefer pattern syntax (and when not)?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I'll do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants