From e711706479a00adc70704a4ab14f5c9950d08334 Mon Sep 17 00:00:00 2001 From: Kamyab7 Date: Sun, 11 Feb 2024 19:25:08 +0330 Subject: [PATCH 1/2] async naming conventions added to .editorconfig --- .editorconfig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.editorconfig b/.editorconfig index 459d75213..05199aa36 100644 --- a/.editorconfig +++ b/.editorconfig @@ -75,6 +75,20 @@ dotnet_naming_symbols.instance_fields.applicable_kinds = field dotnet_naming_style.instance_field_style.capitalization = camel_case dotnet_naming_style.instance_field_style.required_prefix = _ + +# Async naming conventions +dotnet_naming_rule.suffix_async_should_be_asyncsuffix.severity = error #suggestion +dotnet_naming_rule.suffix_async_should_be_asyncsuffix.symbols = suffix_async +dotnet_naming_rule.suffix_async_should_be_asyncsuffix.style = asyncsuffix + +dotnet_naming_symbols.suffix_async.applicable_kinds = method +dotnet_naming_symbols.suffix_async.applicable_accessibilities = * +dotnet_naming_symbols.suffix_async.required_modifiers = async + +dotnet_naming_style.asyncsuffix.required_prefix = +dotnet_naming_style.asyncsuffix.required_suffix = Async +dotnet_naming_style.asyncsuffix.word_separator = +dotnet_naming_style.asyncsuffix.capitalization = pascal_case ############################### # C# Coding Conventions # ############################### From 681e6073eee4e4c18d5ab2ab35c482a2605afff3 Mon Sep 17 00:00:00 2001 From: Kamyab7 Date: Sun, 11 Feb 2024 20:27:42 +0330 Subject: [PATCH 2/2] inconsistent naming of async methods fixed --- .../Interfaces/IBasketQueryService.cs | 2 +- .../Interfaces/IBasketService.cs | 4 +- src/ApplicationCore/Services/BasketService.cs | 4 +- src/BlazorAdmin/CustomAuthStateProvider.cs | 8 +-- src/BlazorAdmin/JavaScript/Cookies.cs | 4 +- src/BlazorAdmin/JavaScript/Css.cs | 4 +- src/BlazorAdmin/JavaScript/Route.cs | 2 +- .../Pages/CatalogItemPage/Create.razor | 20 +++--- .../Pages/CatalogItemPage/Delete.razor | 22 +++--- .../Pages/CatalogItemPage/Details.razor | 20 +++--- .../Pages/CatalogItemPage/Edit.razor | 22 +++--- .../Pages/CatalogItemPage/List.razor | 16 ++--- .../Pages/CatalogItemPage/List.razor.cs | 26 +++---- src/BlazorAdmin/Pages/Logout.razor | 2 +- src/BlazorAdmin/Program.cs | 4 +- .../CachedCatalogItemServiceDecorator.cs | 34 +++++----- ...achedCatalogLookupDataServiceDecorator .cs | 4 +- .../Services/CatalogItemService.cs | 36 +++++----- .../Services/CatalogLookupDataService.cs | 2 +- src/BlazorAdmin/Services/HttpService.cs | 18 ++--- src/BlazorAdmin/Shared/MainLayout.razor | 2 +- .../Interfaces/ICatalogItemService.cs | 12 ++-- .../Interfaces/ICatalogLookupDataService.cs | 2 +- src/BlazorShared/Models/CatalogItem.cs | 2 +- .../Data/Queries/BasketQueryService.cs | 2 +- .../Identity/Pages/Account/Logout.cshtml.cs | 2 +- src/Web/Controllers/ManageController.cs | 68 +++++++++---------- src/Web/Controllers/OrderController.cs | 4 +- src/Web/Controllers/UserController.cs | 8 +-- src/Web/Interfaces/IBasketViewModelService.cs | 6 +- .../ICatalogItemViewModelService.cs | 2 +- .../Interfaces/ICatalogViewModelService.cs | 6 +- src/Web/Pages/Admin/EditCatalogItem.cshtml.cs | 2 +- src/Web/Pages/Basket/Checkout.cshtml.cs | 10 +-- src/Web/Pages/Basket/Index.cshtml.cs | 18 ++--- src/Web/Pages/Index.cshtml.cs | 4 +- .../Components/BasketComponent/Basket.cs | 8 +-- src/Web/Services/BasketViewModelService.cs | 18 ++--- .../Services/CachedCatalogViewModelService.cs | 12 ++-- .../Services/CatalogItemViewModelService.cs | 2 +- src/Web/Services/CatalogViewModelService.cs | 10 +-- .../Controllers/AccountControllerSignIn.cs | 8 +-- .../Web/Controllers/CatalogControllerIndex.cs | 2 +- .../Web/Controllers/OrderControllerIndex.cs | 2 +- .../Web/Pages/Basket/BasketPageCheckout.cs | 2 +- .../Web/Pages/Basket/CheckoutTest.cs | 2 +- .../Web/Pages/Basket/IndexTest.cs | 4 +- .../Web/Pages/HomePageOnGet.cs | 2 +- .../BasketRepositoryTests/SetQuantities.cs | 4 +- .../OrderRepositoryTests/GetById.cs | 2 +- .../GetByIdWithItemsAsync.cs | 2 +- .../AuthEndpoints/AuthenticateEndpointTest.cs | 2 +- .../CatalogItemGetByIdEndpointTest.cs | 4 +- .../CatalogItemListPagedEndpoint.cs | 6 +- .../CreateCatalogItemEndpointTest.cs | 4 +- .../DeleteCatalogItemEndpointTest.cs | 4 +- .../BasketServiceTests/AddItemToBasket.cs | 8 +-- .../BasketServiceTests/DeleteBasket.cs | 2 +- .../BasketServiceTests/TransferBasket.cs | 8 +-- .../OrdersTests/GetMyOrders.cs | 2 +- .../OrdersTests/GetOrderDetails.cs | 2 +- 61 files changed, 263 insertions(+), 263 deletions(-) diff --git a/src/ApplicationCore/Interfaces/IBasketQueryService.cs b/src/ApplicationCore/Interfaces/IBasketQueryService.cs index 6136df765..5fefa409c 100644 --- a/src/ApplicationCore/Interfaces/IBasketQueryService.cs +++ b/src/ApplicationCore/Interfaces/IBasketQueryService.cs @@ -7,6 +7,6 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces; /// public interface IBasketQueryService { - Task CountTotalBasketItems(string username); + Task CountTotalBasketItemsAsync(string username); } diff --git a/src/ApplicationCore/Interfaces/IBasketService.cs b/src/ApplicationCore/Interfaces/IBasketService.cs index 204f5f142..6435e24ce 100644 --- a/src/ApplicationCore/Interfaces/IBasketService.cs +++ b/src/ApplicationCore/Interfaces/IBasketService.cs @@ -8,7 +8,7 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces; public interface IBasketService { Task TransferBasketAsync(string anonymousId, string userName); - Task AddItemToBasket(string username, int catalogItemId, decimal price, int quantity = 1); - Task> SetQuantities(int basketId, Dictionary quantities); + Task AddItemToBasketAsync(string username, int catalogItemId, decimal price, int quantity = 1); + Task> SetQuantitiesAsync(int basketId, Dictionary quantities); Task DeleteBasketAsync(int basketId); } diff --git a/src/ApplicationCore/Services/BasketService.cs b/src/ApplicationCore/Services/BasketService.cs index ec810f397..4558d4efd 100644 --- a/src/ApplicationCore/Services/BasketService.cs +++ b/src/ApplicationCore/Services/BasketService.cs @@ -20,7 +20,7 @@ public BasketService(IRepository basketRepository, _logger = logger; } - public async Task AddItemToBasket(string username, int catalogItemId, decimal price, int quantity = 1) + public async Task AddItemToBasketAsync(string username, int catalogItemId, decimal price, int quantity = 1) { var basketSpec = new BasketWithItemsSpecification(username); var basket = await _basketRepository.FirstOrDefaultAsync(basketSpec); @@ -44,7 +44,7 @@ public async Task DeleteBasketAsync(int basketId) await _basketRepository.DeleteAsync(basket); } - public async Task> SetQuantities(int basketId, Dictionary quantities) + public async Task> SetQuantitiesAsync(int basketId, Dictionary quantities) { var basketSpec = new BasketWithItemsSpecification(basketId); var basket = await _basketRepository.FirstOrDefaultAsync(basketSpec); diff --git a/src/BlazorAdmin/CustomAuthStateProvider.cs b/src/BlazorAdmin/CustomAuthStateProvider.cs index 30cf42cb2..d06e58ab4 100644 --- a/src/BlazorAdmin/CustomAuthStateProvider.cs +++ b/src/BlazorAdmin/CustomAuthStateProvider.cs @@ -30,10 +30,10 @@ public CustomAuthStateProvider(HttpClient httpClient, public override async Task GetAuthenticationStateAsync() { - return new AuthenticationState(await GetUser(useCache: true)); + return new AuthenticationState(await GetUserAsync(useCache: true)); } - private async ValueTask GetUser(bool useCache = false) + private async ValueTask GetUserAsync(bool useCache = false) { var now = DateTimeOffset.Now; if (useCache && now < _userLastCheck + UserCacheRefreshInterval) @@ -41,13 +41,13 @@ private async ValueTask GetUser(bool useCache = false) return _cachedUser; } - _cachedUser = await FetchUser(); + _cachedUser = await FetchUserAsync(); _userLastCheck = now; return _cachedUser; } - private async Task FetchUser() + private async Task FetchUserAsync() { UserInfo user = null; diff --git a/src/BlazorAdmin/JavaScript/Cookies.cs b/src/BlazorAdmin/JavaScript/Cookies.cs index 7d8742cb7..7e0422f77 100644 --- a/src/BlazorAdmin/JavaScript/Cookies.cs +++ b/src/BlazorAdmin/JavaScript/Cookies.cs @@ -12,12 +12,12 @@ public Cookies(IJSRuntime jsRuntime) _jsRuntime = jsRuntime; } - public async Task DeleteCookie(string name) + public async Task DeleteCookieAsync(string name) { await _jsRuntime.InvokeAsync(JSInteropConstants.DeleteCookie, name); } - public async Task GetCookie(string name) + public async Task GetCookieAsync(string name) { return await _jsRuntime.InvokeAsync(JSInteropConstants.GetCookie, name); } diff --git a/src/BlazorAdmin/JavaScript/Css.cs b/src/BlazorAdmin/JavaScript/Css.cs index 11d8763bd..f9d7874d2 100644 --- a/src/BlazorAdmin/JavaScript/Css.cs +++ b/src/BlazorAdmin/JavaScript/Css.cs @@ -12,12 +12,12 @@ public Css(IJSRuntime jsRuntime) _jsRuntime = jsRuntime; } - public async Task ShowBodyOverflow() + public async Task ShowBodyOverflowAsync() { await _jsRuntime.InvokeAsync(JSInteropConstants.ShowBodyOverflow); } - public async Task HideBodyOverflow() + public async Task HideBodyOverflowAsync() { return await _jsRuntime.InvokeAsync(JSInteropConstants.HideBodyOverflow); } diff --git a/src/BlazorAdmin/JavaScript/Route.cs b/src/BlazorAdmin/JavaScript/Route.cs index 3694545ad..702349bb5 100644 --- a/src/BlazorAdmin/JavaScript/Route.cs +++ b/src/BlazorAdmin/JavaScript/Route.cs @@ -12,7 +12,7 @@ public Route(IJSRuntime jsRuntime) _jsRuntime = jsRuntime; } - public async Task RouteOutside(string path) + public async Task RouteOutsideAsync(string path) { await _jsRuntime.InvokeAsync(JSInteropConstants.RouteOutside, path); } diff --git a/src/BlazorAdmin/Pages/CatalogItemPage/Create.razor b/src/BlazorAdmin/Pages/CatalogItemPage/Create.razor index 8bc5c23c1..eb99adfef 100644 --- a/src/BlazorAdmin/Pages/CatalogItemPage/Create.razor +++ b/src/BlazorAdmin/Pages/CatalogItemPage/Create.razor @@ -9,11 +9,11 @@