in src/managed/DiffGen/ArchiveUtility/ItemDefinition.cs [131:187]
public static int Compare(ItemDefinition x, ItemDefinition y)
{
if (x.Length != y.Length)
{
return (x.Length < y.Length) ? -1 : 1;
}
if (x.Hashes.Count != y.Hashes.Count)
{
return x.Hashes.Count - y.Hashes.Count;
}
if ((x.Hashes.Count == 0) && (x.Names.Count != y.Names.Count))
{
return x.Names.Count - y.Names.Count;
}
var sortedXHashes = x.Hashes.OrderBy(x => x.Key);
var sortedYHashes = y.Hashes.OrderBy(y => y.Key);
foreach (var hashesPair in sortedXHashes.Zip(sortedYHashes))
{
if (hashesPair.First.Key != hashesPair.Second.Key)
{
return hashesPair.First.Key.CompareTo(hashesPair.Second.Key);
}
byte[] hashXValue = hashesPair.First.Value.Value;
byte[] hashYValue = hashesPair.Second.Value.Value;
foreach (var hashBytePair in hashXValue.Zip(hashYValue))
{
if (hashBytePair.First != hashBytePair.Second)
{
return hashBytePair.First - hashBytePair.Second;
}
}
}
if (x.Hashes.Count == 0)
{
var sortedXNames = x.Names.OrderBy(x => x);
var sortedYNames = y.Names.OrderBy(x => x);
foreach (var namePair in sortedXNames.Zip(sortedYNames))
{
var nameCompareResult = namePair.First.CompareTo(namePair.Second);
if (nameCompareResult != 0)
{
return nameCompareResult;
}
}
}
return 0;
}