diff --git a/MigrationTools.sln b/MigrationTools.sln index d0209cc7e..1d248ae92 100644 --- a/MigrationTools.sln +++ b/MigrationTools.sln @@ -126,7 +126,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{88C358 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{BB497233-248C-49DF-AE12-F7A76F775E74}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NKDAgility.AzureDevOps.Tools.CommandHost", "src\NKDAgility.AzureDevOps.Tools.CommandHost\NKDAgility.AzureDevOps.Tools.CommandHost.csproj", "{60EF98A1-5AA4-4589-8B6F-A77B3940025D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NKDAgility.AzureDevOps.Tools.CommandHost", "src\NKDAgility.AzureDevOps.Tools.CommandHost\NKDAgility.AzureDevOps.Tools.CommandHost.csproj", "{60EF98A1-5AA4-4589-8B6F-A77B3940025D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MigrationTools.Helpers.Tests", "src\MigrationTools.Fakes\MigrationTools.Helpers.Tests.csproj", "{EB20ED85-8876-4585-BC90-E6976C11DEE3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -214,6 +216,10 @@ Global {60EF98A1-5AA4-4589-8B6F-A77B3940025D}.Debug|Any CPU.Build.0 = Debug|Any CPU {60EF98A1-5AA4-4589-8B6F-A77B3940025D}.Release|Any CPU.ActiveCfg = Release|Any CPU {60EF98A1-5AA4-4589-8B6F-A77B3940025D}.Release|Any CPU.Build.0 = Release|Any CPU + {EB20ED85-8876-4585-BC90-E6976C11DEE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB20ED85-8876-4585-BC90-E6976C11DEE3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB20ED85-8876-4585-BC90-E6976C11DEE3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB20ED85-8876-4585-BC90-E6976C11DEE3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -248,6 +254,7 @@ Global {AC3B5101-83F5-4C28-976C-C325425D1988} = {1F5E9C8C-AD05-4C4F-B370-FF3D080A6541} {BB497233-248C-49DF-AE12-F7A76F775E74} = {83F36820-E9BC-4F48-8202-5EAF9530405E} {60EF98A1-5AA4-4589-8B6F-A77B3940025D} = {BB497233-248C-49DF-AE12-F7A76F775E74} + {EB20ED85-8876-4585-BC90-E6976C11DEE3} = {BB497233-248C-49DF-AE12-F7A76F775E74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {62EE0B27-C55A-46EE-8D17-1691DE9BBD50} diff --git a/docs/Reference/Generated/MigrationTools.xml b/docs/Reference/Generated/MigrationTools.xml index d51c4e74b..a0b92ea79 100644 --- a/docs/Reference/Generated/MigrationTools.xml +++ b/docs/Reference/Generated/MigrationTools.xml @@ -344,6 +344,41 @@ + + + A work item query based on WIQL to select only important work items. To migrate all leave this empty. See [WIQL Query Bits](#wiql-query-bits) + + AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') + + + + A list of work items to import + + [] + + + + This loads all of the work items already saved to the Target and removes them from the Source work item list prior to commencing the run. + While this may take some time in large data sets it reduces the time of the overall migration significantly if you need to restart. + + true + + + + Pause after each work item is migrated + + false + + + + **beta** If set to a number greater than 0 work items that fail to save will retry after a number of seconds equal to the retry count. + This allows for periodic network glitches not to end the process. + + 5 + + + + @@ -541,41 +576,6 @@ - - - A work item query based on WIQL to select only important work items. To migrate all leave this empty. See [WIQL Query Bits](#wiql-query-bits) - - AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') - - - - A list of work items to import - - [] - - - - This loads all of the work items already saved to the Target and removes them from the Source work item list prior to commencing the run. - While this may take some time in large data sets it reduces the time of the overall migration significantly if you need to restart. - - true - - - - Pause after each work item is migrated - - false - - - - **beta** If set to a number greater than 0 work items that fail to save will retry after a number of seconds equal to the retry count. - This allows for periodic network glitches not to end the process. - - 5 - - - - from https://gist.github.com/pietergheysens/792ed505f09557e77ddfc1b83531e4fb @@ -594,7 +594,7 @@ - => @"false" + => @"true" @@ -604,32 +604,32 @@ - => @"topic/move-cmd" + => @"feature/small-changes-group-1" - => @"3a2c737" + => @"0e5f65f" - => @"3a2c737011911c5b1e68261733d02c1ef8f40cc1" + => @"0e5f65ff4368b8da72e7e64991c4d0a095637a02" - => @"2024-07-25T13:50:46+01:00" + => @"2024-07-26T14:20:01+01:00" - => @"11" + => @"26" - => @"v15.1.5-Preview.2-11-g3a2c737" + => @"v15.1.5-Preview.2-26-g0e5f65f" @@ -664,7 +664,7 @@ - => @"16" + => @"31" diff --git a/docs/Reference/Generated/VstsSyncMigrator.Core.xml b/docs/Reference/Generated/VstsSyncMigrator.Core.xml index 63c78e83e..c415a50c4 100644 --- a/docs/Reference/Generated/VstsSyncMigrator.Core.xml +++ b/docs/Reference/Generated/VstsSyncMigrator.Core.xml @@ -123,18 +123,18 @@ alpha Profiles - + - The `WorkItemDelete` processor allows you to delete any amount of work items that meet the query. - **DANGER:** This is not a recoverable action and should be use with extream caution. + This processor allows you to make changes in place where we load from teh Target and update the Target. This is used for bulk updates with the most common reason being a process template change. - ready WorkItem - + - This processor allows you to make changes in place where we load from teh Target and update the Target. This is used for bulk updates with the most common reason being a process template change. + The `WorkItemDelete` processor allows you to delete any amount of work items that meet the query. + **DANGER:** This is not a recoverable action and should be use with extream caution. + ready WorkItem diff --git a/docs/_data/reference.v1.processors.workitemupdate.yaml b/docs/_data/reference.v1.processors.workitembulkeditprocessor.yaml similarity index 90% rename from docs/_data/reference.v1.processors.workitemupdate.yaml rename to docs/_data/reference.v1.processors.workitembulkeditprocessor.yaml index 8b64b0fd6..6d4f96c92 100644 --- a/docs/_data/reference.v1.processors.workitemupdate.yaml +++ b/docs/_data/reference.v1.processors.workitembulkeditprocessor.yaml @@ -1,11 +1,11 @@ -optionsClassName: WorkItemUpdateConfig -optionsClassFullName: MigrationTools._EngineV1.Configuration.Processing.WorkItemUpdateConfig +optionsClassName: WorkItemBulkEditProcessorConfig +optionsClassFullName: MigrationTools._EngineV1.Configuration.Processing.WorkItemBulkEditProcessorConfig configurationSamples: - name: default description: code: >- { - "$type": "WorkItemUpdateConfig", + "$type": "WorkItemBulkEditProcessorConfig", "Enabled": false, "WhatIf": false, "WIQLQuery": "SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [@ReflectedWorkItemIdFieldName] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') ORDER BY [System.ChangedDate] desc", @@ -14,9 +14,9 @@ configurationSamples: "PauseAfterEachWorkItem": false, "WorkItemCreateRetryLimit": 0 } - sampleFor: MigrationTools._EngineV1.Configuration.Processing.WorkItemUpdateConfig + sampleFor: MigrationTools._EngineV1.Configuration.Processing.WorkItemBulkEditProcessorConfig description: This processor allows you to make changes in place where we load from teh Target and update the Target. This is used for bulk updates with the most common reason being a process template change. -className: WorkItemUpdate +className: WorkItemBulkEditProcessor typeName: Processors architecture: v1 options: @@ -50,5 +50,5 @@ options: defaultValue: '[]' status: missng XML code comments processingTarget: WorkItem -classFile: /src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemUpdate.cs -optionsClassFile: /src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemUpdateConfig.cs +classFile: /src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemBulkEditProcessor.cs +optionsClassFile: /src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemBulkEditProcessorConfig.cs diff --git a/docs/collections/_reference/reference.v1.processors.workitemupdate.md b/docs/collections/_reference/reference.v1.processors.workitembulkeditprocessor.md similarity index 84% rename from docs/collections/_reference/reference.v1.processors.workitemupdate.md rename to docs/collections/_reference/reference.v1.processors.workitembulkeditprocessor.md index 6dda7c76b..a1be1281c 100644 --- a/docs/collections/_reference/reference.v1.processors.workitemupdate.md +++ b/docs/collections/_reference/reference.v1.processors.workitembulkeditprocessor.md @@ -1,12 +1,12 @@ --- -optionsClassName: WorkItemUpdateConfig -optionsClassFullName: MigrationTools._EngineV1.Configuration.Processing.WorkItemUpdateConfig +optionsClassName: WorkItemBulkEditProcessorConfig +optionsClassFullName: MigrationTools._EngineV1.Configuration.Processing.WorkItemBulkEditProcessorConfig configurationSamples: - name: default description: code: >- { - "$type": "WorkItemUpdateConfig", + "$type": "WorkItemBulkEditProcessorConfig", "Enabled": false, "WhatIf": false, "WIQLQuery": "SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [@ReflectedWorkItemIdFieldName] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') ORDER BY [System.ChangedDate] desc", @@ -15,9 +15,9 @@ configurationSamples: "PauseAfterEachWorkItem": false, "WorkItemCreateRetryLimit": 0 } - sampleFor: MigrationTools._EngineV1.Configuration.Processing.WorkItemUpdateConfig + sampleFor: MigrationTools._EngineV1.Configuration.Processing.WorkItemBulkEditProcessorConfig description: This processor allows you to make changes in place where we load from teh Target and update the Target. This is used for bulk updates with the most common reason being a process template change. -className: WorkItemUpdate +className: WorkItemBulkEditProcessor typeName: Processors architecture: v1 options: @@ -51,24 +51,23 @@ options: defaultValue: '[]' status: missng XML code comments processingTarget: WorkItem -classFile: /src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemUpdate.cs -optionsClassFile: /src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemUpdateConfig.cs - +classFile: /src/VstsSyncMigrator.Core/Execution/ProcessingContext/WorkItemBulkEditProcessor.cs +optionsClassFile: /src/MigrationTools/_EngineV1/Configuration/Processing/WorkItemBulkEditProcessorConfig.cs redirectFrom: [] layout: reference toc: true -permalink: /Reference/v1/Processors/WorkItemUpdate/ -title: WorkItemUpdate +permalink: /Reference/v1/Processors/WorkItemBulkEditProcessor/ +title: WorkItemBulkEditProcessor categories: - Processors - v1 topics: - topic: notes - path: /docs/Reference/v1/Processors/WorkItemUpdate-notes.md + path: /docs/Reference/v1/Processors/WorkItemBulkEditProcessor-notes.md exists: false markdown: '' - topic: introduction - path: /docs/Reference/v1/Processors/WorkItemUpdate-introduction.md + path: /docs/Reference/v1/Processors/WorkItemBulkEditProcessor-introduction.md exists: false markdown: '' diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Endpoints/TfsWorkItemEndPointTests.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Endpoints/TfsWorkItemEndPointTests.cs index 63b4712bd..4561ea89c 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Endpoints/TfsWorkItemEndPointTests.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Endpoints/TfsWorkItemEndPointTests.cs @@ -19,7 +19,7 @@ public void Setup() Services = ServiceProviderHelper.GetServices(); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L3")] public void TfsWorkItemEndPointTest() { var endpoint = Services.GetRequiredService(); @@ -28,7 +28,7 @@ public void TfsWorkItemEndPointTest() Assert.IsNotNull(endpoint); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L3")] public void TfsWorkItemEndPointConfigureTest() { var endpoint = Services.GetRequiredService(); @@ -36,7 +36,7 @@ public void TfsWorkItemEndPointConfigureTest() Assert.IsNotNull(endpoint); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L3")] public void TfsWorkItemEndPointGetWorkItemsTest() { var endpoint = Services.GetRequiredService(); @@ -45,7 +45,7 @@ public void TfsWorkItemEndPointGetWorkItemsTest() Assert.AreEqual(13, result.Count()); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L3")] public void TfsWorkItemEndPointGetWorkItemsQueryTest() { TfsWorkItemEndpoint endpoint = Services.GetRequiredService(); diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/MigrationTools.Clients.AzureDevops.ObjectModel.Tests.csproj b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/MigrationTools.Clients.AzureDevops.ObjectModel.Tests.csproj index 5d9ce7e47..de4d64e22 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/MigrationTools.Clients.AzureDevops.ObjectModel.Tests.csproj +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/MigrationTools.Clients.AzureDevops.ObjectModel.Tests.csproj @@ -27,6 +27,7 @@ + diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsNodeStructureTests.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsNodeStructureTests.cs index 8ef065246..80fb971c4 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsNodeStructureTests.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsNodeStructureTests.cs @@ -37,7 +37,7 @@ public void Setup() }); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void GetTfsNodeStructure_WithDifferentAreaPath() { var nodeStructure = _services.GetRequiredService(); diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsRevisionManagerTests.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsRevisionManagerTests.cs index a31a86569..83ebad318 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsRevisionManagerTests.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ProcessorEnrichers/TfsRevisionManagerTests.cs @@ -45,7 +45,7 @@ private static List GetWorkItemWithRevisions(DateTime currentDateT } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerInSync1() { var peOptions = GetTfsRevisionManagerOptions(); @@ -62,7 +62,7 @@ public void TfsRevisionManagerInSync1() } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerInSync10() { var peOptions = GetTfsRevisionManagerOptions(); @@ -79,7 +79,7 @@ public void TfsRevisionManagerInSync10() } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerSync1() { var peOptions = GetTfsRevisionManagerOptions(); @@ -95,7 +95,7 @@ public void TfsRevisionManagerSync1() Assert.AreEqual(1, revs.Count); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerSync10() { var peOptions = GetTfsRevisionManagerOptions(); @@ -111,7 +111,7 @@ public void TfsRevisionManagerSync10() Assert.AreEqual(10, revs.Count); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerReplayRevisionsOff() { var peOptions = GetTfsRevisionManagerOptions(); @@ -129,7 +129,7 @@ public void TfsRevisionManagerReplayRevisionsOff() } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerMaxRevision51() { var peOptions = GetTfsRevisionManagerOptions(); @@ -146,7 +146,7 @@ public void TfsRevisionManagerMaxRevision51() Assert.AreEqual(0, revs.Count); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerMaxRevision56() { var peOptions = GetTfsRevisionManagerOptions(); @@ -163,7 +163,7 @@ public void TfsRevisionManagerMaxRevision56() Assert.AreEqual(5, revs.Count); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerMaxRevision59() { var peOptions = GetTfsRevisionManagerOptions(); @@ -179,7 +179,7 @@ public void TfsRevisionManagerMaxRevision59() Assert.AreEqual(5, revs.Count); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsRevisionManagerDatesMustBeIncreasing() { var peOptions = GetTfsRevisionManagerOptions(); diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsSharedQueryProcessorTests.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsSharedQueryProcessorTests.cs index 176dc3f9b..2ce4cbd15 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsSharedQueryProcessorTests.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsSharedQueryProcessorTests.cs @@ -9,14 +9,14 @@ namespace MigrationTools.Processors.Tests [TestClass()] public class TfsSharedQueryProcessorTests : TfsProcessorTests { - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsSharedQueryProcessorTest() { var x = Services.GetRequiredService(); Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsSharedQueryProcessorConfigureTest() { var y = new TfsSharedQueryProcessorOptions @@ -31,7 +31,7 @@ public void TfsSharedQueryProcessorConfigureTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsSharedQueryProcessorRunTest() { var y = new TfsSharedQueryProcessorOptions @@ -46,7 +46,7 @@ public void TfsSharedQueryProcessorRunTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L3")] public void TfsSharedQueryProcessorNoEnrichersTest() { // Senario 1 Migration from Tfs to Tfs with no Enrichers. diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsTeamSettingsProcessorTests.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsTeamSettingsProcessorTests.cs index d9a86b241..3a8ddb8e8 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsTeamSettingsProcessorTests.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/Processors/TfsTeamSettingsProcessorTests.cs @@ -6,14 +6,14 @@ namespace MigrationTools.Processors.Tests [TestClass()] public class TfsTeamSettingsProcessorTests : TfsProcessorTests { - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsTeamSettingsProcessorTest() { var x = Services.GetRequiredService(); Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsTeamSettingsProcessorConfigureTest() { var y = new TfsTeamSettingsProcessorOptions @@ -30,7 +30,7 @@ public void TfsTeamSettingsProcessorConfigureTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L0")] public void TfsTeamSettingsProcessorRunTest() { var y = new TfsTeamSettingsProcessorOptions @@ -47,7 +47,7 @@ public void TfsTeamSettingsProcessorRunTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.ObjectModel")] + [TestMethod(), TestCategory("L3")] public void TfsTeamSettingsProcessorNoEnrichersTest() { // Senario 1 Migration from Tfs to Tfs with no Enrichers. diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ServiceProviderHelper.cs index 19ab26968..2375fa7a2 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ServiceProviderHelper.cs @@ -1,6 +1,8 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using MigrationTools.Endpoints; +using MigrationTools.Fakes; +using MigrationTools.Services; using MigrationTools.TestExtensions; namespace MigrationTools.Tests @@ -23,6 +25,9 @@ public static ServiceProvider GetServices() AddTfsTeamEndpoint(services, "TfsTeamSettingsSource", "migrationSource1"); AddTfsTeamEndpoint(services, "TfsTeamSettingsTarget", "migrationTarget1"); + services.AddSingleton(); + services.AddSingleton(); + return services.BuildServiceProvider(); } diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel/_Enginev1/Clients/TfsMigrationClient.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel/_Enginev1/Clients/TfsMigrationClient.cs index 91afb77c1..1199b65a5 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel/_Enginev1/Clients/TfsMigrationClient.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel/_Enginev1/Clients/TfsMigrationClient.cs @@ -175,7 +175,7 @@ private TfsTeamProjectCollection GetDependantTfsCollection(NetworkCredential cre new Dictionary { { "Time",timer.ElapsedMilliseconds } }); - Log.Error(ex, "Unable to configure store: Check persmissions and credentials for {AuthenticationMode}!", _config.AuthenticationMode); + Log.Error("Unable to configure store: Check persmissions and credentials for {AuthenticationMode}: " + ex.Message, _config.AuthenticationMode); switch (_config.AuthenticationMode) { case AuthenticationMode.AccessToken: diff --git a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj index 1fa84dae1..d6e5a72e3 100644 --- a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj +++ b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj @@ -19,6 +19,8 @@ + + diff --git a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/Processors/AzureDevOpsPipelineProcessorTests.cs b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/Processors/AzureDevOpsPipelineProcessorTests.cs index 9a26eb8f1..b9c28cd75 100644 --- a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/Processors/AzureDevOpsPipelineProcessorTests.cs +++ b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/Processors/AzureDevOpsPipelineProcessorTests.cs @@ -11,14 +11,14 @@ namespace MigrationTools.Processors.Tests [TestClass()] public class AzureDevOpsPipelineProcessorTests : AzureDevOpsProcessorTests { - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.REST")] + [TestMethod(), TestCategory("L0")] public void AzureDevOpsPipelineProcessorTest() { var x = Services.GetRequiredService(); Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.REST")] + [TestMethod(), TestCategory("L0")] public void AzureDevOpsPipelineProcessorConfigureTest() { var y = new AzureDevOpsPipelineProcessorOptions @@ -32,7 +32,7 @@ public void AzureDevOpsPipelineProcessorConfigureTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L0"), TestCategory("AzureDevOps.REST")] + [TestMethod(), TestCategory("L0")] public void AzureDevOpsPipelineProcessorRunTest() { var y = new AzureDevOpsPipelineProcessorOptions @@ -46,7 +46,7 @@ public void AzureDevOpsPipelineProcessorRunTest() Assert.IsNotNull(x); } - [TestMethod(), TestCategory("L3"), TestCategory("AzureDevOps.REST")] + [TestMethod(), TestCategory("L3")] public void AzureDevOpsPipelineProcessorNoEnrichersTest() { // Senario 1 Migration from Tfs to Tfs with no Enrichers. @@ -57,7 +57,7 @@ public void AzureDevOpsPipelineProcessorNoEnrichersTest() Assert.AreEqual(ProcessingStatus.Complete, processor.Status); } - [TestMethod, TestCategory("L3"), TestCategory("AzureDevOps.REST")] + [TestMethod, TestCategory("L3")] public void AzureDevOpsPipelineProcessorSelectedBuildDefinitionsTest() { var config = new AzureDevOpsPipelineProcessorOptions @@ -89,7 +89,7 @@ public void AzureDevOpsPipelineProcessorSelectedBuildDefinitionsTest() Assert.AreEqual(2, InMemorySink.Instance.LogEvents.Count(configuredMessageFilter)); } - [TestMethod, TestCategory("L3"), TestCategory("AzureDevOps.REST")] + [TestMethod, TestCategory("L3")] public void AzureDevOpsPipelineProcessorSelectedReleaseDefinitionsTest() { var config = new AzureDevOpsPipelineProcessorOptions diff --git a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/ServiceProviderHelper.cs index 12fc32133..0ffb0b124 100644 --- a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/ServiceProviderHelper.cs @@ -1,6 +1,8 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using MigrationTools.Endpoints; +using MigrationTools.Fakes; +using MigrationTools.Services; using MigrationTools.TestExtensions; namespace MigrationTools.Tests @@ -15,9 +17,13 @@ internal static ServiceProvider GetServices() services.AddMigrationToolServices(); services.AddMigrationToolServicesForClientAzureDevopsRest(configuration); + AddEndpoint(services, "Source", "migrationSource1"); AddEndpoint(services, "Target", "migrationTarget1"); + services.AddSingleton(); + services.AddSingleton(); + return services.BuildServiceProvider(); } diff --git a/src/MigrationTools.Clients.FileSystem.Tests/MigrationTools.Clients.FileSystem.Tests.csproj b/src/MigrationTools.Clients.FileSystem.Tests/MigrationTools.Clients.FileSystem.Tests.csproj index 4558dd485..79ad15394 100644 --- a/src/MigrationTools.Clients.FileSystem.Tests/MigrationTools.Clients.FileSystem.Tests.csproj +++ b/src/MigrationTools.Clients.FileSystem.Tests/MigrationTools.Clients.FileSystem.Tests.csproj @@ -22,6 +22,7 @@ + diff --git a/src/MigrationTools.Clients.FileSystem.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Clients.FileSystem.Tests/ServiceProviderHelper.cs index 58b89be60..c9a23d53f 100644 --- a/src/MigrationTools.Clients.FileSystem.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Clients.FileSystem.Tests/ServiceProviderHelper.cs @@ -1,4 +1,6 @@ using Microsoft.Extensions.DependencyInjection; +using MigrationTools.Fakes; +using MigrationTools.Services; using MigrationTools.TestExtensions; namespace MigrationTools.Tests @@ -13,6 +15,9 @@ internal static ServiceProvider GetServices() services.AddMigrationToolServices(); services.AddMigrationToolServicesForClientFileSystem(); + services.AddSingleton(); + services.AddSingleton(); + return services.BuildServiceProvider(); } } diff --git a/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj b/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj index 51b90f725..dd0a554e0 100644 --- a/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj +++ b/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj @@ -22,6 +22,8 @@ + + diff --git a/src/MigrationTools.Clients.InMemory.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Clients.InMemory.Tests/ServiceProviderHelper.cs index 651ce61ab..418b09d02 100644 --- a/src/MigrationTools.Clients.InMemory.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Clients.InMemory.Tests/ServiceProviderHelper.cs @@ -1,4 +1,6 @@ using Microsoft.Extensions.DependencyInjection; +using MigrationTools.Fakes; +using MigrationTools.Services; using MigrationTools.TestExtensions; namespace MigrationTools.Tests @@ -13,6 +15,9 @@ internal static ServiceProvider GetServices() services.AddMigrationToolServices(); services.AddMigrationToolServicesForClientInMemory(); + services.AddSingleton(); + services.AddSingleton(); + return services.BuildServiceProvider(); } } diff --git a/src/MigrationTools.Fakes/FakeMigrationToolVersion.cs b/src/MigrationTools.Fakes/FakeMigrationToolVersion.cs new file mode 100644 index 000000000..dabe9cd68 --- /dev/null +++ b/src/MigrationTools.Fakes/FakeMigrationToolVersion.cs @@ -0,0 +1,12 @@ +using MigrationTools.Services; + +namespace MigrationTools.Fakes +{ + public class FakeMigrationToolVersion : IMigrationToolVersion + { + public (Version version, string PreReleaseLabel, string versionString) GetRunningVersion() + { + return (new System.Version("0.0.0"), "test", "0.0.0-test"); + } + } +} \ No newline at end of file diff --git a/src/MigrationTools.Fakes/FakeMigrationToolVersionInfo.cs b/src/MigrationTools.Fakes/FakeMigrationToolVersionInfo.cs new file mode 100644 index 000000000..f20f8cdfb --- /dev/null +++ b/src/MigrationTools.Fakes/FakeMigrationToolVersionInfo.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using MigrationTools.Services; + +namespace MigrationTools.Fakes +{ + public class FakeMigrationToolVersionInfo : MigrationToolVersionInfo + { + public FakeMigrationToolVersionInfo() + { + ProductVersion = "0.0.0-test+7acec2e6266f5f05b2807264ee8f1db7b94b1949"; + FileVersion = "0.0.0.0"; + GitTag = "v0.0.0-test.0-0-g7acec2e"; + } + public FakeMigrationToolVersionInfo(string productVersion, string fileVersion, string gitTag) + { + ProductVersion = productVersion; + FileVersion = fileVersion; + GitTag = gitTag; + } + } +} diff --git a/src/MigrationTools.Fakes/MigrationTools.Helpers.Tests.csproj b/src/MigrationTools.Fakes/MigrationTools.Helpers.Tests.csproj new file mode 100644 index 000000000..4bb328964 --- /dev/null +++ b/src/MigrationTools.Fakes/MigrationTools.Helpers.Tests.csproj @@ -0,0 +1,17 @@ + + + + netstandard2.0;net8.0 + enable + enable + + + + + + + + + + + diff --git a/src/MigrationTools.Host.Tests/MigrationHostTests.cs b/src/MigrationTools.Host.Tests/MigrationHostTests.cs index bb97d24d6..541513ccd 100644 --- a/src/MigrationTools.Host.Tests/MigrationHostTests.cs +++ b/src/MigrationTools.Host.Tests/MigrationHostTests.cs @@ -16,14 +16,14 @@ public void Setup() host = MigrationToolHost.CreateDefaultBuilder(new string[] { "execute", "-c", "configuration.json" }).Build(); } - [TestMethod, TestCategory("L2"), TestCategory("Host")] + [TestMethod, TestCategory("L2")] [Ignore("need to ignore for now, missing a good config file for non-objectmodel")] public void MigrationHostTest() { IMigrationEngine mh = host.Services.GetRequiredService(); } - [TestMethod, TestCategory("L1"), TestCategory("Host")] + [TestMethod, TestCategory("L1")] [Ignore("need to ignore for now, untill we get some generic field maps")] public void TestEngineExecuteEmptyProcessors() { @@ -33,7 +33,7 @@ public void TestEngineExecuteEmptyProcessors() me.Run(); } - [TestMethod, TestCategory("L1"), TestCategory("Host")] + [TestMethod, TestCategory("L1")] [Ignore("need to ignore for now, missing a good config file for non-objectmodel")] public void TestEngineExecuteEmptyFieldMaps() { @@ -44,7 +44,7 @@ public void TestEngineExecuteEmptyFieldMaps() me.Run(); } - [TestMethod, TestCategory("L3"), TestCategory("L2"), TestCategory("Host")] + [TestMethod, TestCategory("L3"), TestCategory("L2")] [Ignore("need to ignore for now, missing a good config file for non-objectmodel")] public void TestEngineExecuteProcessors() { diff --git a/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj b/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj index 757a1e4c5..c70cc31c0 100644 --- a/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj +++ b/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj @@ -26,6 +26,7 @@ + diff --git a/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs b/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs index 25338dfed..dacdd87dc 100644 --- a/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs +++ b/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs @@ -1,9 +1,13 @@ -using Microsoft.Extensions.DependencyInjection; +using MigrationTools.Host.Services; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; using MigrationTools.Services; using Serilog; using Serilog.Events; +using MigrationTools.Host.Tests; +using MigrationTools.Tests; +using MigrationTools.Fakes; namespace MigrationTools.Host.Services.Tests { @@ -26,11 +30,10 @@ public void Setup() public void DetectVersionServiceTest_Initialise() { var loggerFactory = new LoggerFactory().AddSerilog(); - IDetectVersionService2 dos = new DetectVersionService2(new TelemetryLoggerMock(), new Logger(loggerFactory)); + IDetectVersionService2 dos = new DetectVersionService2(new TelemetryLoggerMock(), new Logger(loggerFactory), new FakeMigrationToolVersion()); Assert.IsNotNull(dos); } - } } \ No newline at end of file diff --git a/src/MigrationTools.Host/Commands/CommandBase.cs b/src/MigrationTools.Host/Commands/CommandBase.cs index 29dfc42e3..0a45657a0 100644 --- a/src/MigrationTools.Host/Commands/CommandBase.cs +++ b/src/MigrationTools.Host/Commands/CommandBase.cs @@ -9,6 +9,7 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using MigrationTools.Host.Services; +using MigrationTools.Services; using Serilog; using Spectre.Console; using Spectre.Console.Cli; @@ -17,6 +18,7 @@ namespace MigrationTools.Host.Commands { internal abstract class CommandBase : AsyncCommand where TSettings : CommandSettingsBase { + private IMigrationToolVersion _MigrationToolVersion; private readonly IHostApplicationLifetime _LifeTime; private readonly IDetectOnlineService _detectOnlineService; private readonly IDetectVersionService2 _detectVersionService; @@ -24,8 +26,9 @@ internal abstract class CommandBase : AsyncCommand where T private readonly ITelemetryLogger _telemetryLogger; private static Stopwatch _mainTimer = new Stopwatch(); - public CommandBase(IHostApplicationLifetime appLifetime, IDetectOnlineService detectOnlineService, IDetectVersionService2 detectVersionService, ILogger> logger, ITelemetryLogger telemetryLogger) + public CommandBase(IHostApplicationLifetime appLifetime, IDetectOnlineService detectOnlineService, IDetectVersionService2 detectVersionService, ILogger> logger, ITelemetryLogger telemetryLogger, IMigrationToolVersion migrationToolVersion) { + _MigrationToolVersion = migrationToolVersion; _LifeTime = appLifetime; _detectOnlineService = detectOnlineService; _detectVersionService = detectVersionService; @@ -138,12 +141,12 @@ public void RunStartupLogic(TSettings settings) private void ApplicationStartup( TSettings settings) { _mainTimer.Start(); - AsciiLogo(DetectVersionService2.GetRunningVersion().versionString); + AsciiLogo(_MigrationToolVersion.GetRunningVersion().versionString); TelemetryNote(); _logger.LogInformation("Start Time: {StartTime}", DateTime.Now.ToUniversalTime().ToLocalTime()); _logger.LogInformation("Running with settings: {@settings}", settings); _logger.LogInformation("OSVersion: {OSVersion}", Environment.OSVersion.ToString()); - _logger.LogInformation("Version (Assembly): {Version}", DetectVersionService2.GetRunningVersion().versionString); + _logger.LogInformation("Version (Assembly): {Version}", _MigrationToolVersion.GetRunningVersion().versionString); } private void TelemetryNote() diff --git a/src/MigrationTools.Host/Commands/ExecuteMigrationCommand.cs b/src/MigrationTools.Host/Commands/ExecuteMigrationCommand.cs index 2ef1afa75..2f1fa0c64 100644 --- a/src/MigrationTools.Host/Commands/ExecuteMigrationCommand.cs +++ b/src/MigrationTools.Host/Commands/ExecuteMigrationCommand.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging; using MigrationTools.Host.Commands; using MigrationTools.Host.Services; +using MigrationTools.Services; using Spectre.Console.Cli; namespace MigrationTools.Host.Commands @@ -20,7 +21,7 @@ internal class ExecuteMigrationCommand : CommandBase logger, - IHostApplicationLifetime appLifetime, ITelemetryLogger telemetryLogger, IDetectOnlineService detectOnlineService, IDetectVersionService2 detectVersionService) : base(appLifetime, detectOnlineService, detectVersionService, logger, telemetryLogger) + IHostApplicationLifetime appLifetime, ITelemetryLogger telemetryLogger, IDetectOnlineService detectOnlineService, IDetectVersionService2 detectVersionService, IMigrationToolVersion migrationToolVersion) : base(appLifetime, detectOnlineService, detectVersionService, logger, telemetryLogger, migrationToolVersion) { Telemetery = telemetryLogger; _services = services; diff --git a/src/MigrationTools.Host/MigrationToolHost.cs b/src/MigrationTools.Host/MigrationToolHost.cs index c20b79e62..18c153bed 100644 --- a/src/MigrationTools.Host/MigrationToolHost.cs +++ b/src/MigrationTools.Host/MigrationToolHost.cs @@ -24,42 +24,49 @@ using MigrationTools.Host.Commands; using System.Diagnostics; using System.Text.RegularExpressions; +using MigrationTools.Services; namespace MigrationTools.Host { + + + public static class MigrationToolHost { static int logs = 1; + private static bool LoggerHasBeenBuilt = false; public static IHostBuilder CreateDefaultBuilder(string[] args) { var configFile = CommandSettingsBase.ForceGetConfigFile(args); + var mtv = new MigrationToolVersion(); var hostBuilder = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args); hostBuilder.UseSerilog((hostingContext, services, loggerConfiguration) => { - string outputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] [" + DetectVersionService2.GetRunningVersion().versionString + "] {Message:lj}{NewLine}{Exception}"; // {SourceContext} - string logsPath = CreateLogsPath(); - var logPath = Path.Combine(logsPath, $"migration{logs}.log"); - - var logLevel = hostingContext.Configuration.GetValue("LogLevel"); - var levelSwitch = new LoggingLevelSwitch(logLevel); - loggerConfiguration - .MinimumLevel.ControlledBy(levelSwitch) - .ReadFrom.Configuration(hostingContext.Configuration) - .Enrich.FromLogContext() - .Enrich.WithMachineName() - .Enrich.WithProcessId() - .WriteTo.File(logPath, LogEventLevel.Verbose, outputTemplate) - .WriteTo.Logger(lc => lc - .Filter.ByExcluding(Matching.FromSource("Microsoft")) - .Filter.ByExcluding(Matching.FromSource("MigrationTools.Host.StartupService")) - .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Debug, theme: AnsiConsoleTheme.Code, outputTemplate: outputTemplate)) - .WriteTo.Logger(lc => lc - .Filter.ByExcluding(Matching.FromSource("Microsoft")) - .WriteTo.ApplicationInsights(services.GetService(), new CustomConverter(), LogEventLevel.Error)); - logs++; + string outputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] [" + mtv.GetRunningVersion().versionString + "] {Message:lj}{NewLine}{Exception}"; // {SourceContext} + string logsPath = CreateLogsPath(); + var logPath = Path.Combine(logsPath, $"migration-{logs}.log"); + + var logLevel = hostingContext.Configuration.GetValue("LogLevel"); + var levelSwitch = new LoggingLevelSwitch(logLevel); + loggerConfiguration + .MinimumLevel.ControlledBy(levelSwitch) + .ReadFrom.Configuration(hostingContext.Configuration) + .Enrich.FromLogContext() + .Enrich.WithMachineName() + .Enrich.WithProcessId() + .WriteTo.File(logPath, LogEventLevel.Verbose, outputTemplate) + .WriteTo.Logger(lc => lc + .Filter.ByExcluding(Matching.FromSource("Microsoft")) + .Filter.ByExcluding(Matching.FromSource("MigrationTools.Host.StartupService")) + .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Debug, theme: AnsiConsoleTheme.Code, outputTemplate: outputTemplate)) + .WriteTo.Logger(lc => lc + .Filter.ByExcluding(Matching.FromSource("Microsoft")) + .WriteTo.ApplicationInsights(services.GetService (), new CustomConverter(), LogEventLevel.Error)); + logs++; + LoggerHasBeenBuilt = true; }); hostBuilder.ConfigureLogging((context, logBuilder) => @@ -114,6 +121,7 @@ public static IHostBuilder CreateDefaultBuilder(string[] args) services.AddTransient(); //services.AddTransient(); services.AddTransient(); + // Config services.AddSingleton(); diff --git a/src/MigrationTools.Host/Services/DetectVersionService2.cs b/src/MigrationTools.Host/Services/DetectVersionService2.cs index b11300eb0..0479ba637 100644 --- a/src/MigrationTools.Host/Services/DetectVersionService2.cs +++ b/src/MigrationTools.Host/Services/DetectVersionService2.cs @@ -9,6 +9,7 @@ using Microsoft.Extensions.Logging; using MigrationTools.DataContracts.Pipelines; using MigrationTools.EndpointEnrichers; +using MigrationTools.Services; using NuGet.Common; using NuGet.Configuration; using NuGet.Protocol; @@ -22,6 +23,7 @@ namespace MigrationTools.Host.Services { public class DetectVersionService2 : IDetectVersionService2 { + private IMigrationToolVersion _VerionsInfo; private readonly ITelemetryLogger _Telemetry; private ILogger _logger; @@ -45,7 +47,7 @@ public Version RunningVersion { get { - return GetRunningVersion().version; + return _VerionsInfo.GetRunningVersion().version; } } public Version AvailableVersion @@ -62,7 +64,7 @@ private Version GetAvailableVersion() { return Package.AvailableVersion; } - return new Version("0.0.0"); + return new Version("0.0.0"); } public Version InstalledVersion @@ -95,12 +97,13 @@ private bool GetIsPackageInstalled() return Package != null; } - public bool IsPackageManagerInstalled { + public bool IsPackageManagerInstalled + { get { return GetIsPackageManagerInstalled(); } - } + } private bool GetIsPackageManagerInstalled() { @@ -112,7 +115,7 @@ public bool IsPreviewVersion { get { - return !string.IsNullOrEmpty( GetRunningVersion().PreReleaseLabel); + return !string.IsNullOrEmpty(_VerionsInfo.GetRunningVersion().PreReleaseLabel); } } @@ -128,7 +131,7 @@ public bool IsRunningInDebug { get { - return GetRunningVersion().PreReleaseLabel.ToLower() == "local"; + return _VerionsInfo.GetRunningVersion().PreReleaseLabel.ToLower() == "local"; } } @@ -140,18 +143,20 @@ public bool IsNewLocalVersionAvailable } } - public DetectVersionService2(ITelemetryLogger telemetry, ILogger logger) + public DetectVersionService2(ITelemetryLogger telemetry, ILogger logger, IMigrationToolVersion verionsInfo) { + _VerionsInfo = verionsInfo; _Telemetry = telemetry; _logger = logger; if (IsPreviewVersion) { PackageId = "nkdAgility.AzureDevOpsMigrationTools.Preview"; - } else + } + else { PackageId = "nkdAgility.AzureDevOpsMigrationTools"; } - + } private WinGetPackage GetPackage() @@ -170,54 +175,32 @@ private WinGetPackage GetPackage() return _package; } - public static (Version version, string PreReleaseLabel, string versionString) GetRunningVersion() + public class Benchmark : IDisposable { - FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly()?.Location); - var matches = Regex.Matches(myFileVersionInfo.ProductVersion, @"^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-((?