in src/Microsoft.VisualStudio.Composition/ByValueEquality+AssemblyNameComparer.cs [32:72]
public bool Equals(AssemblyName? x, AssemblyName? y)
{
if (x is null && y is null)
{
return true;
}
if (x is null || y is null)
{
return false;
}
// If fast check is enabled, we can compare the code bases
if (this.fastCheck && x.CodeBase == y.CodeBase)
{
return true;
}
// There are some cases where two AssemblyNames who are otherwise equivalent
// have a null PublicKey but a correct PublicKeyToken, and vice versa. We should
// compare the PublicKeys first, but then fall back to GetPublicKeyToken(), which
// will generate a public key token for the AssemblyName that has a public key and
// return the public key token for the other AssemblyName.
byte[]? xPublicKey = x.GetPublicKey();
byte[]? yPublicKey = y.GetPublicKey();
// Testing on FullName is horrifically slow.
// So test directly on its components instead.
if (xPublicKey != null && yPublicKey != null)
{
return x.Name == y.Name
&& Equals(x.Version, y.Version)
&& string.Equals(x.CultureName, y.CultureName)
&& ByValueEquality.Buffer.Equals(xPublicKey, yPublicKey);
}
return x.Name == y.Name
&& Equals(x.Version, y.Version)
&& string.Equals(x.CultureName, y.CultureName)
&& ByValueEquality.Buffer.Equals(x.GetPublicKeyToken(), y.GetPublicKeyToken());
}