Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Minor refactor code to use square brackets for array initialization
KrzysztofPajakd2b7a5e81275
diff --git a/src/API/Grand.Api/ApiExplorer/MetadataApiDescriptionProvider.cs b/src/API/Grand.Api/ApiExplorer/MetadataApiDescriptionProvider.csindex c483be7ba..a77ca77f3 100644--- a/src/API/Grand.Api/ApiExplorer/MetadataApiDescriptionProvider.cs+++ b/src/API/Grand.Api/ApiExplorer/MetadataApiDescriptionProvider.cs@@ -308,7 +308,7 @@ public class MetadataApiDescriptionProvider : IApiDescriptionProvider{return action.ActionConstraints is { Count: > 0 }? action.ActionConstraints.OfType<HttpMethodActionConstraint>().SelectMany(c => c.HttpMethods)- : new[] { string.Empty };+ : [string.Empty];}private static RouteTemplate? ParseTemplate(ControllerActionDescriptor action)@@ -501,7 +501,7 @@ public class MetadataApiDescriptionProvider : IApiDescriptionProvider{var propertyMetadata = metadataProperties[i];var key = new PropertyKey(propertyMetadata, source);- var bindingInfo = BindingInfo.GetBindingInfo(Enumerable.Empty<object>(), propertyMetadata);+ var bindingInfo = BindingInfo.GetBindingInfo([], propertyMetadata);var propertyContext = new ApiParameterDescriptionContext(propertyMetadata,diff --git a/src/API/Grand.Api/Validators/Catalog/ProductAttributeValidator.cs b/src/API/Grand.Api/Validators/Catalog/ProductAttributeValidator.csindex 615f137d4..5d10a209f 100644--- a/src/API/Grand.Api/Validators/Catalog/ProductAttributeValidator.cs+++ b/src/API/Grand.Api/Validators/Catalog/ProductAttributeValidator.cs@@ -27,10 +27,7 @@ public class ProductAttributeValidator : BaseGrandValidator<ProductAttributeDto>}).WithMessage(translationService.GetResource("Api.Catalog.ProductAttribute.Fields.Id.NotExists"));RuleFor(x => x).Must((x, _) =>{- foreach (var item in x.PredefinedProductAttributeValues)- if (string.IsNullOrEmpty(item.Name))- return false;- return true;+ return x.PredefinedProductAttributeValues.All(item => !string.IsNullOrEmpty(item.Name));}).WithMessage(translationService.GetResource("Api.Catalog.PredefinedProductAttributeValue.Fields.Name.Required"));}diff --git a/src/API/Grand.Api/Validators/Catalog/SpecificationAttributeValidator.cs b/src/API/Grand.Api/Validators/Catalog/SpecificationAttributeValidator.csindex 290abcf6a..c9430eaa6 100644--- a/src/API/Grand.Api/Validators/Catalog/SpecificationAttributeValidator.cs+++ b/src/API/Grand.Api/Validators/Catalog/SpecificationAttributeValidator.cs@@ -28,10 +28,7 @@ public class SpecificationAttributeValidator : BaseGrandValidator<SpecificationA}).WithMessage(translationService.GetResource("Api.Catalog.SpecificationAttribute.Fields.Id.NotExists"));RuleFor(x => x).Must((x, _) =>{- foreach (var item in x.SpecificationAttributeOptions)- if (string.IsNullOrEmpty(item.Name))- return false;- return true;+ return x.SpecificationAttributeOptions.All(item => !string.IsNullOrEmpty(item.Name));}).WithMessage(translationService.GetResource("Api.Catalog.SpecificationAttributeOptions.Fields.Name.Required"));}diff --git a/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.cs b/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.csindex 329421653..94b649180 100644--- a/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.cs+++ b/src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.cs@@ -83,7 +83,7 @@ public class ExternalAuthenticationService : IExternalAuthenticationService//account is already assigned to another userif (currentLoggedInUser.Id != associatedUser.Id)- return Error(new[] { "Account is already assigned" });+ return Error(["Account is already assigned"]);if (string.IsNullOrEmpty(returnUrl))return new RedirectToRouteResult("HomePage", new { area = "" });@@ -114,7 +114,7 @@ public class ExternalAuthenticationService : IExternalAuthenticationServicereturn await RegisterNewUser(parameters, returnUrl);//registration is disabled- return Error(new[] { "Registration is disabled" });+ return Error(["Registration is disabled"]);}/// <summary>@@ -154,7 +154,7 @@ public class ExternalAuthenticationService : IExternalAuthenticationServicereturn _customerSettings.UserRegistrationType == UserRegistrationType.AdminApproval? new RedirectToRouteResult("RegisterResult",new { resultId = (int)UserRegistrationType.AdminApproval })- : Error(new[] { "Error on registration" });+ : Error(["Error on registration"]);await _authenticationService.SignIn(_workContext.CurrentCustomer, false);return new RedirectToRouteResult("RegisterResult", new { resultId = (int)UserRegistrationType.Standard });@@ -261,7 +261,7 @@ public class ExternalAuthenticationService : IExternalAuthenticationServiceArgumentNullException.ThrowIfNull(parameters);if (!AuthenticationProviderIsAvailable(parameters.ProviderSystemName))- return Error(new[] { "External authentication method cannot be loaded" });+ return Error(["External authentication method cannot be loaded"]);//get current logged-in uservar currentLoggedInUser = await _groupService.IsRegistered(_workContext.CurrentCustomer)diff --git a/src/Business/Grand.Business.Catalog/Services/ExportImport/ProductImportDataObject.cs b/src/Business/Grand.Business.Catalog/Services/ExportImport/ProductImportDataObject.csindex 5b29725c8..0183a6e70 100644--- a/src/Business/Grand.Business.Catalog/Services/ExportImport/ProductImportDataObject.cs+++ b/src/Business/Grand.Business.Catalog/Services/ExportImport/ProductImportDataObject.cs@@ -172,7 +172,7 @@ public class ProductImportDataObject : IImportDataObject<ProductDto>private async Task PrepareProductCategories(Product product, string categoryIds){- foreach (var id in categoryIds.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)+ foreach (var id in categoryIds.Split([';'], StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim())){if (product.ProductCategories.FirstOrDefault(x => x.CategoryId == id) != null) continue;@@ -190,7 +190,7 @@ public class ProductImportDataObject : IImportDataObject<ProductDto>private async Task PrepareProductCollections(Product product, string collectionIds){- foreach (var id in collectionIds.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)+ foreach (var id in collectionIds.Split([';'], StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim())){if (product.ProductCollections.FirstOrDefault(x => x.CollectionId == id) != null) continue;diff --git a/src/Business/Grand.Business.Checkout/Validators/ShoppingCartCheckoutAttributesValidator.cs b/src/Business/Grand.Business.Checkout/Validators/ShoppingCartCheckoutAttributesValidator.csindex e6427a5e2..24ef123b7 100644--- a/src/Business/Grand.Business.Checkout/Validators/ShoppingCartCheckoutAttributesValidator.cs+++ b/src/Business/Grand.Business.Checkout/Validators/ShoppingCartCheckoutAttributesValidator.cs@@ -40,12 +40,10 @@ public class ShoppingCartCheckoutAttributesValidator : AbstractValidator<Shoppin{if (a1.Id != a2.Id) continue;var attributeValuesStr = value.CheckoutAttributes.Where(x => x.Key == a1.Id).Select(x => x.Value);- foreach (var str1 in attributeValuesStr)- if (!string.IsNullOrEmpty(str1.Trim()))- {- found = true;- break;- }+ if (attributeValuesStr.Any(str1 => !string.IsNullOrEmpty(str1.Trim())))+ {+ found = true;+ }}//if not founddiff --git a/src/Business/Grand.Business.Common/Services/Security/PermissionProvider.cs b/src/Business/Grand.Business.Common/Services/Security/PermissionProvider.csindex 02fde39cd..d676ca743 100644--- a/src/Business/Grand.Business.Common/Services/Security/PermissionProvider.cs+++ b/src/Business/Grand.Business.Common/Services/Security/PermissionProvider.cs@@ -9,7 +9,7 @@ public class PermissionProvider : IPermissionProvider{public virtual IEnumerable<Permission> GetPermissions(){- return new[] {+ return [StandardPermission.ManageAccessAdminPanel,StandardPermission.ManageAccessVendorPanel,StandardPermission.AllowCustomerImpersonation,@@ -81,15 +81,15 @@ public class PermissionProvider : IPermissionProviderStandardPermission.ManageOrderTags,StandardPermission.ManageOrderStatus,StandardPermission.AllowUseApi- };+ ];}public virtual IEnumerable<DefaultPermission> GetDefaultPermissions(){- return new[] {+ return [new DefaultPermission {CustomerGroupSystemName = SystemCustomerGroupNames.Administrators,- Permissions = new[] {+ Permissions = [StandardPermission.ManageAccessAdminPanel,StandardPermission.AllowCustomerImpersonation,StandardPermission.ManageProducts,@@ -160,30 +160,30 @@ public class PermissionProvider : IPermissionProviderStandardPermission.PublicStoreAllowNavigation,StandardPermission.AccessClosedStore,StandardPermission.AllowUseApi- }+ ]},new DefaultPermission {CustomerGroupSystemName = SystemCustomerGroupNames.Guests,- Permissions = new[] {+ Permissions = [StandardPermission.DisplayPrices,StandardPermission.EnableShoppingCart,StandardPermission.EnableWishlist,StandardPermission.PublicStoreAllowNavigation- }+ ]},new DefaultPermission {CustomerGroupSystemName = SystemCustomerGroupNames.Registered,- Permissions = new[] {+ Permissions = [StandardPermission.DisplayPrices,StandardPermission.EnableShoppingCart,StandardPermission.EnableWishlist,StandardPermission.PublicStoreAllowNavigation,StandardPermission.AllowUseApi- }+ ]},new DefaultPermission {CustomerGroupSystemName = SystemCustomerGroupNames.Vendors,- Permissions = new[] {+ Permissions = [StandardPermission.ManageAccessVendorPanel,StandardPermission.ManageProducts,StandardPermission.ManageFiles,@@ -193,11 +193,11 @@ public class PermissionProvider : IPermissionProviderStandardPermission.ManageShipments,StandardPermission.ManageMerchandiseReturns,StandardPermission.ManageReports- }+ ]},new DefaultPermission {CustomerGroupSystemName = SystemCustomerGroupNames.Staff,- Permissions = new[] {+ Permissions = [StandardPermission.ManageAccessAdminPanel,StandardPermission.ManageProducts,StandardPermission.ManageFiles,@@ -210,17 +210,17 @@ public class PermissionProvider : IPermissionProviderStandardPermission.ManageShipments,StandardPermission.ManageMerchandiseReturns,StandardPermission.ManageReports- }+ ]},new DefaultPermission {CustomerGroupSystemName = SystemCustomerGroupNames.SalesManager,- Permissions = new[] {+ Permissions = [StandardPermission.ManageAccessAdminPanel,StandardPermission.ManageOrders,StandardPermission.ManageCustomers- }+ ]}- };+ ];}}\ No newline at end of filediff --git a/src/Business/Grand.Business.Storage/Services/PictureService.cs b/src/Business/Grand.Business.Storage/Services/PictureService.csindex 7cfc1d732..680246bcc 100644--- a/src/Business/Grand.Business.Storage/Services/PictureService.cs+++ b/src/Business/Grand.Business.Storage/Services/PictureService.cs@@ -105,7 +105,7 @@ public class PictureService : IPictureServicevar fileName = $"{pictureId}_0.{lastPart}";var filePath = await GetPicturePhysicalPath(fileName);if (string.IsNullOrEmpty(filePath))- return Array.Empty<byte>();+ return [];return await File.ReadAllBytesAsync(filePath);}@@ -207,7 +207,7 @@ public class PictureService : IPictureServiceif (dirThumb != null){var file = _mediaFileStore.Combine(dirThumb.PhysicalPath, thumbFileName);- File.WriteAllBytes(file, binary ?? Array.Empty<byte>());+ File.WriteAllBytes(file, binary ?? []);}else{@@ -542,7 +542,7 @@ public class PictureService : IPictureServicepictureBinary = ValidatePicture(pictureBinary, mimeType);var picture = new Picture {- PictureBinary = _storageSettings.PictureStoreInDb ? pictureBinary : Array.Empty<byte>(),+ PictureBinary = _storageSettings.PictureStoreInDb ? pictureBinary : [],MimeType = mimeType,SeoFilename = seoFilename,AltAttribute = altAttribute,@@ -599,7 +599,7 @@ public class PictureService : IPictureServiceif (pictureBinary != null){- picture.PictureBinary = _storageSettings.PictureStoreInDb ? pictureBinary : Array.Empty<byte>();+ picture.PictureBinary = _storageSettings.PictureStoreInDb ? pictureBinary : [];await _pictureRepository.UpdateField(picture.Id, x => x.PictureBinary, picture.PictureBinary);}diff --git a/src/Business/Grand.Business.System/Services/BackgroundServices/ScheduleTasks/QueuedMessagesSendScheduleTask.cs b/src/Business/Grand.Business.System/Services/BackgroundServices/ScheduleTasks/QueuedMessagesSendScheduleTask.csindex f51c516f9..9bf2d435b 100644--- a/src/Business/Grand.Business.System/Services/BackgroundServices/ScheduleTasks/QueuedMessagesSendScheduleTask.cs+++ b/src/Business/Grand.Business.System/Services/BackgroundServices/ScheduleTasks/QueuedMessagesSendScheduleTask.cs@@ -37,10 +37,10 @@ public class QueuedMessagesSendScheduleTask : IScheduleTask{var bcc = string.IsNullOrWhiteSpace(queuedEmail.Bcc)? null- : queuedEmail.Bcc.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);+ : queuedEmail.Bcc.Split([';'], StringSplitOptions.RemoveEmptyEntries);var cc = string.IsNullOrWhiteSpace(queuedEmail.CC)? null- : queuedEmail.CC.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);+ : queuedEmail.CC.Split([';'], StringSplitOptions.RemoveEmptyEntries);try{diff --git a/src/Core/Grand.Domain/Blogs/BlogExtensions.cs b/src/Core/Grand.Domain/Blogs/BlogExtensions.csindex 86d2ccd24..86a50920e 100644--- a/src/Core/Grand.Domain/Blogs/BlogExtensions.cs+++ b/src/Core/Grand.Domain/Blogs/BlogExtensions.cs@@ -9,7 +9,7 @@ public static class BlogExtensionsvar parsedTags = new List<string>();if (!string.IsNullOrEmpty(blogPost.Tags)){- var tags2 = blogPost.Tags.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);+ var tags2 = blogPost.Tags.Split([','], StringSplitOptions.RemoveEmptyEntries);foreach (var tag2 in tags2){var tmp = tag2.Trim();diff --git a/src/Core/Grand.Domain/Catalog/ProductExtensions.cs b/src/Core/Grand.Domain/Catalog/ProductExtensions.csindex 3768e132e..7ef26840b 100644--- a/src/Core/Grand.Domain/Catalog/ProductExtensions.cs+++ b/src/Core/Grand.Domain/Catalog/ProductExtensions.cs@@ -63,7 +63,7 @@ public static class ProductExtensionsvar result = new List<int>();if (!string.IsNullOrWhiteSpace(product.AllowedQuantities))product.AllowedQuantities- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(qtyStr =>{@@ -259,20 +259,10 @@ public static class ProductExtensions{foreach (var str1 in values1Str){- var hasValue = false;- foreach (var str2 in values2Str)- //case insensitive?- if (str1.Trim() == str2.Trim())- {- hasValue = true;- break;- }-- if (!hasValue)- {- attributesEqual = false;- break;- }+ var hasValue = values2Str.Any(str2 => str1.Trim() == str2.Trim());+ if (hasValue) continue;+ attributesEqual = false;+ break;}}else@@ -419,12 +409,12 @@ public static class ProductExtensionsArgumentNullException.ThrowIfNull(product);if (string.IsNullOrEmpty(product.RequiredProductIds))- return Array.Empty<string>();+ return [];var ids = new List<string>();foreach (var idStr in product.RequiredProductIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()))ids.Add(idStr);diff --git a/src/Core/Grand.Domain/Orders/ShoppingCartExtensions.cs b/src/Core/Grand.Domain/Orders/ShoppingCartExtensions.csindex aa8e6c4f0..b352b06a7 100644--- a/src/Core/Grand.Domain/Orders/ShoppingCartExtensions.cs+++ b/src/Core/Grand.Domain/Orders/ShoppingCartExtensions.cs@@ -12,18 +12,12 @@ public static class ShoppingCartExtensions/// <returns>True if the shopping cart requires shipping; otherwise, false.</returns>public static bool RequiresShipping(this IList<ShoppingCartItem> shoppingCart){- foreach (var shoppingCartItem in shoppingCart)- if (shoppingCartItem.IsShipEnabled)- return true;- return false;+ return shoppingCart.Any(shoppingCartItem => shoppingCartItem.IsShipEnabled);}public static IEnumerable<ShoppingCartItem> LimitPerStore(this IEnumerable<ShoppingCartItem> cart,bool cartsSharedBetweenStores, string storeId){- if (cartsSharedBetweenStores)- return cart;-- return cart.Where(x => x.StoreId == storeId);+ return cartsSharedBetweenStores ? cart : cart.Where(x => x.StoreId == storeId);}}\ No newline at end of filediff --git a/src/Core/Grand.Infrastructure/TypeConverters/Converter/GenericDictionaryTypeConverter.cs b/src/Core/Grand.Infrastructure/TypeConverters/Converter/GenericDictionaryTypeConverter.csindex 5a5ecc19e..ba33ab971 100644--- a/src/Core/Grand.Infrastructure/TypeConverters/Converter/GenericDictionaryTypeConverter.cs+++ b/src/Core/Grand.Infrastructure/TypeConverters/Converter/GenericDictionaryTypeConverter.cs@@ -50,14 +50,14 @@ public class GenericDictionaryTypeConverter<K, V> : TypeConverter{if (value is not string input) return base.ConvertFrom(context, culture, value);var items = string.IsNullOrEmpty(input)- ? Array.Empty<string>()+ ? []: input.Split(';').Select(x => x.Trim()).ToArray();var result = new Dictionary<K, V>();foreach (var s in items){var keyValueStr = string.IsNullOrEmpty(s)- ? Array.Empty<string>()+ ? []: s.Split(',').Select(x => x.Trim()).ToArray();if (keyValueStr.Length != 2) continue;var dictionaryKey = _typeConverterKey.ConvertFromInvariantString(keyValueStr[0]);diff --git a/src/Core/Grand.Infrastructure/TypeConverters/Converter/GenericListTypeConverter.cs b/src/Core/Grand.Infrastructure/TypeConverters/Converter/GenericListTypeConverter.csindex 2b9334fa4..71f02d0e9 100644--- a/src/Core/Grand.Infrastructure/TypeConverters/Converter/GenericListTypeConverter.cs+++ b/src/Core/Grand.Infrastructure/TypeConverters/Converter/GenericListTypeConverter.cs@@ -31,7 +31,7 @@ public class GenericListTypeConverter<T> : TypeConverter/// <returns>Array</returns>protected virtual string[] GetStringArray(string input){- return string.IsNullOrEmpty(input) ? Array.Empty<string>() : input.Split(',').Select(x => x.Trim()).ToArray();+ return string.IsNullOrEmpty(input) ? [] : input.Split(',').Select(x => x.Trim()).ToArray();}/// <summary>diff --git a/src/Core/Grand.SharedKernel/Extensions/ExtendedLinq.cs b/src/Core/Grand.SharedKernel/Extensions/ExtendedLinq.csindex 0b4c11ee1..972e1e48a 100644--- a/src/Core/Grand.SharedKernel/Extensions/ExtendedLinq.cs+++ b/src/Core/Grand.SharedKernel/Extensions/ExtendedLinq.cs@@ -10,13 +10,13 @@ public static class ExtendedLinqpublic static IEnumerable<IEnumerable<T>> CartesianProduct<T>(this IEnumerable<IEnumerable<T>> sequences){- IEnumerable<IEnumerable<T>> emptyProduct = new[] { Enumerable.Empty<T>() };+ IEnumerable<IEnumerable<T>> emptyProduct = [[]];return sequences.Aggregate(emptyProduct,(accumulator, sequence) =>from accseq in accumulatorfrom item in sequence- select accseq.Concat(new[] { item }));+ select accseq.Concat([item]));}public static async Task<bool> AllAsync<T>(this IEnumerable<T> source, Func<T, Task<bool>> predicate)diff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasAllProductsController.cs b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasAllProductsController.csindex 814ab41ff..b0ccab735 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasAllProductsController.cs+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasAllProductsController.cs@@ -199,7 +199,7 @@ public class HasAllProductsController : BaseAdminPluginControllerif (string.IsNullOrWhiteSpace(productIds)) return new JsonResult(new { Text = result });var ids = new List<string>();var rangeArray = productIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList();diff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasOneProductController.cs b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasOneProductController.csindex 7e8aa857d..680c146ac 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasOneProductController.cs+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasOneProductController.cs@@ -199,7 +199,7 @@ public class HasOneProductController : BaseAdminPluginControllerif (string.IsNullOrWhiteSpace(productIds)) return new JsonResult(new { Text = result });var ids = new List<string>();var rangeArray = productIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList();diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/OutOfStockSubscriptionServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/OutOfStockSubscriptionServiceTests.csindex 733d6d2b3..47826741d 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/OutOfStockSubscriptionServiceTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/OutOfStockSubscriptionServiceTests.cs@@ -275,7 +275,7 @@ public class OutOfStockSubscriptionServiceTests//Actawait _outOfStockSubscriptionService.SendNotificationsToSubscribers(new Product { Id = "1" },- new CustomAttribute[] { new() { Key = "MyKey", Value = "1" } }, "");+ [new() { Key = "MyKey", Value = "1" }], "");//Assert_mediatorMock.Verify(c => c.Send(It.IsAny<SendNotificationsToSubscribersCommand>(), default),diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.csindex 4c80992c3..8b36e3d6f 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs@@ -230,7 +230,7 @@ public class ProductServiceTests//Arrangeawait insertSampleProducts();//Act- var result = _productService.GetCategoryProductNumber(new Customer(), new[] { "1" });+ var result = _productService.GetCategoryProductNumber(new Customer(), ["1"]);//AssertAssert.IsTrue(result == 1);diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Seo/SeNameServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Seo/SeNameServiceTests.csindex 143af0da7..d386a0f40 100644--- a/src/Tests/Grand.Business.Common.Tests/Services/Seo/SeNameServiceTests.cs+++ b/src/Tests/Grand.Business.Common.Tests/Services/Seo/SeNameServiceTests.cs@@ -26,7 +26,7 @@ namespace Grand.Business.Common.Tests.Services.Seo_mockLanguageService = new Mock<ILanguageService>();_mockLanguageService.Setup(l => l.GetAllLanguages(true, "")).ReturnsAsync(new List<Language>());_seoSettings = new SeoSettings {- ReservedEntityUrlSlugs = new List<string> { "reserved-slug" },+ ReservedEntityUrlSlugs = ["reserved-slug"],ConvertNonWesternChars = false,AllowUnicodeCharsInUrls = false,AllowSlashChar = false,@@ -96,7 +96,7 @@ namespace Grand.Business.Common.Tests.Services.Seo_mockSlugService.Setup(s => s.GetBySlug(It.IsAny<string>())).ReturnsAsync(new EntityUrl() { Slug = seName, EntityId = "123", EntityName = "TestEntity" });_mockLanguageService.Setup(l => l.GetAllLanguages(true, ""))- .ReturnsAsync(new[] { new Language { UniqueSeoCode = "en" } });+ .ReturnsAsync([new Language { UniqueSeoCode = "en" }]);// Actvar result = await _seNameService.ValidateSeName(entity, seName, name, true);@@ -116,7 +116,7 @@ namespace Grand.Business.Common.Tests.Services.Seo_mockSlugService.Setup(s => s.GetBySlug(It.IsAny<string>())).ReturnsAsync(new EntityUrl() { Slug = seName, EntityId = "123", EntityName = "TestEntity" });_mockLanguageService.Setup(l => l.GetAllLanguages(true, ""))- .ReturnsAsync(new[] { new Language { UniqueSeoCode = "en" } });+ .ReturnsAsync([new Language { UniqueSeoCode = "en" }]);// Actvar result = await _seNameService.ValidateSeName(entity, seName, name, true);@@ -135,7 +135,7 @@ namespace Grand.Business.Common.Tests.Services.Seo_mockSlugService.Setup(s => s.GetBySlug(It.IsAny<string>())).ReturnsAsync(new EntityUrl() { Slug = seName, EntityId = "123", EntityName = "TestEntity" });_mockLanguageService.Setup(l => l.GetAllLanguages(true, ""))- .ReturnsAsync(new[] { new Language { UniqueSeoCode = "en" } });+ .ReturnsAsync([new Language { UniqueSeoCode = "en" }]);// Actvar result = await _seNameService.ValidateSeName(entity, seName, name, true);diff --git a/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs b/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.csindex 6a7092a15..dec9a7729 100644--- a/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs+++ b/src/Tests/Grand.Data.Tests/LiteDb/LiteDbRepositoryTests.cs@@ -174,11 +174,11 @@ public class LiteDbRepositoryTestsvar products = new List<SampleCollection> {new() {Id = "1", Name = "Test",- Phones = new[] { "Phone1", "Phone2", "Phone3" }+ Phones = ["Phone1", "Phone2", "Phone3"]},new() {Id = "2", Name = "Test2",- Phones = new[] { "Phone1", "Phone2", "Phone3" }+ Phones = ["Phone1", "Phone2", "Phone3"]},new() { Id = "3", Name = "Test3" }};@@ -201,11 +201,11 @@ public class LiteDbRepositoryTestsvar products = new List<SampleCollection> {new() {Id = "1", Name = "Test",- Phones = new[] { "Phone1", "Phone2", "Phone3" }+ Phones = ["Phone1", "Phone2", "Phone3"]},new() {Id = "2", Name = "Test2",- Phones = new[] { "Phone1", "Phone2", "Phone3" }+ Phones = ["Phone1", "Phone2", "Phone3"]},new() { Id = "3", Name = "Test3" }};diff --git a/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs b/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.csindex ae3e1c713..f04896502 100644--- a/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs+++ b/src/Tests/Grand.Data.Tests/MongoDb/MongoRepositoryTests.cs@@ -165,11 +165,11 @@ public class MongoRepositoryTestsvar products = new List<SampleCollection> {new() {Id = "1", Name = "Test",- Phones = new[] { "Phone1", "Phone2", "Phone3" }+ Phones = ["Phone1", "Phone2", "Phone3"]},new() {Id = "2", Name = "Test2",- Phones = new[] { "Phone1", "Phone2", "Phone3" }+ Phones = ["Phone1", "Phone2", "Phone3"]},new() { Id = "3", Name = "Test3" }};@@ -195,11 +195,11 @@ public class MongoRepositoryTestsvar products = new List<SampleCollection> {new() {Id = "1", Name = "Test",- Phones = new[] { "Phone1", "Phone2", "Phone3" }+ Phones = ["Phone1", "Phone2", "Phone3"]},new() {Id = "2", Name = "Test2",- Phones = new[] { "Phone1", "Phone2", "Phone3" }+ Phones = ["Phone1", "Phone2", "Phone3"]},new() { Id = "3", Name = "Test3" }};diff --git a/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs b/src/Web/Grand.Web.Admin/Controllers/CustomerController.csindex 5885919ac..153e5c440 100644--- a/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs@@ -1002,7 +1002,7 @@ public class CustomerController : BaseAdminControllerif (selectedIds != null){var ids = selectedIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x).ToArray();customers.AddRange(await _customerService.GetCustomersByIds(ids));diff --git a/src/Web/Grand.Web.Admin/Controllers/OrderController.cs b/src/Web/Grand.Web.Admin/Controllers/OrderController.csindex 8b2b130e2..7c05e55be 100644--- a/src/Web/Grand.Web.Admin/Controllers/OrderController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/OrderController.cs@@ -172,7 +172,7 @@ public class OrderController(if (selectedIds != null){var ids = selectedIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x).ToArray();orders.AddRange(await orderService.GetOrdersByIds(ids));@@ -398,7 +398,7 @@ public class OrderController(if (selectedIds != null){var ids = selectedIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x).ToArray();orders.AddRange(await orderService.GetOrdersByIds(ids));diff --git a/src/Web/Grand.Web.Admin/Controllers/ProductController.cs b/src/Web/Grand.Web.Admin/Controllers/ProductController.csindex 07209ff6d..3bb89d273 100644--- a/src/Web/Grand.Web.Admin/Controllers/ProductController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/ProductController.cs@@ -356,7 +356,7 @@ public class ProductController : BaseAdminController{var ids = new List<string>();var rangeArray = productIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList();@@ -1500,7 +1500,7 @@ public class ProductController : BaseAdminControllerif (selectedIds != null){var ids = selectedIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x).ToArray();products.AddRange(await _productService.GetProductsByIds(ids, true));diff --git a/src/Web/Grand.Web.Admin/Controllers/SettingController.cs b/src/Web/Grand.Web.Admin/Controllers/SettingController.csindex 6e4b50bf6..5d7af64e6 100644--- a/src/Web/Grand.Web.Admin/Controllers/SettingController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/SettingController.cs@@ -692,10 +692,10 @@ public class SettingController(//security settingsvar securitySettings = settingService.LoadSetting<SecuritySettings>(storeScope);- securitySettings.AdminAreaAllowedIpAddresses ??= new List<string>();+ securitySettings.AdminAreaAllowedIpAddresses ??= [];securitySettings.AdminAreaAllowedIpAddresses.Clear();if (!string.IsNullOrEmpty(model.SecuritySettings.AdminAreaAllowedIpAddresses))- foreach (var s in model.SecuritySettings.AdminAreaAllowedIpAddresses.Split(new[] { ',' },+ foreach (var s in model.SecuritySettings.AdminAreaAllowedIpAddresses.Split([','],StringSplitOptions.RemoveEmptyEntries))if (!string.IsNullOrWhiteSpace(s))securitySettings.AdminAreaAllowedIpAddresses.Add(s.Trim());@@ -935,7 +935,7 @@ public class SettingController(await pictureService.SavePictureInFile(picture.Id, pictureBinary, picture.MimeType);}- picture.PictureBinary = storeIdDb ? pictureBinary : Array.Empty<byte>();+ picture.PictureBinary = storeIdDb ? pictureBinary : [];picture.IsNew = true;await pictureService.UpdatePicture(picture);diff --git a/src/Web/Grand.Web.Admin/Controllers/ShipmentController.cs b/src/Web/Grand.Web.Admin/Controllers/ShipmentController.csindex 8ebda1dac..9ea6a5add 100644--- a/src/Web/Grand.Web.Admin/Controllers/ShipmentController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/ShipmentController.cs@@ -530,7 +530,7 @@ public class ShipmentController : BaseAdminControllerif (selectedIds != null){var ids = selectedIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x).ToArray();shipments.AddRange(await _shipmentService.GetShipmentsByIds(ids));diff --git a/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.csindex af22f5e05..deca9d07d 100644--- a/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs@@ -1169,7 +1169,7 @@ public class CustomerViewModelService : ICustomerViewModelServicevar result = new List<string>();if (!string.IsNullOrWhiteSpace(customerTags)){- var values = customerTags.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);+ var values = customerTags.Split([','], StringSplitOptions.RemoveEmptyEntries);foreach (var val1 in values)if (!string.IsNullOrEmpty(val1.Trim()))result.Add(val1.Trim());diff --git a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.csindex c0ab1858f..915ecd39a 100644--- a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs@@ -1051,7 +1051,7 @@ public class OrderViewModelService : IOrderViewModelServicevar cblAttributes = model.SelectedAttributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;if (!string.IsNullOrEmpty(cblAttributes))foreach (var item in cblAttributes- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))+ .Split([','], StringSplitOptions.RemoveEmptyEntries))customattributes = ProductExtensions.AddProductAttribute(customattributes,attribute, item).ToList();@@ -1266,7 +1266,7 @@ public class OrderViewModelService : IOrderViewModelServicevar result = new List<string>();if (!string.IsNullOrWhiteSpace(orderTags)){- var values = orderTags.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);+ var values = orderTags.Split([','], StringSplitOptions.RemoveEmptyEntries);foreach (var val1 in values)if (!string.IsNullOrEmpty(val1.Trim()))result.Add(val1.Trim());diff --git a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.csindex c24853660..29570d0ca 100644--- a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs@@ -1733,7 +1733,7 @@ public class ProductViewModelService(if (!string.IsNullOrEmpty(cblAttributes)){var anyValueSelected = false;- foreach (var item in cblAttributes.Split(new[] { ',' },+ foreach (var item in cblAttributes.Split([','],StringSplitOptions.RemoveEmptyEntries))if (!string.IsNullOrEmpty(item)){@@ -2086,7 +2086,7 @@ public class ProductViewModelService({var cblAttributes = model.SelectedAttributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;if (!string.IsNullOrEmpty(cblAttributes))- foreach (var item in cblAttributes.Split(new[] { ',' },+ foreach (var item in cblAttributes.Split([','],StringSplitOptions.RemoveEmptyEntries))if (!string.IsNullOrEmpty(item))customAttributes = ProductExtensions.AddProductAttribute(customAttributes,@@ -2546,7 +2546,7 @@ public class ProductViewModelService(var result = new List<string>();if (!string.IsNullOrWhiteSpace(productTags)){- var values = productTags.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);+ var values = productTags.Split([','], StringSplitOptions.RemoveEmptyEntries);foreach (var val1 in values)if (!string.IsNullOrEmpty(val1.Trim()))result.Add(val1.Trim());diff --git a/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs b/src/Web/Grand.Web.Common/Filters/LanguageAttribute.csindex 19e579bf1..0138f3be7 100644--- a/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs+++ b/src/Web/Grand.Web.Common/Filters/LanguageAttribute.cs@@ -105,7 +105,7 @@ public class LanguageAttribute : TypeFilterAttribute_ = new PathString(url).StartsWithSegments(pathBase, out var result);url = WebUtility.UrlDecode(result);- var firstSegment = url.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ??+ var firstSegment = url.Split(['/'], StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ??string.Empty;if (string.IsNullOrEmpty(firstSegment))return false;diff --git a/src/Web/Grand.Web.Common/Startup/HostFilteringStartup.cs b/src/Web/Grand.Web.Common/Startup/HostFilteringStartup.csindex b2583c291..e51c6faf0 100644--- a/src/Web/Grand.Web.Common/Startup/HostFilteringStartup.cs+++ b/src/Web/Grand.Web.Common/Startup/HostFilteringStartup.cs@@ -26,7 +26,7 @@ public class HostFilteringStartup : IStartupApplication//configuration[var hosts = securityConfig.AllowedHosts?- .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);+ .Split([';'], StringSplitOptions.RemoveEmptyEntries);if (hosts?.Length > 0) services.Configure<HostFilteringOptions>(options => options.AllowedHosts = hosts);}diff --git a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ValidationHelpers.cs b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ValidationHelpers.csindex e4e494ac9..603a932db 100644--- a/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ValidationHelpers.cs+++ b/src/Web/Grand.Web.Common/TagHelpers/Admin/Extend/ValidationHelpers.cs@@ -44,7 +44,7 @@ internal static class ValidationHelpers{viewData.ModelState.TryGetValue(viewData.TemplateInfo.HtmlFieldPrefix, out var ms);- if (ms != null) return new[] { ms };+ if (ms != null) return [ms];}else if (viewData.ModelState.Count > 0){diff --git a/src/Web/Grand.Web.Common/WorkContext.cs b/src/Web/Grand.Web.Common/WorkContext.csindex f1ba9582a..80e35d7ef 100644--- a/src/Web/Grand.Web.Common/WorkContext.cs+++ b/src/Web/Grand.Web.Common/WorkContext.cs@@ -98,7 +98,7 @@ public class WorkContext : IWorkContext, IWorkContextSetterif (string.IsNullOrEmpty(path))return await Task.FromResult<Language>(null);- var firstSegment = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ??+ var firstSegment = path.Split(['/'], StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ??string.Empty;if (string.IsNullOrEmpty(firstSegment))return await Task.FromResult<Language>(null);diff --git a/src/Web/Grand.Web.Vendor/Controllers/OrderController.cs b/src/Web/Grand.Web.Vendor/Controllers/OrderController.csindex ee322f727..51e74f786 100644--- a/src/Web/Grand.Web.Vendor/Controllers/OrderController.cs+++ b/src/Web/Grand.Web.Vendor/Controllers/OrderController.cs@@ -188,7 +188,7 @@ public class OrderController : BaseVendorControllerif (selectedIds != null){var ids = selectedIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x).ToArray();orders.AddRange(await _orderService.GetOrdersByIds(ids));diff --git a/src/Web/Grand.Web.Vendor/Controllers/ProductController.cs b/src/Web/Grand.Web.Vendor/Controllers/ProductController.csindex b1cbddb0f..7232b77c1 100644--- a/src/Web/Grand.Web.Vendor/Controllers/ProductController.cs+++ b/src/Web/Grand.Web.Vendor/Controllers/ProductController.cs@@ -314,7 +314,7 @@ public class ProductController : BaseVendorControllerif (!string.IsNullOrWhiteSpace(productIds)){var rangeArray = productIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList();@@ -1439,7 +1439,7 @@ public class ProductController : BaseVendorControllerif (selectedIds != null){var ids = selectedIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x).ToArray();products.AddRange(await _productService.GetProductsByIds(ids, true));diff --git a/src/Web/Grand.Web.Vendor/Controllers/ShipmentController.cs b/src/Web/Grand.Web.Vendor/Controllers/ShipmentController.csindex 674431d06..14e474c86 100644--- a/src/Web/Grand.Web.Vendor/Controllers/ShipmentController.cs+++ b/src/Web/Grand.Web.Vendor/Controllers/ShipmentController.cs@@ -409,7 +409,7 @@ public class ShipmentController : BaseVendorControllerif (selectedIds != null){var ids = selectedIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).Select(x => x).ToArray();shipments.AddRange(await _shipmentService.GetShipmentsByIds(ids));diff --git a/src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs b/src/Web/Grand.Web.Vendor/Services/ProductViewModelService.csindex 6eeb92d53..de51077c7 100644--- a/src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs+++ b/src/Web/Grand.Web.Vendor/Services/ProductViewModelService.cs@@ -1568,7 +1568,7 @@ public class ProductViewModelService : IProductViewModelServiceif (!string.IsNullOrEmpty(cblAttributes)){var anyValueSelected = false;- foreach (var item in cblAttributes.Split(new[] { ',' },+ foreach (var item in cblAttributes.Split([','],StringSplitOptions.RemoveEmptyEntries))if (!string.IsNullOrEmpty(item)){@@ -1929,7 +1929,7 @@ public class ProductViewModelService : IProductViewModelServicevar cblAttributes = model.SelectedAttributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;if (!string.IsNullOrEmpty(cblAttributes))- foreach (var item in cblAttributes.Split(new[] { ',' },+ foreach (var item in cblAttributes.Split([','],StringSplitOptions.RemoveEmptyEntries))if (!string.IsNullOrEmpty(item))customAttributes = ProductExtensions.AddProductAttribute(diff --git a/src/Web/Grand.Web/Commands/Handler/Contact/ContactUsCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Contact/ContactUsCommandHandler.csindex de4325052..91b878535 100644--- a/src/Web/Grand.Web/Commands/Handler/Contact/ContactUsCommandHandler.cs+++ b/src/Web/Grand.Web/Commands/Handler/Contact/ContactUsCommandHandler.cs@@ -80,7 +80,7 @@ public class ContactUsCommandHandler : IRequestHandler<ContactUsCommand, Contactif (!string.IsNullOrEmpty(attribute.ValidationFileAllowedExtensions))attributeModel.AllowedFileExtensions = attribute.ValidationFileAllowedExtensions- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).ToList();if (attribute.ShouldHaveValues())diff --git a/src/Web/Grand.Web/Controllers/CheckoutController.cs b/src/Web/Grand.Web/Controllers/CheckoutController.csindex ddc99ea58..0f17f68c0 100644--- a/src/Web/Grand.Web/Controllers/CheckoutController.cs+++ b/src/Web/Grand.Web/Controllers/CheckoutController.cs@@ -844,9 +844,7 @@ public class CheckoutController : BasePublicController{var errors = new List<string>();var valuerrors = modelState.Where(entry => entry.Value.Errors.Any());- foreach (var item in valuerrors)- foreach (var er in item.Value.Errors)- errors.Add(er.ErrorMessage);+ foreach (var item in valuerrors) errors.AddRange(item.Value.Errors.Select(er => er.ErrorMessage));return errors;}diff --git a/src/Web/Grand.Web/Controllers/CommonController.cs b/src/Web/Grand.Web/Controllers/CommonController.csindex dbcbcc939..19c4a9d0c 100644--- a/src/Web/Grand.Web/Controllers/CommonController.cs+++ b/src/Web/Grand.Web/Controllers/CommonController.cs@@ -70,7 +70,7 @@ public class CommonController : BasePublicController_ = new PathString(url).StartsWithSegments(pathBase, out var result);url = WebUtility.UrlDecode(result);- var firstSegment = url.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ??+ var firstSegment = url.Split(['/'], StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ??string.Empty;if (string.IsNullOrEmpty(firstSegment))return false;@@ -366,9 +366,8 @@ public class CommonController : BasePublicController//save consent cookiesawait customerService.UpdateUserField(_workContext.CurrentCustomer, SystemCustomerFieldNames.ConsentCookies, "",_workContext.CurrentStore.Id);- var dictionary = new Dictionary<string, bool>();var consentCookies = cookiePreference.GetConsentCookies();- foreach (var item in consentCookies.Where(x => x.AllowToDisable)) dictionary.Add(item.SystemName, accept);+ var dictionary = consentCookies.Where(x => x.AllowToDisable).ToDictionary(item => item.SystemName, item => accept);if (dictionary.Any())await customerService.UpdateUserField(_workContext.CurrentCustomer, SystemCustomerFieldNames.ConsentCookies,diff --git a/src/Web/Grand.Web/Controllers/ContactController.cs b/src/Web/Grand.Web/Controllers/ContactController.csindex 0aa87d661..ddeae1c73 100644--- a/src/Web/Grand.Web/Controllers/ContactController.cs+++ b/src/Web/Grand.Web/Controllers/ContactController.cs@@ -149,7 +149,7 @@ public class ContactController : BasePublicControllerif (!string.IsNullOrEmpty(attribute.ValidationFileAllowedExtensions)){var allowedFileExtensions = attribute.ValidationFileAllowedExtensions.ToLowerInvariant()- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).ToList();if (!allowedFileExtensions.Contains(fileExtension.ToLowerInvariant()))return Json(new {diff --git a/src/Web/Grand.Web/Controllers/ProductController.cs b/src/Web/Grand.Web/Controllers/ProductController.csindex c5ee1c735..4fe591573 100644--- a/src/Web/Grand.Web/Controllers/ProductController.cs+++ b/src/Web/Grand.Web/Controllers/ProductController.cs@@ -413,7 +413,7 @@ public class ProductController : BasePublicControllerif (!string.IsNullOrEmpty(attribute.ValidationFileAllowedExtensions)){var allowedFileExtensions = attribute.ValidationFileAllowedExtensions.ToLowerInvariant()- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).ToList();if (!allowedFileExtensions.Contains(fileExtension.ToLowerInvariant()))return Json(new {diff --git a/src/Web/Grand.Web/Controllers/ShoppingCartController.cs b/src/Web/Grand.Web/Controllers/ShoppingCartController.csindex 794eb59a6..ce8a348b5 100644--- a/src/Web/Grand.Web/Controllers/ShoppingCartController.cs+++ b/src/Web/Grand.Web/Controllers/ShoppingCartController.cs@@ -202,7 +202,7 @@ public class ShoppingCartController : BasePublicControllerif (!string.IsNullOrEmpty(attribute.ValidationFileAllowedExtensions)){var allowedFileExtensions = attribute.ValidationFileAllowedExtensions.ToLowerInvariant()- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).ToList();if (!allowedFileExtensions.Contains(fileExtension.ToLowerInvariant()))return Json(new {diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCompareProductsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCompareProductsHandler.csindex 75ac1df96..2ee3e7645 100644--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetCompareProductsHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetCompareProductsHandler.cs@@ -73,10 +73,10 @@ public class GetCompareProductsHandler : IRequestHandler<GetCompareProducts, Com//try to get cookieif (!_httpContextAccessor.HttpContext!.Request.Cookies.TryGetValue(CacheKey.PRODUCTS_COMPARE_COOKIE_NAME,out var productIdsCookie) || string.IsNullOrEmpty(productIdsCookie))- return new List<string>();+ return [];//get array of string product identifiers from cookie- var productIds = productIdsCookie.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);+ var productIds = productIdsCookie.Split(['|'], StringSplitOptions.RemoveEmptyEntries);//return list of int product identifiersreturn productIds.Select(productId => productId).Distinct().Take(10).ToList();diff --git a/src/Web/Grand.Web/Features/Handlers/Catalog/GetViewSortSizeOptionsHandler.cs b/src/Web/Grand.Web/Features/Handlers/Catalog/GetViewSortSizeOptionsHandler.csindex 47b41c60e..68c09788f 100644--- a/src/Web/Grand.Web/Features/Handlers/Catalog/GetViewSortSizeOptionsHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Catalog/GetViewSortSizeOptionsHandler.cs@@ -106,7 +106,7 @@ public class GetViewSortSizeOptionsHandler : IRequestHandler<GetViewSortSizeOptiif (request.AllowCustomersToSelectPageSize && request.PageSizeOptions != null){var pageSizes =- request.PageSizeOptions.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);+ request.PageSizeOptions.Split([',', ' '], StringSplitOptions.RemoveEmptyEntries);if (pageSizes.Any()){diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.csindex 9416c71e8..136c44a33 100644--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs@@ -373,7 +373,7 @@ public class GetProductDetailsPageHandler : IRequestHandler<GetProductDetailsPagMpn = product.Mpn,ShowGtin = _catalogSettings.ShowGtin,Gtin = product.Gtin,- StockAvailability = StockAvailability(product, warehouseId, new List<CustomAttribute>()),+ StockAvailability = StockAvailability(product, warehouseId, []),UserFields = product.UserFields,HasSampleDownload = product.IsDownload && product.HasSampleDownload,DisplayDiscontinuedMessage =@@ -869,12 +869,12 @@ public class GetProductDetailsPageHandler : IRequestHandler<GetProductDetailsPag};if (!string.IsNullOrEmpty(attribute.ValidationFileAllowedExtensions))attributeModel.AllowedFileExtensions = attribute.ValidationFileAllowedExtensions- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).ToList();var urlselectedValues = !string.IsNullOrEmpty(productAttribute.SeName)? _httpContextAccessor.HttpContext.Request.Query[productAttribute.SeName].ToList()- : new List<string>();+ : [];if (attribute.ShouldHaveValues()){diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.csindex 8e76c7eba..b5202497f 100644--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetShoppingCartHandler.cs@@ -222,7 +222,7 @@ public class GetShoppingCartHandler : IRequestHandler<GetShoppingCart, ShoppingC};if (!string.IsNullOrEmpty(attribute.ValidationFileAllowedExtensions))attributeModel.AllowedFileExtensions = attribute.ValidationFileAllowedExtensions- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Split([','], StringSplitOptions.RemoveEmptyEntries).ToList();if (attribute.ShouldHaveValues())diff --git a/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs b/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.csindex 4438d6420..dba6d8fdb 100644--- a/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs+++ b/src/Web/Grand.Web/Models/Blogs/BlogPostTagListModel.cs@@ -8,9 +8,7 @@ public class BlogPostTagListModel : BaseModelpublic int GetFontSize(BlogPostTagModel blogPostTag){- var itemWeights = new List<double>();- foreach (var tag in Tags)- itemWeights.Add(tag.BlogPostCount);+ var itemWeights = Tags.Select(tag => tag.BlogPostCount).Select(dummy => (double)dummy).ToList();var stdDev = StdDev(itemWeights, out var mean);return GetFontSize(blogPostTag.BlogPostCount, mean, stdDev);diff --git a/src/Web/Grand.Web/Models/Catalog/CatalogPagingFilteringModel.cs b/src/Web/Grand.Web/Models/Catalog/CatalogPagingFilteringModel.csindex 1f4a03c1d..2daf5bffd 100644--- a/src/Web/Grand.Web/Models/Catalog/CatalogPagingFilteringModel.cs+++ b/src/Web/Grand.Web/Models/Catalog/CatalogPagingFilteringModel.cs@@ -68,7 +68,7 @@ public class CatalogPagingFilteringModel : BasePageableModel//comma separated list of parameters to excludeconst string excludedQueryStringParams = "pagenumber";var excludedQueryStringParamsSplitted =- excludedQueryStringParams.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);+ excludedQueryStringParams.Split([','], StringSplitOptions.RemoveEmptyEntries);foreach (var exclude in excludedQueryStringParamsSplitted)url = CommonExtensions.ModifyQueryString(url, exclude, null);return url;diff --git a/src/Web/Grand.Web/Models/Catalog/PopularProductTagsModel.cs b/src/Web/Grand.Web/Models/Catalog/PopularProductTagsModel.csindex 845fda908..9b2b48a01 100644--- a/src/Web/Grand.Web/Models/Catalog/PopularProductTagsModel.cs+++ b/src/Web/Grand.Web/Models/Catalog/PopularProductTagsModel.cs@@ -8,9 +8,7 @@ public class PopularProductTagsModel : BaseModelpublic virtual int GetFontSize(ProductTagModel productTag){- var itemWeights = new List<double>();- foreach (var tag in Tags)- itemWeights.Add(tag.ProductCount);+ var itemWeights = Tags.Select(tag => tag.ProductCount).Select(dummy => (double)dummy).ToList();var stdDev = StdDev(itemWeights, out var mean);return GetFontSize(productTag.ProductCount, mean, stdDev);