Skip to content

Update AV1755: Only use Async or TaskAsync as a suffix when a method has both synchronous and asynchronous versions#374

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

Update AV1755: Only use Async or TaskAsync as a suffix when a method has both synchronous and asynchronous versions#374
dennisdoomen wants to merge 1 commit intodevelopfrom
copilot/pr298-update-av1755

Conversation

@dennisdoomen
Copy link
Copy Markdown
Owner

This PR updates guideline AV1755.

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

Files:

  • _rules/1755.md

Part of the replacement for #298.

Split from #298.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
rule_id: 1755
rule_category: naming-conventions
title: Postfix asynchronous methods with `Async` or `TaskAsync`
title: Only use `Async` or `TaskAsync` as a suffix when a method has both synchronous and asynchronous versions
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.

Why was this rule changed? The BCL still adds the Async suffix, as far as I'm aware.

severity: 2
---
The general convention for methods and local functions that return `Task` or `Task<TResult>` is to postfix them with `Async`. But if such a method already exists, use `TaskAsync` instead.
Only postfix a method or local function that returns `Task` or `Task<TResult>` with `Async` if there is also a synchronous version of that method. If the only version is asynchronous, the `Async` suffix adds unnecessary noise. If both synchronous and asynchronous versions exist, use `Async` as the postfix. If a method named `Async` already exists, use `TaskAsync` instead.
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.

Suggested change
Only postfix a method or local function that returns `Task` or `Task<TResult>` with `Async` if there is also a synchronous version of that method. If the only version is asynchronous, the `Async` suffix adds unnecessary noise. If both synchronous and asynchronous versions exist, use `Async` as the postfix. If a method named `Async` already exists, use `TaskAsync` instead.
Only suffix a method or local function that returns `Task` or `Task<TResult>` with `Async` if there is also a synchronous version of that method. If the only version is asynchronous, the `Async` suffix adds unnecessary noise. If both synchronous and asynchronous versions exist, use `Async` as the postfix. If a method named `Async` already exists, use `TaskAsync` instead.

Googled for "what's the difference between postfix and suffix as a noun?":

"suffix" is the standard term in linguistics for word endings (e.g., -ed, -ing), whereas "postfix" is a technical term commonly used in computing and mathematics to mean an operator placed after operands.

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