Skip to content

Commit 40c1462

Browse files
MrHinshma-chni
andauthored
Refactor GetFieldMappings for missing mappings (#3060)
Refactored the `GetFieldMappings` method in `FieldMappingTool.cs` to improve code clarity and functionality. Introduced a `result` list to aggregate both global (`"*"` wildcard) and specific mappings for a given work item type. The method now returns a combined list of mappings, ensuring both global and specific mappings are considered when applicable. Co-authored-by: Mattias Nielsen <[email protected]>
2 parents 56748e3 + 88c47b1 commit 40c1462

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/MigrationTools/Tools/FieldMappingTool.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,16 @@ public void AddFieldMap(string workItemTypeName, IFieldMap fieldToTagFieldMap)
7373

7474
public List<IFieldMap> GetFieldMappings(string witName)
7575
{
76-
if (_fieldMaps.TryGetValue("*", out List<IFieldMap> fieldMaps))
76+
var result = new List<IFieldMap>();
77+
if (_fieldMaps.TryGetValue("*", out var globalMaps))
7778
{
78-
return fieldMaps;
79+
result.AddRange(globalMaps);
7980
}
80-
else if (_fieldMaps.TryGetValue(witName, out fieldMaps))
81+
if (_fieldMaps.TryGetValue(witName, out var specificMaps))
8182
{
82-
return fieldMaps;
83+
result.AddRange(specificMaps);
8384
}
84-
return [];
85+
return result;
8586
}
8687

8788
public void ApplyFieldMappings(WorkItemData source, WorkItemData target)

0 commit comments

Comments
 (0)