From 56d25b8f397d4181fb76d30bd49453da17bfeb99 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Thu, 13 Jun 2024 12:06:16 +0200 Subject: [PATCH] Compare just assembly names not full names --- .../src/Build.Tasks/TypeReferenceExtensions.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Controls/src/Build.Tasks/TypeReferenceExtensions.cs b/src/Controls/src/Build.Tasks/TypeReferenceExtensions.cs index 1989c825b1a6..44c060a9b028 100644 --- a/src/Controls/src/Build.Tasks/TypeReferenceExtensions.cs +++ b/src/Controls/src/Build.Tasks/TypeReferenceExtensions.cs @@ -9,12 +9,12 @@ namespace Microsoft.Maui.Controls.Build.Tasks { class TypeRefComparer : IEqualityComparer { - 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)); } @@ -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) @@ -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;