88using MigrationTools . DataContracts ;
99using MigrationTools . Processors . Infrastructure ;
1010using MigrationTools . Tools . Infrastructure ;
11+ using Riok . Mapperly . Abstractions ;
1112
1213namespace MigrationTools . Tools
1314{
@@ -23,6 +24,7 @@ public TfsUserMappingTool(IOptions<TfsUserMappingToolOptions> options, IServiceP
2324 }
2425
2526 private readonly CaseInsensitiveStringComparer _workItemNameComparer = new ( ) ;
27+ private readonly TfsUserMappingToolMapper _mapper = new ( ) ;
2628
2729 private HashSet < string > GetUsersFromWorkItems ( List < WorkItemData > workitems , List < string > identityFieldsToCheck )
2830 {
@@ -76,7 +78,7 @@ private Dictionary<string, string> GetMappingFileData()
7678 try
7779 {
7880 var fileMaps = Newtonsoft . Json . JsonConvert . DeserializeObject < List < IdentityMapData > > ( fileData ) ;
79- _UserMappings = fileMaps . ToDictionary ( x => x . Source . FriendlyName , x => x . Target ? . FriendlyName ) ;
81+ _UserMappings = fileMaps . ToDictionary ( x => x . Source . DisplayName , x => x . Target ? . DisplayName ) ;
8082 }
8183 catch ( Exception )
8284 {
@@ -106,11 +108,7 @@ private List<IdentityItemData> GetUsersListFromServer(IGroupSecurityService gss)
106108 else if ( ( identity . Type == IdentityType . WindowsUser ) || ( identity . Type == IdentityType . UnknownIdentityType ) )
107109 {
108110 // UnknownIdentityType is set for users in Azure Entra ID.
109- foundUsers . Add ( new IdentityItemData ( )
110- {
111- FriendlyName = identity . DisplayName ,
112- AccountName = identity . AccountName
113- } ) ;
111+ foundUsers . Add ( _mapper . IdentityToIdentityItemData ( identity ) ) ;
114112 }
115113 else
116114 {
@@ -154,7 +152,7 @@ public List<IdentityMapData> GetUsersInSourceMappedToTargetForWorkItems(TfsProce
154152 Log . LogDebug ( $ "TfsUserMappingTool::GetUsersInSourceMappedToTargetForWorkItems [workItemUsers|{ workItemUsers . Count } ]") ;
155153 List < IdentityMapData > mappedUsers = GetUsersInSourceMappedToTarget ( processor ) ;
156154 Log . LogDebug ( $ "TfsUserMappingTool::GetUsersInSourceMappedToTargetForWorkItems [mappedUsers|{ mappedUsers . Count } ]") ;
157- return mappedUsers . Where ( x => workItemUsers . Contains ( x . Source . FriendlyName ) ) . ToList ( ) ;
155+ return mappedUsers . Where ( x => workItemUsers . Contains ( x . Source . DisplayName ) ) . ToList ( ) ;
158156 }
159157 else
160158 {
@@ -176,4 +174,12 @@ public int GetHashCode(string obj)
176174 return obj . GetHashCode ( ) ;
177175 }
178176 }
177+
178+ [ Mapper ]
179+ internal partial class TfsUserMappingToolMapper
180+ {
181+ #pragma warning disable RMG020 // Source member is not mapped to any target member
182+ public partial IdentityItemData IdentityToIdentityItemData ( Identity identity ) ;
183+ #pragma warning restore RMG020 // Source member is not mapped to any target member
184+ }
179185}
0 commit comments