Skip to content

Commit 81bff2a

Browse files
authored
#2952 issue ,check target field allowed values contain all allowed source field values (#2953)
When trying to migrate from Azure Devops 2019 to Azure Devops 2022, in user story , Resolved reason which is of type Microsoft.VSTS.Common.ResolvedReason , has extra value "Will not fix" in target values. in source code, instead of checking equality of source field count and target field count modified check to targetfields.count< sourcefields.count. Source Azure Devops Version : 2019 Target Azure Devops Version: 2022 Microsoft.VSTS.Common.ResolvedReason in 2022 , has extra value "will not fix". There is no way in Azure Devops 2022 or Azure Devops 2019 to modify Microsoft.VSTS.Common.ResolvedReason. Therefore, instead of checking number of fields, checking all allowed source field values in allowed target field values is enough. Also modified name of method from **AllowedValuesAreSame** to **DoesTargetContainsAllSourceValues**
2 parents 4aff69a + bdc58c3 commit 81bff2a

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/MigrationTools.Clients.TfsObjectModel/Tools/TfsWorkItemTypeValidatorTool.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private bool ValidateFieldAllowedValues(FieldDefinition sourceField, FieldDefini
189189
+ " source = '{sourceFieldAllowedValueType}', target = '{targetFieldAllowedValueType}'.",
190190
sourceField.ReferenceName, targetField.ReferenceName, sourceValueType, targetValueType);
191191
}
192-
if (!AllowedValuesAreSame(sourceAllowedValues, targetAllowedValues))
192+
if (!DoesTargetContainsAllSourceValues(sourceAllowedValues, targetAllowedValues))
193193
{
194194
isValid = false;
195195
Log.Log(logLevel,
@@ -204,21 +204,9 @@ private bool ValidateFieldAllowedValues(FieldDefinition sourceField, FieldDefini
204204
return isValid;
205205
}
206206

207-
private bool AllowedValuesAreSame(List<string> sourceAllowedValues, List<string> targetAllowedValues)
208-
{
209-
if (sourceAllowedValues.Count != targetAllowedValues.Count)
210-
{
211-
return false;
212-
}
213-
foreach (string sourceValue in sourceAllowedValues)
214-
{
215-
if (!targetAllowedValues.Contains(sourceValue, StringComparer.OrdinalIgnoreCase))
216-
{
217-
return false;
218-
}
219-
}
220-
return true;
221-
}
207+
private bool DoesTargetContainsAllSourceValues(List<string> sourceAllowedValues, List<string> targetAllowedValues) =>
208+
sourceAllowedValues.Except(targetAllowedValues, StringComparer.OrdinalIgnoreCase).Count() == 0;
209+
222210

223211
private (string valueType, List<string> allowedValues) GetAllowedValues(FieldDefinition field)
224212
{

0 commit comments

Comments
 (0)