Skip to content

Commit bdc58c3

Browse files
committed
simplified logic to check if source allowed values contains all target values (#2952)
1 parent 4aff69a commit bdc58c3

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)