From bb52b5718a5c1619a3f2518b622d467084921202 Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Mon, 24 Feb 2025 09:28:14 -0800 Subject: [PATCH] Use right hand side references even when not compatible Not using references at all creates a problem when comparing against API that requires a core-assembly for resolving syntax (EG: Nullable<> -> `?`) Whenever a package is replacing a more specific assembly with a less specific assembly it still needs to be compatible with the less specific references. --- .../ApiCompatRunnerExtensions.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Compatibility/ApiCompat/Microsoft.DotNet.PackageValidation/ApiCompatRunnerExtensions.cs b/src/Compatibility/ApiCompat/Microsoft.DotNet.PackageValidation/ApiCompatRunnerExtensions.cs index cd716170e22f..fbc6fc1c3588 100644 --- a/src/Compatibility/ApiCompat/Microsoft.DotNet.PackageValidation/ApiCompatRunnerExtensions.cs +++ b/src/Compatibility/ApiCompat/Microsoft.DotNet.PackageValidation/ApiCompatRunnerExtensions.cs @@ -42,6 +42,12 @@ public static void QueueApiCompatFromContentItem(this IApiCompatRunner apiCompat { fallbackAssemblyReferences = rightPackage.FindBestAssemblyReferencesForFramework(leftTargetFramework); } + + // if we cannot find references for the left framework, then just use the same right references for the left assembly + if (fallbackAssemblyReferences is null && rightContentItems[0].Properties.TryGetValue("tfm", out tfmObj) && tfmObj is NuGetFramework rightTargetFramework) + { + fallbackAssemblyReferences = rightPackage.FindBestAssemblyReferencesForFramework(rightTargetFramework); + } } MetadataInformation[] left = new MetadataInformation[leftContentItems.Count];