Inconsistent naming of async methods
Author: CniKKoRCreated Jan 29, 2024Updated Jan 29, 2024
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.
The name of an async method, by convention, ends with an "Async" suffix.
for exmaple:
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:
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) { ... }Source: dotnet-architecture/eShopOnWeb