From a6dd58c20f65eef782f4894c69726d6b36a76325 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Wed, 7 Feb 2024 10:04:22 -0800 Subject: [PATCH 1/3] Remove unnecessary argument in ThrowIfNullOrEmpty --- .../ContentItemExtensions.cs | 2 +- .../ContentDefinitionManager.cs | 12 ++++++------ .../OrchardCore.Data.YesSql/SqliteHelper.cs | 4 ++-- .../Views/ShapeViewModel.cs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/OrchardCore/OrchardCore.ContentManagement.Abstractions/ContentItemExtensions.cs b/src/OrchardCore/OrchardCore.ContentManagement.Abstractions/ContentItemExtensions.cs index d973f333d92..d0ce29c42d2 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.Abstractions/ContentItemExtensions.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.Abstractions/ContentItemExtensions.cs @@ -27,7 +27,7 @@ public static bool TryGet(this ContentItem contentItem, out TPart part) w /// true if a part found, otherwise false. public static bool TryGet(this ContentItem contentItem, string name, out TPart part) where TPart : ContentPart { - ArgumentException.ThrowIfNullOrEmpty(name, nameof(name)); + ArgumentException.ThrowIfNullOrEmpty(name); try { diff --git a/src/OrchardCore/OrchardCore.ContentManagement/ContentDefinitionManager.cs b/src/OrchardCore/OrchardCore.ContentManagement/ContentDefinitionManager.cs index 5374a105b02..96b5ded5d7c 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement/ContentDefinitionManager.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement/ContentDefinitionManager.cs @@ -70,7 +70,7 @@ public async Task> ListPartDefinitionsAsync() public async Task LoadTypeDefinitionAsync(string name) { - ArgumentException.ThrowIfNullOrEmpty(name, nameof(name)); + ArgumentException.ThrowIfNullOrEmpty(name); if (_scopedTypeDefinitions.TryGetValue(name, out var typeDefinition)) { @@ -84,7 +84,7 @@ public async Task LoadTypeDefinitionAsync(string name) public async Task GetTypeDefinitionAsync(string name) { - ArgumentException.ThrowIfNullOrEmpty(name, nameof(name)); + ArgumentException.ThrowIfNullOrEmpty(name); var document = await _contentDefinitionStore.GetContentDefinitionAsync(); @@ -95,7 +95,7 @@ public async Task GetTypeDefinitionAsync(string name) public async Task LoadPartDefinitionAsync(string name) { - ArgumentException.ThrowIfNullOrEmpty(name, nameof(name)); + ArgumentException.ThrowIfNullOrEmpty(name); if (_scopedPartDefinitions.TryGetValue(name, out var partDefinition)) { @@ -109,7 +109,7 @@ public async Task LoadPartDefinitionAsync(string name) public async Task GetPartDefinitionAsync(string name) { - ArgumentException.ThrowIfNullOrEmpty(name, nameof(name)); + ArgumentException.ThrowIfNullOrEmpty(name); var document = await _contentDefinitionStore.GetContentDefinitionAsync(); @@ -120,7 +120,7 @@ public async Task GetPartDefinitionAsync(string name) public async Task DeleteTypeDefinitionAsync(string name) { - ArgumentException.ThrowIfNullOrEmpty(name, nameof(name)); + ArgumentException.ThrowIfNullOrEmpty(name); var document = await _contentDefinitionStore.LoadContentDefinitionAsync(); @@ -136,7 +136,7 @@ public async Task DeleteTypeDefinitionAsync(string name) public async Task DeletePartDefinitionAsync(string name) { - ArgumentException.ThrowIfNullOrEmpty(name, nameof(name)); + ArgumentException.ThrowIfNullOrEmpty(name); var document = await _contentDefinitionStore.LoadContentDefinitionAsync(); diff --git a/src/OrchardCore/OrchardCore.Data.YesSql/SqliteHelper.cs b/src/OrchardCore/OrchardCore.Data.YesSql/SqliteHelper.cs index d0d5718b0d8..c29335176cd 100644 --- a/src/OrchardCore/OrchardCore.Data.YesSql/SqliteHelper.cs +++ b/src/OrchardCore/OrchardCore.Data.YesSql/SqliteHelper.cs @@ -43,8 +43,8 @@ public static string GetConnectionString(SqliteOptions sqliteOptions, string dat /// public static string GetConnectionString(SqliteOptions sqliteOptions, string databaseFolder, string databaseName, SqliteOpenMode sqliteOpenMode) { - ArgumentException.ThrowIfNullOrEmpty(databaseFolder, nameof(databaseFolder)); - ArgumentException.ThrowIfNullOrEmpty(databaseName, nameof(databaseName)); + ArgumentException.ThrowIfNullOrEmpty(databaseFolder); + ArgumentException.ThrowIfNullOrEmpty(databaseName); return GetSqliteConnectionStringBuilder(sqliteOptions, databaseFolder, databaseName, sqliteOpenMode).ToString(); } diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Views/ShapeViewModel.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Views/ShapeViewModel.cs index 109699a581d..c6b8ce84d72 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/Views/ShapeViewModel.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Views/ShapeViewModel.cs @@ -16,7 +16,7 @@ public ShapeViewModel() public ShapeViewModel(string shapeType) { - ArgumentException.ThrowIfNullOrEmpty(shapeType, nameof(shapeType)); + ArgumentException.ThrowIfNullOrEmpty(shapeType); Metadata.Type = shapeType; } From 5384dc99a275b25964daff207761d5e8b4338ad7 Mon Sep 17 00:00:00 2001 From: Hisham Bin Ateya Date: Wed, 7 Feb 2024 21:46:13 +0300 Subject: [PATCH 2/3] Cleanup OC.Search.AzureAI.Core --- .../Models/AzureAISearchIndexMap.cs | 2 +- .../Services/AzureAISearchIndexDocumentManager.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Models/AzureAISearchIndexMap.cs b/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Models/AzureAISearchIndexMap.cs index 5337fabdc93..d62dc39e881 100644 --- a/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Models/AzureAISearchIndexMap.cs +++ b/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Models/AzureAISearchIndexMap.cs @@ -21,7 +21,7 @@ public AzureAISearchIndexMap() public AzureAISearchIndexMap(string azureFieldKey, Types type) { - ArgumentException.ThrowIfNullOrEmpty(azureFieldKey, nameof(azureFieldKey)); + ArgumentException.ThrowIfNullOrEmpty(azureFieldKey); AzureFieldKey = azureFieldKey; Type = type; diff --git a/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Services/AzureAISearchIndexDocumentManager.cs b/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Services/AzureAISearchIndexDocumentManager.cs index f9a8e04f7d4..77027c013cd 100644 --- a/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Services/AzureAISearchIndexDocumentManager.cs +++ b/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Services/AzureAISearchIndexDocumentManager.cs @@ -32,8 +32,8 @@ public class AzureAIIndexDocumentManager( public async Task> SearchAsync(string indexName, string searchText, SearchOptions searchOptions = null) { - ArgumentException.ThrowIfNullOrEmpty(indexName, nameof(indexName)); - ArgumentException.ThrowIfNullOrWhiteSpace(searchText, nameof(searchText)); + ArgumentException.ThrowIfNullOrEmpty(indexName); + ArgumentException.ThrowIfNullOrWhiteSpace(searchText); var client = GetSearchClient(indexName); From a244cdbea93ac9dc061859cbbc3d3304d5bf880d Mon Sep 17 00:00:00 2001 From: Hisham Bin Ateya Date: Wed, 7 Feb 2024 21:47:16 +0300 Subject: [PATCH 3/3] Cleanup ElasticsearchIndexPermissionHelper --- .../ElasticsearchIndexPermissionHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs index b65910fc713..c006a987f47 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/ElasticsearchIndexPermissionHelper.cs @@ -14,7 +14,7 @@ public class ElasticsearchIndexPermissionHelper public static Permission GetElasticIndexPermission(string indexName) { - ArgumentException.ThrowIfNullOrEmpty(indexName, nameof(indexName)); + ArgumentException.ThrowIfNullOrEmpty(indexName); if (!_permissions.TryGetValue(indexName, out var permission)) {