Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XC] Make assembly comparison less strict #23031

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Controls/src/Build.Tasks/TypeReferenceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace Microsoft.Maui.Controls.Build.Tasks
{
class TypeRefComparer : IEqualityComparer<TypeReference>
{
static string GetAssembly(TypeReference typeRef)
static string GetAssemblyName(TypeReference typeRef)
{
if (typeRef.Scope is ModuleDefinition md)
return md.Assembly.FullName;
return md.Assembly.Name.Name;
if (typeRef.Scope is AssemblyNameReference anr)
return anr.FullName;
return anr.Name;
throw new ArgumentOutOfRangeException(nameof(typeRef));
}

Expand All @@ -30,8 +30,8 @@ public bool Equals(TypeReference x, TypeReference y)
var yname = y.FullName.EndsWith("&", StringComparison.InvariantCulture) ? y.FullName.Substring(0, y.FullName.Length - 1) : y.FullName;
if (xname != yname)
return false;
var xasm = GetAssembly(x);
var yasm = GetAssembly(y);
var xasm = GetAssemblyName(x);
var yasm = GetAssemblyName(y);

//standard types comes from either mscorlib. System.Runtime or netstandard. Assume they are equivalent
if ((xasm.StartsWith("System.Runtime", StringComparison.Ordinal)
Expand All @@ -50,7 +50,7 @@ public bool Equals(TypeReference x, TypeReference y)

public int GetHashCode(TypeReference obj)
{
return $"{GetAssembly(obj)}//{obj.FullName}".GetHashCode();
return $"{GetAssemblyName(obj)}//{obj.FullName}".GetHashCode();
}

static TypeRefComparer s_default;
Expand Down
Loading