From f63771807621366808948e15d4e60d7420683d72 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Tue, 3 Dec 2024 15:23:27 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20#2521=20reported=20by=20@nirkal=20\n\n=20?= =?UTF-8?q?=E2=9C=A8=20(ServiceCollectionExtensions.cs,=20TfsGitRepository?= =?UTF-8?q?Tool.cs):=20add=20TfsChangeSetMappingTool=20to=20service=20coll?= =?UTF-8?q?ection=20and=20ensure=20required=20service=20retrieval?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add `TfsChangeSetMappingTool` to the service collection to enable its configuration and usage within the application. Change the retrieval method of `TfsChangeSetMappingTool` from `GetService` to `GetRequiredService` to ensure that the service is available and to prevent potential null reference exceptions. This change enhances the robustness and configurability of the application by ensuring necessary services are properly registered and retrieved. --- .../ServiceCollectionExtensions.cs | 3 ++- .../Tools/TfsGitRepositoryTool.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/MigrationTools.Clients.TfsObjectModel/ServiceCollectionExtensions.cs b/src/MigrationTools.Clients.TfsObjectModel/ServiceCollectionExtensions.cs index dd766e9e5..cd7408b49 100644 --- a/src/MigrationTools.Clients.TfsObjectModel/ServiceCollectionExtensions.cs +++ b/src/MigrationTools.Clients.TfsObjectModel/ServiceCollectionExtensions.cs @@ -30,6 +30,7 @@ public static void AddMigrationToolServicesForClientTfs_Tools(this IServiceColle context.AddSingleton().AddMigrationToolsOptions(configuration); context.AddSingleton().AddMigrationToolsOptions(configuration); context.AddSingleton().AddMigrationToolsOptions(configuration); + context.AddSingleton< TfsChangeSetMappingTool>().AddMigrationToolsOptions(configuration); } public static void AddMigrationToolServicesForClientTfs_Processors(this IServiceCollection context) @@ -93,4 +94,4 @@ public static void AddMigrationToolServicesForClientLegacyAzureDevOpsObjectModel context.AddTransient(); } } -} \ No newline at end of file +} diff --git a/src/MigrationTools.Clients.TfsObjectModel/Tools/TfsGitRepositoryTool.cs b/src/MigrationTools.Clients.TfsObjectModel/Tools/TfsGitRepositoryTool.cs index 6085d8174..b1889abf9 100644 --- a/src/MigrationTools.Clients.TfsObjectModel/Tools/TfsGitRepositoryTool.cs +++ b/src/MigrationTools.Clients.TfsObjectModel/Tools/TfsGitRepositoryTool.cs @@ -84,7 +84,7 @@ public int Enrich(TfsProcessor processor, WorkItemData sourceWorkItem, WorkItem } Log.LogInformation("GitRepositoryEnricher: Enriching {Id} To fix Git Repo Links", targetWorkItem.Id); - var changeSetMappings = Services.GetService(); + var changeSetMappings = Services.GetRequiredService(); List newEL = new List(); List removeEL = new List(); int count = 0;