@@ -59,7 +59,7 @@ public class TfsNodeStructureTool : Tool<TfsNodeStructureToolOptions>
5959 private string _sourceProjectName ;
6060 private NodeInfo [ ] _sourceRootNodes ;
6161 private ICommonStructureService4 _targetCommonStructureService ;
62-
62+
6363 private string _targetProjectName ;
6464 private KeyValuePair < string , string > ? _lastResortRemapRule ;
6565
@@ -77,7 +77,7 @@ public void ApplySettings(TfsNodeStructureToolSettings settings)
7777 _targetProjectName = settings . TargetProjectName ;
7878 }
7979
80- public void ValidateAllNodesExistOrAreMapped ( TfsProcessor processor , List < WorkItemData > sourceWorkItems , string sourceProject , string targetProject )
80+ public void ValidateAllNodesExistOrAreMapped ( TfsProcessor processor , List < WorkItemData > sourceWorkItems , string sourceProject , string targetProject )
8181 {
8282 ContextLog . Information ( "Validating::Check that all Area & Iteration paths from Source have a valid mapping on Target" ) ;
8383 if ( ! Options . Enabled && targetProject != sourceProject )
@@ -108,22 +108,24 @@ public string GetNewNodeName(string sourceNodePath, TfsNodeStructureType nodeStr
108108 var lastResortRule = GetLastResortRemappingRule ( ) ;
109109
110110 Log . LogDebug ( "NodeStructureEnricher.GetNewNodeName::Mappers" , mappers ) ;
111- foreach ( var mapper in mappers )
111+ if ( mappers != null )
112112 {
113- Log . LogDebug ( "NodeStructureEnricher.GetNewNodeName::Mappers::{key}" , mapper . Key ) ;
114- if ( Regex . IsMatch ( sourceNodePath , mapper . Key , RegexOptions . IgnoreCase ) )
115- {
116- Log . LogDebug ( "NodeStructureEnricher.GetNewNodeName::Mappers::{key}::Match" , mapper . Key ) ;
117- string replacement = Regex . Replace ( sourceNodePath , mapper . Key , mapper . Value ) ;
118- Log . LogDebug ( "NodeStructureEnricher.GetNewNodeName::Mappers::{key}::replaceWith({replace})" , mapper . Key , replacement ) ;
119- return replacement ;
120- }
121- else
113+ foreach ( var mapper in mappers )
122114 {
123- Log . LogDebug ( "NodeStructureEnricher.GetNewNodeName::Mappers::{key}::NoMatch" , mapper . Key ) ;
115+ Log . LogDebug ( "NodeStructureEnricher.GetNewNodeName::Mappers::{key}" , mapper . Key ) ;
116+ if ( Regex . IsMatch ( sourceNodePath , mapper . Key , RegexOptions . IgnoreCase ) )
117+ {
118+ Log . LogDebug ( "NodeStructureEnricher.GetNewNodeName::Mappers::{key}::Match" , mapper . Key ) ;
119+ string replacement = Regex . Replace ( sourceNodePath , mapper . Key , mapper . Value ) ;
120+ Log . LogDebug ( "NodeStructureEnricher.GetNewNodeName::Mappers::{key}::replaceWith({replace})" , mapper . Key , replacement ) ;
121+ return replacement ;
122+ }
123+ else
124+ {
125+ Log . LogDebug ( "NodeStructureEnricher.GetNewNodeName::Mappers::{key}::NoMatch" , mapper . Key ) ;
126+ }
124127 }
125128 }
126-
127129 if ( ! Regex . IsMatch ( sourceNodePath , lastResortRule . Key , RegexOptions . IgnoreCase ) )
128130 {
129131 Log . LogWarning ( "NodeStructureEnricher.NodePathNotAnchoredException({sourceNodePath}, {nodeStructureType})" , sourceNodePath , nodeStructureType . ToString ( ) ) ;
@@ -153,7 +155,7 @@ private KeyValuePair<string, string> GetLastResortRemappingRule()
153155
154156 private NodeInfo GetOrCreateNode ( string nodePath , DateTime ? startDate , DateTime ? finishDate )
155157 {
156- Log . LogDebug ( "TfsNodeStructureTool:GetOrCreateNode({nodePath}, {startDate}, {finishDate})" , nodePath , startDate , finishDate ) ;
158+ Log . LogDebug ( "TfsNodeStructureTool:GetOrCreateNode({nodePath}, {startDate}, {finishDate})" , nodePath , startDate , finishDate ) ;
157159 if ( _pathToKnownNodeMap . TryGetValue ( nodePath , out var info ) )
158160 {
159161 Log . LogInformation ( " Node {0} already migrated, nothing to do" , nodePath ) ;
@@ -261,13 +263,13 @@ private Dictionary<string, string> GetMaps(TfsNodeStructureType nodeStructureTyp
261263 case TfsNodeStructureType . Area :
262264 return Options . Areas != null ? Options . Areas . Mappings : new Dictionary < string , string > ( ) ;
263265 case TfsNodeStructureType . Iteration :
264- return Options . Iterations != null ? Options . Iterations . Mappings : new Dictionary < string , string > ( ) ;
266+ return Options . Iterations != null ? Options . Iterations . Mappings : new Dictionary < string , string > ( ) ;
265267 default :
266268 throw new ArgumentOutOfRangeException ( nameof ( nodeStructureType ) , nodeStructureType , null ) ;
267269 }
268270 }
269271
270- public void ProcessorExecutionBegin ( TfsProcessor processor )
272+ public void ProcessorExecutionBegin ( TfsProcessor processor )
271273 {
272274 if ( Options . Enabled )
273275 {
@@ -278,13 +280,14 @@ public void ProcessorExecutionBegin(TfsProcessor processor)
278280 MigrateAllNodeStructures ( ) ;
279281 }
280282 RefreshForProcessorType ( processor ) ;
281- } else
283+ }
284+ else
282285 {
283286 Log . LogWarning ( "TfsNodeStructureTool: TfsNodeStructureTool is disabled! This may cause work item migration errors! " ) ;
284287 }
285288 }
286289
287- protected void EntryForProcessorType ( TfsProcessor processor )
290+ protected void EntryForProcessorType ( TfsProcessor processor )
288291 {
289292 if ( processor is null )
290293 {
@@ -309,10 +312,10 @@ protected void EntryForProcessorType(TfsProcessor processor)
309312 }
310313 }
311314
312- protected void RefreshForProcessorType ( TfsProcessor processor )
315+ protected void RefreshForProcessorType ( TfsProcessor processor )
313316 {
314-
315- ( ( TfsWorkItemMigrationClient ) processor . Target . WorkItems ) . Store ? . RefreshCache ( true ) ;
317+
318+ ( ( TfsWorkItemMigrationClient ) processor . Target . WorkItems ) . Store ? . RefreshCache ( true ) ;
316319 }
317320
318321 private void CreateNodes ( XmlNodeList nodeList , string treeType , TfsNodeStructureType nodeStructureType )
@@ -493,7 +496,7 @@ private bool ShouldCreateNode(string userFriendlyPath, TfsNodeStructureType node
493496 if ( DotNet . Globbing . Glob . Parse ( filter ) . IsMatch ( userFriendlyPath ) )
494497 {
495498 if ( ! _matchedPath . Contains ( userFriendlyPath ) )
496- {
499+ {
497500 _matchedPath . Add ( userFriendlyPath ) ;
498501 return true ;
499502 }
@@ -534,7 +537,7 @@ public string GetFieldNameFromTfsNodeStructureToolType(TfsNodeStructureType node
534537 public List < NodeStructureItem > CheckForMissingPaths ( TfsProcessor processor , List < WorkItemData > workItems , TfsNodeStructureType nodeType )
535538 {
536539 EntryForProcessorType ( processor ) ;
537- Log . LogDebug ( "TfsNodeStructureTool:CheckForMissingPaths" ) ;
540+ Log . LogDebug ( "TfsNodeStructureTool:CheckForMissingPaths" ) ;
538541 _targetCommonStructureService . ClearProjectInfoCache ( ) ;
539542
540543 string fieldName = GetFieldNameFromTfsNodeStructureToolType ( nodeType ) ;
@@ -545,24 +548,24 @@ public List<NodeStructureItem> CheckForMissingPaths(TfsProcessor processor, List
545548 . Distinct ( )
546549 . ToList ( ) ;
547550
548- Log . LogDebug ( "TfsNodeStructureTool:CheckForMissingPaths::{nodeType}Nodes::{count}" , nodeType . ToString ( ) , nodePaths . Count ) ;
551+ Log . LogDebug ( "TfsNodeStructureTool:CheckForMissingPaths::{nodeType}Nodes::{count}" , nodeType . ToString ( ) , nodePaths . Count ) ;
549552
550553 List < NodeStructureItem > missingPaths = new List < NodeStructureItem > ( ) ;
551554
552555 foreach ( var missingItem in nodePaths )
553556 {
554- Log . LogDebug ( "TfsNodeStructureTool:CheckForMissingPaths:Checking::{sourceSystemPath}" , missingItem . sourceSystemPath ) ;
555- Log . LogTrace ( "TfsNodeStructureTool:CheckForMissingPaths:Checking::{@missingItem}" , missingItem ) ;
557+ Log . LogDebug ( "TfsNodeStructureTool:CheckForMissingPaths:Checking::{sourceSystemPath}" , missingItem . sourceSystemPath ) ;
558+ Log . LogTrace ( "TfsNodeStructureTool:CheckForMissingPaths:Checking::{@missingItem}" , missingItem ) ;
556559 bool keepProcessing = true ;
557560 try
558561 {
559562 missingItem . targetPath = GetNewNodeName ( missingItem . sourcePath , nodeType ) ;
560- Log . LogTrace ( "TfsNodeStructureTool:CheckForMissingPaths:GetNewNodeName::{@missingItem}" , missingItem ) ;
563+ Log . LogTrace ( "TfsNodeStructureTool:CheckForMissingPaths:GetNewNodeName::{@missingItem}" , missingItem ) ;
561564 }
562565 catch ( NodePathNotAnchoredException ex )
563566 {
564- Log . LogDebug ( "TfsNodeStructureTool:CheckForMissingPaths:NodePathNotAnchoredException::{sourceSystemPath}" , missingItem . sourceSystemPath ) ;
565- Log . LogTrace ( "TfsNodeStructureTool:CheckForMissingPaths:NodePathNotAnchoredException::{@missingItem}" , missingItem ) ;
567+ Log . LogDebug ( "TfsNodeStructureTool:CheckForMissingPaths:NodePathNotAnchoredException::{sourceSystemPath}" , missingItem . sourceSystemPath ) ;
568+ Log . LogTrace ( "TfsNodeStructureTool:CheckForMissingPaths:NodePathNotAnchoredException::{@missingItem}" , missingItem ) ;
566569 missingItem . anchored = false ;
567570 List < int > workItemsNotAncored = workItems . SelectMany ( x => x . Revisions . Values )
568571 . Where ( x => x . Fields [ fieldName ] . Value . ToString ( ) . Contains ( missingItem . sourcePath ) )
@@ -580,13 +583,13 @@ public List<NodeStructureItem> CheckForMissingPaths(TfsProcessor processor, List
580583 PopulateIterationDatesFronSource ( missingItem ) ;
581584 try
582585 {
583- Log . LogDebug ( "TfsNodeStructureTool:CheckForMissingPaths:CheckTarget::{targetSystemPath}" , missingItem . targetSystemPath ) ;
586+ Log . LogDebug ( "TfsNodeStructureTool:CheckForMissingPaths:CheckTarget::{targetSystemPath}" , missingItem . targetSystemPath ) ;
584587 NodeInfo c = _targetCommonStructureService . GetNodeFromPath ( missingItem . targetSystemPath ) ;
585- Log . LogTrace ( "TfsNodeStructureTool:CheckForMissingPaths:CheckTarget::FOUND::{@missingItem}::FOUND" , missingItem ) ;
588+ Log . LogTrace ( "TfsNodeStructureTool:CheckForMissingPaths:CheckTarget::FOUND::{@missingItem}::FOUND" , missingItem ) ;
586589 }
587590 catch
588591 {
589- Log . LogDebug ( "TfsNodeStructureTool:CheckForMissingPaths:CheckTarget::NOTFOUND:{targetSystemPath}" , missingItem . targetSystemPath ) ;
592+ Log . LogDebug ( "TfsNodeStructureTool:CheckForMissingPaths:CheckTarget::NOTFOUND:{targetSystemPath}" , missingItem . targetSystemPath ) ;
590593 if ( Options . ShouldCreateMissingRevisionPaths && ShouldCreateNode ( missingItem . targetSystemPath , nodeType ) )
591594 {
592595
@@ -595,7 +598,7 @@ public List<NodeStructureItem> CheckForMissingPaths(TfsProcessor processor, List
595598 else
596599 {
597600 missingPaths . Add ( missingItem ) ;
598- Log . LogTrace ( "TfsNodeStructureTool:CheckForMissingPaths:CheckTarget::LOG-ONLY::{@missingItem}" , missingItem ) ;
601+ Log . LogTrace ( "TfsNodeStructureTool:CheckForMissingPaths:CheckTarget::LOG-ONLY::{@missingItem}" , missingItem ) ;
599602 }
600603 }
601604 }
@@ -611,7 +614,7 @@ private void PopulateIterationDatesFronSource(NodeStructureItem missingItem)
611614 {
612615 if ( missingItem . nodeType == "Iteration" )
613616 {
614- Log . LogDebug ( "TfsNodeStructureTool:PopulateIterationDatesFronSource:{sourceSystemPath}" , missingItem . sourceSystemPath ) ;
617+ Log . LogDebug ( "TfsNodeStructureTool:PopulateIterationDatesFronSource:{sourceSystemPath}" , missingItem . sourceSystemPath ) ;
615618 try
616619 {
617620 var sourceNode = _sourceCommonStructureService . GetNodeFromPath ( missingItem . sourceSystemPath ) ;
@@ -621,7 +624,7 @@ private void PopulateIterationDatesFronSource(NodeStructureItem missingItem)
621624 }
622625 catch ( Exception )
623626 {
624- Log . LogTrace ( "TfsNodeStructureTool:PopulateIterationDatesFronSource:{@missingItem}" , missingItem ) ;
627+ Log . LogTrace ( "TfsNodeStructureTool:PopulateIterationDatesFronSource:{@missingItem}" , missingItem ) ;
625628 missingItem . startDate = null ;
626629 missingItem . finishDate = null ;
627630 missingItem . sourcePathExists = false ;
0 commit comments