From 740369250ba86ab675dbfc7aba06fcf7d39b3959 Mon Sep 17 00:00:00 2001 From: Washi Date: Tue, 7 Nov 2023 20:37:03 +0100 Subject: [PATCH] BUGFIX: Test whether type's scope is the current assembly. --- src/AsmResolver.DotNet/DefaultMetadataResolver.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/AsmResolver.DotNet/DefaultMetadataResolver.cs b/src/AsmResolver.DotNet/DefaultMetadataResolver.cs index e80d5cae4..519e769da 100644 --- a/src/AsmResolver.DotNet/DefaultMetadataResolver.cs +++ b/src/AsmResolver.DotNet/DefaultMetadataResolver.cs @@ -177,6 +177,13 @@ public TypeResolution(IAssemblyResolver resolver) switch (scope.MetadataToken.Table) { case TableIndex.AssemblyRef: + if (reference.Module?.Assembly is { } assembly) + { + // Are we referencing the current assembly the reference was declared in? + if (SignatureComparer.Default.Equals(scope.GetAssembly(), assembly)) + return FindTypeInModule(reference.Module, reference.Namespace, reference.Name); + } + var assemblyDefScope = _assemblyResolver.Resolve((AssemblyReference) scope); return assemblyDefScope is not null ? FindTypeInAssembly(assemblyDefScope, reference.Namespace, reference.Name)