Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Inconsistent naming of async methods  #1009

Description

@CniKKoR

I know it's not an issue in general, but there is no consistent sceme of naming async methods, at least none I noticed.

Also all async methods should include the Async Suffix.

Source:
https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/task-asynchronous-programming-model#BKMK_HowtoWriteanAsyncMethod

The name of an async method, by convention, ends with an "Async" suffix.

for exmaple:

https://github.com/dotnet-architecture/eShopOnWeb/blob/main/src/Web/Pages/Shared/Components/BasketComponent/Basket.cs

public async Task<IViewComponentResult> InvokeAsync() {    ...    }

private async Task<int> CountTotalBasketItems() {    ...    }

private string? GetAnnonymousIdFromCookie() {    ...    }

For consistency CountTotalBasketItems() should also have the Suffix like InvokeAsync()

another example:

https://github.com/dotnet-architecture/eShopOnWeb/blob/main/src/Web/Pages/Admin/EditCatalogItem.cshtml.cs

public void OnGet(CatalogItemViewModel catalogModel) {    ...    }

public async Task<IActionResult> OnPostAsync() {    ...    }

All fine up here, BUT:

https://github.com/dotnet-architecture/eShopOnWeb/blob/main/src/Web/Pages/Basket/Index.cshtml.cs

public async Task OnGet() {    ...    }

public async Task<IActionResult> OnPost(CatalogItemViewModel productDetails) {    ...    }

public async Task OnPostUpdate(IEnumerable<BasketItemViewModel> items)  {    ...    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions